Exit codes
rf declares twelve exit codes and never overloads them.
| Exit | Class | Meaning | Retryable |
|---|---|---|---|
0 |
success | The operation ran. This includes an empty result (data.items is []). |
n/a |
1 |
user-input error | The call is wrong: an unknown verb or flag, an absent argument, a value that fails validation, a bad regex, or a named path that does not exist. | No — fix the call |
2 |
safety block | Part of the exit dictionary. No rf 0.1.2 error code uses it. |
No |
3 |
tool-environment error | The environment stopped the call: a named path that cannot be read, a program that the call needs and that is absent, or a Git history scan that failed. | n/a — fix the environment |
4 |
transient failure | Part of the exit dictionary. No rf 0.1.2 error code uses it. |
Yes |
5 |
conflict | The result set changed after an earlier page, so the cursor is stale. | No — start the query again without the cursor |
6 |
findings present | The verb ran and found a fault: doctor found an absent or unhealthy external tool, or conformance found a failed case. data stays in the envelope. |
No — read errors |
7 |
internal error | A defect in rf that the totality wrapper caught. |
No — report it |
129 |
signal | Ended by SIGHUP. | n/a |
130 |
signal | Ended by SIGINT. | n/a |
141 |
signal | The reader closed the pipe. | n/a |
143 |
signal | Ended by SIGTERM. | n/a |
“Retryable” answers one question: can the same call succeed if you send it
again unchanged? n/a means the question does not apply.
Why empty is exit 0
A plain rg exits 1 when it finds nothing, which conflates “the term is not
here” with “the search failed.” A caller cannot tell the two apart. rf splits
them: a genuine empty result is exit 0 with ok: true and data.items equal to
[]. A broken call, a broken environment, a stale cursor, or an internal defect
gets a non-zero code with a populated errors array. See the
agent guide.
Exit 6: the verb ran and found a fault
doctor and conformance are checks. When a check finds a fault, the verb did
its job, so the result stays: ok is false, data holds the full report, and
errors has one entry for each finding. All other failures have data: null.
Error codes
When rf exits non-zero, errors[] carries a stable code. Each entry also has
exit_code, message, remediation, arg, details, did_you_mean, and
path. The complete set:
| Code | Exit | Meaning |
|---|---|---|
UNKNOWN_COMMAND |
1 |
The command is not recognized. |
UNKNOWN_FLAG |
1 |
The flag is not recognized. |
MISSING_REQUIRED |
1 |
A required positional, flag, flag value, or companion flag is absent (for example --structural without --lang). |
INVALID_INPUT |
1 |
A supplied value failed validation: type, range, enum, pattern, empty value, flag conflict, surplus positional, or malformed cursor. |
INVALID_SELECTION |
1 |
Selected-input bytes or paths failed validation. |
BAD_PATTERN |
1 |
The search pattern failed to compile. |
NOT_FOUND |
1 |
A path that the caller named does not exist. |
IO_FAILURE |
3 |
A path that the caller named exists and cannot be read. |
DEPENDENCY_MISSING |
3 |
A program that the call needs is not on the search path (find --structural without ast-grep). |
HISTORY_ERROR |
3 |
Git history could not be scanned; no partial result was returned. |
CONFLICT |
5 |
A cursor snapshot no longer matches the current result set. |
COMPONENT_DEGRADED |
6 |
doctor found an optional external tool absent; the find source that depends on it cannot run. |
COMPONENT_UNHEALTHY |
6 |
doctor found an external tool that is present and does not run correctly. |
CASE_FAILED |
6 |
One conformance case has verdict fail. There is one error for each failed case. |
INTERNAL |
7 |
A defect in rf that the totality wrapper caught. |
Warning codes
Warnings never change the exit code. Each one is an entry in warnings[] as
{ code, message, details }. For a recovered miss, details.files lists the
paths. The complete set:
| Code | Meaning |
|---|---|
IGNORE_VCS |
A .gitignore/.ignore rule hides a match from a default search; add -u. |
HIDDEN_SKIPPED |
A hidden path hides a match from a default search; add -uu. |
BINARY_SKIPPED |
Binary detection hides a match from a default search; add -uu -a. |
CASE_SENSITIVE |
A search without case finds a match that the default search does not; add -i. |
ENCODING_MISS |
UTF-16 decoding finds a match that the default search does not. |
IGNORE_SOURCE_UNRESOLVED |
why could not identify the ignore rule that hides the file. |
PARTIAL_RESULT |
One or more paths could not be read; the result covers the other paths. With --matches, a matched file that could not be read for its occurrences has matches: null. |
FD_NAME |
The name filter excludes a file whose content matches. |
FD_HIDDEN |
A hidden path excludes a file whose content matches. |
FD_IGNORE |
An ignore rule excludes a file whose content matches. |
RG_BINARY |
Binary detection excludes a file whose content matches. |
GIT_DELETED |
The match exists only in Git history. |
GIT_ABSENT |
git is not available, so history was not searched. |
EXTERNAL_TOOL_MISSING |
git is present and cannot run, so history was not searched. |
GIT_NOT_WORK_TREE |
The root is not a Git work tree, so history was not searched. |
GIT_HISTORY_PARTIAL |
The history scan budget ended before all revisions were read. |
GIT_SCRUB_WORD_UNAVAILABLE |
Whole-word mode omits Git pickaxe evidence. |
GIT_SCRUB_UNAVAILABLE |
git log failed or passed its time limit, so the commit that removed a history-only match is unknown. |
AST_STRUCTURAL |
The match comes only from the structural stage. |
STRUCTURAL_UNAVAILABLE |
ast-grep is present and failed or exceeded its time limit, so the structural stage did not run. |
IGNORE_MODE |
doctor reports the active ignore mode for the path. |
Both tables are the curated view. rf capabilities --json is the authoritative
source: errors and warnings are in one registry, data.error_codes. A code with
exit: null is a warning.
Internal defects
There is one totality wrapper. A defect in rf becomes an error envelope with
code INTERNAL and exit 7. An environment failure exits 3.
An absent external tool does not always stop a search. find without git
still runs and adds the GIT_ABSENT warning. find --structural without
ast-grep cannot do what you asked, so it exits 3 with DEPENDENCY_MISSING.