Quickstart
A few minutes from zero to seeing recovered matches. Every command is runnable verbatim from a scratch directory.
Build a repo that hides matches
QS=$(mktemp -d) && cd "$QS"
git init -q
printf 'timeout = 30\n' > config.py # tracked
printf 'timeout = 5\n' > .env.local # hidden dotfile
mkdir cache && printf 'timeout = 999\n' > cache/build.py
printf 'cache/\n' > .gitignore # gitignore the cache
git add -A && git commit -qm 'initial'
Three files contain timeout: one tracked, one hidden, one gitignored.
What a naive search sees
rg timeout .
config.py:1:timeout = 30
One of three, exit 0. The search looks complete. It is not.
What rf sees
rf content timeout .
content 'timeout' in . [regex]: 3 file(s), 1 by default, 2 hidden by filters
default config.py
hidden .env.local
vcs_ignore cache/build.py
! IGNORE_VCS: 1 match(es) hidden by default; add -u (ignore .gitignore/.ignore rules)
! HIDDEN_SKIPPED: 1 match(es) hidden by default; add -uu (also search hidden/dotfiles)
$ 'rg' '-u' '-e' 'timeout' '--' '.'
$ 'rg' '-uu' '-e' 'timeout' '--' '.'
All three matches. Each recovered file is attributed to the filter that hid it,
and each miss carries a paste-ready rg command to confirm it independently.
The same thing as JSON
With --json, rf prints one structured envelope instead of the summary. A
pipe alone does not change the output:
rf content timeout . --json
{
"ok": true,
"data": {
"items": [
{ "file": "config.py", "surfaced_by": "default", "matches": null, "selection": null },
{ "file": ".env.local", "surfaced_by": "hidden", "matches": null, "selection": null },
{ "file": "cache/build.py", "surfaced_by": "vcs_ignore", "matches": null, "selection": null }
],
"total": 3
},
"meta": { "matched_files": 3, "default_matched_files": 1, "hidden_by_filters": 2, "…": "…" }
}
The warnings array (elided here) holds one entry per miss. See the
JSON contract for every key.
An empty result is not an error
Search for a term that is not there:
rf content nonexistent-token . ; echo "exit $?"
content 'nonexistent-token' in . [regex]: 0 file(s), 0 by default, 0 hidden by filters
exit 0
rf returns exit 0, and the JSON envelope has data.items equal to []. A plain rg would exit 1 and conflate “no
match” with “the search failed.” See Exit codes.
Ask about one file
rf why timeout cache/build.py
why 'timeout' cache/build.py [regex any sensitive]: MATCH - hidden by vcs_ignore
ignore rule: .gitignore:1 (cache/)
! IGNORE_VCS: match hidden from a default tree search; add -u (ignore .gitignore/.ignore rules)
$ 'rg' '-u' '-e' 'timeout' '--' '.'
why names the rule that hid the file. See The why verb.
Clean up
cd / && rm -rf "$QS"
Next steps
- How it works — the in-process engine and layer peeling
- The find verb — staged discovery across four sources
- Agent guide — scripting rf safely