Full-text search across your local Claude Code transcripts — then jump straight back into the session that has what you were looking for.
cbg shows you the shape of your sessions (the fork tree). cfind shows you what is
inside them: every prompt you typed, every reply, every command run, every byte of tool
output — and a ready-to-paste /resume for each hit.
Zero LLM tokens. Pure static local code: no network, no API key, nothing leaves the machine.
This is a Rust rewrite of the original single-file Node implementation, which lives in
../magical and is still the reference the test suite diffs against. Same flags, same
output, same exit codes, with one behavioural change — the search is scoped to the
directory you run it from — and about 15× the speed. See
Differences from the Node implementation.
./install.sh # prebuilt binary, SHA-256 verified, into ~/.local/bin
BINDIR=/usr/local/bin ./install.sh
FROM_SOURCE=1 ./install.sh # cargo build --release instead
./install-dev.sh # symlink target/release, for working on it
./uninstall.shBuilding from source needs Rust ≥ 1.75. There is no runtime dependency at all — the result is one static binary, no Node.
install.sh downloads from $REPO (default KCSAbeywickrama/c-find) and verifies
the download against the release's SHA256SUMS, refusing to install anything it cannot
verify. Until that repository exists it falls through to building from source, so
./install.sh works either way; set REPO=owner/name once it is published.
cfind "drizzle migration" # search this project's conversation (prompts + replies)
cfind -g "drizzle migration" # ...every project on the machine
cfind -t "kubectl rollout" # ...and tool calls: commands, file paths, edits
cfind -o "ENOENT" # ...and tool output
cfind -a "port 8090" # everything
cfind -L "I found build.sh:30" # ignore markup: matches `build.sh:30` in backticks
cfind "--host-resolver-rules maps names" # a query that starts with a dash
cfind -- --json # ...a single dash-word needs -- in front
cfind -l # browse this project's sessions, newest first
cfind --stats # what is actually in your transcriptscfind "gate" · 60 matches in 2 of 2 sessions · conversation · ~/path/to/project · 0.01s
▸ rewrite-cfind-rust 2026-08-25 15:16 57 hits
~/path/to/project · HEAD · dd8fe295 · 3 subagents
user 13:59 subagent Two things to investi[gate] on this machine (read-only): A) In /path/to/w…
asst 13:59 Explore I'll investi[gate] both in parallel.
· 8 more matches in this session
/resume dd8fe295-dcbd-41a5-8c8a-1758f3b08176
▸ Build a magical useful tool 2026-08-18 11:59 3 hits
~/path/to/project · HEAD · afb6b6be · 2 subagents
user 15:24 subagent …p large files. Investi[gate] and report concisely: 1. Shell setup: read ~…
asst 15:24 Explore I'll investi[gate] the environment efficiently with parallel searches.
· 1 more match in this session
/resume afb6b6be-2c71-489c-8b6b-830fddf6ac00
Because it prints /resume <id>, you can run it from inside Claude Code as !cfind ...
and paste the line straight back.
By default, the directory you ran it from and everything below it. Running cfind
inside a repo searches that repo's sessions; the header always names the scope so a
result is never ambiguous.
cfind "flaky" · 4 matches in 1 of 2 sessions · conversation · ~/path/to/project · 0.01s
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-g widens it to every project. -p <substring> and --session <id> imply -g, since
naming a project or a session id is already a statement about where to look.
Two things make this less trivial than it sounds, and both are handled:
- Project directory names are lossy.
-Users-me-tools-branch-graph-rustcould be/tools/branch-graph-rustor/tools/branch/graph/rust; you cannot invert the mangling. So the directory name is only ever used as a cheap prefilter, deliberately generous — it can produce false positives, never false negatives. - Sessions are filed under the repo root, not their cwd. A session started in
repo/services/apilives in the project directory named forrepo. The authoritative test is therefore thecwdrecorded inside the transcript, and a session that moved directories mid-run is matched if any of its recorded directories is in scope.
A session with no recorded cwd at all falls back to the directory-name evidence rather
than being dropped silently.
Conversation text is a small slice of a transcript; tool traffic is the bulk of it. The default scope is the conversation, so results stay signal-dense and searches stay fast. Widen it when you are hunting for a command or an error string.
| Scope | Flag | What it adds |
|---|---|---|
| Conversation | (default) | Your prompts and Claude's replies |
| Tool calls | -t |
tool_use inputs — shell commands, file paths, edit bodies |
| Tool output | -o |
tool_result contents — command output, file contents, errors |
| Everything | -a |
Both of the above |
--stats prints the split for your own corpus:
Claude Code transcript corpus ~/.claude/projects
sessions 132 projects 8 subagent transcripts 33
range 2026-07-17 to 2026-08-25 (39 days)
records 105,269 lines on disk 312.1 MB
searchable text
user prompts 2.8 MB 4.5% [default]
assistant replies 5.4 MB 8.8% [default]
tool calls 18.1 MB 29.7% [-t]
tool output 34.7 MB 56.9% [-o]
injected boilerplate 1.7 MB [--meta]
thinking blocks (empty - display is "omitted", nothing to search)
top tools Bash 18,032 · Edit 3,251 · Read 2,560 · AskUserQuestion 570 · Write 451
scanned in 0.09s, zero LLM tokens
2 of 2 sessions in ~/path/to/project · 0.00s
2026-08-25 15:31 dd8fe295 ~/path/to/project HEAD rewrite-cfind-rust
2026-08-25 14:02 afb6b6be ~/path/to/project HEAD Build a useful to…
| Flag | Meaning |
|---|---|
-t, --tools |
Include tool calls |
-o, --output |
Include tool output |
-a, --all |
Include everything |
--meta |
Include injected boilerplate (caveats, skill dumps) — excluded by default |
--no-dedupe |
Keep duplicate matches copied into forked sessions |
-L, --loose |
Ignore punctuation, markup and whitespace differences |
-e, --regex |
Treat the query as a regular expression |
-s, --case |
Case-sensitive (default: insensitive) |
-w, --word |
Whole words only |
-g, --global |
Every project, not just the current directory and below |
-p, --project <s> |
Only sessions whose project path contains s (implies -g) |
-b, --branch <s> |
Only sessions whose git branch contains s |
--session <s> |
Only sessions whose id starts with s (implies -g) |
-r, --role <r> |
user, assistant or tool |
--tool <name> |
Only this tool's calls/results, e.g. --tool Bash (implies -t) |
--since <when> |
2026-07-01, 7d, 24h, 2w, 3m |
--until <when> |
Same forms; a bare date means the end of that day |
-m, --max <n> |
Max sessions shown (default 20, 0 = all) |
-n, --hits <n> |
Max hits per session (default 3, 0 = all) |
-C, --context <n> |
Context characters around a match (default 100) |
-l, --list |
One line per session, no snippets |
--json |
Machine-readable output |
--html |
Write a self-contained HTML report, print its path |
--out <file> |
Where the report goes (implies --html) |
--stats |
Corpus overview |
--color / --no-color |
Force or disable ANSI color |
-- |
End of flags: everything after it is the query |
-h, --help / -V, --version |
Honors NO_COLOR, FORCE_COLOR, CLAUDECODE, and TTY detection. Exit code is 1 when a
search finds nothing and 2 on a usage error, so cfind foo && echo hit works in scripts.
(--json and --html return before that, so they exit 0 even with no matches — as in
the Node version.)
- Text you copy out of a rendered view will often not match literally. The terminal
renders markdown, so what reads as
I found build-runner.sh:30is stored asI found `build-runner.sh:30`— backticks and all — and a literal search correctly finds nothing.cfind's own snippets also collapse whitespace, so a wrapped line becomes a single space.-Lmatches the words in order while allowing up to four punctuation, symbol or whitespace characters between them, which covers backticks,**bold**, list markers and line wraps without matching unrelated text. When a literal search returns nothing,cfindretries loosely on its own and tells you if that would have found it. - Forked sessions duplicate their parent's history. In a heavily forked project more
than half of all messages exist in several transcripts, so a naive search returns the
same hit again and again.
cfindkeeps each logical match once — in the most recently active session, the one you are most likely to want to resume — notesalso in N forks, and reports how many copies it folded away.--no-dedupeturns this off. - Subagent transcripts are searched too. A subagent's log lives at
<project>/<sessionId>/subagents/agent-*.jsonl; its hits are attributed to the parent session and tagged with the agent type (Explore,Plan, …). - Thinking blocks contain no text. Recent models default to
display: "omitted", so thethinkingfield is an empty string. There is nothing to search there. - Injected boilerplate is excluded by default. Skill dumps,
<local-command-caveat>blocks and session-name reminders areisMetarecords; they would otherwise dominate results.--metaputs them back. - Titles come from your custom title, else Claude's generated title, else the last prompt, else the first prompt.
- Damaged transcripts degrade rather than fail. An unparseable line or an unreadable file is counted and reported in a trailing note; the rest of the corpus is still searched.
A full corpus is a few hundred MB of JSONL, and decoding all of it per query would be slow. Three things do the work:
- A lossless gate. For a literal query
cfindfirst tests each raw line against the longest run of characters in the query that JSON encodes byte-for-byte, and only decodes the lines that pass. Runs containing a quote, a backslash or a non-ASCII character are never used, which keeps the gate lossless: it cannot skip a line that would have matched. A--regexquery has no such gate and decodes everything. - No wasted decoding. With the default scope neither
tool_use.inputnortool_result.contentis ever searched — and those are ~87% of the bytes — so they are skipped by the JSON lexer instead of being allocated. - All of the cores. Files are memory-mapped rather than copied, and scanned in parallel, largest first so the tail stays short.
Measured on this machine — 312 MB, 165 transcripts, 132 sessions, 105,269 records — best
of five warm runs, with -g on the Rust side so the two search the same corpus:
| Command | Node | Rust | |
|---|---|---|---|
cfind "flaky" |
0.81s | 0.04s | 20× |
cfind -a "error" |
1.07s | 0.12s | 9× |
cfind --stats |
1.32s | 0.09s | 15× |
cfind -e "ENOENT" (no gate) |
1.25s | 0.07s | 18× |
cfind "cargo test x" (0 hits, double scan) |
1.72s | 0.12s | 14× |
cfind -l |
1.28s | 0.06s | 21× |
Scoped to one project, the same search is ~0.01s, because whole project directories are skipped before any I/O.
Everything below is deliberate. tests/golden/compare.sh diffs the two implementations
across 72 flag combinations — comparing stdout, stderr and the exit code — and fails
if anything else differs.
Fixes.
-
--toolno longer under-reports on tool output. In the JS, thetool_useid → name map is only filled from lines that clear the gate, so atool_resultwhose call line was skipped renders as<outinstead of<Bashand is dropped by--tool. Measured on a 312 MB snapshot:-o --tool Bash "ENOENT"found 35 matches in 3 sessions where this finds 57 in 7, and an-o "flaky"HTML report had 50 unlabelled rows against 0 here. -
--stats"on disk" is now actually bytes. The JS counts UTF-16 string length: on the same snapshot it reported 311,499,503 where the disk holds 312,150,873, which is what this reports. Same fix fortextLengthin--json. -
Ordering is deterministic. Directory enumeration is sorted, where the JS inherits readdir order — which also decided which of a session's files won when resolving last-write-wins metadata.
-
A query may start with a dash. The JS rejects
cfind "--host-resolver-rules maps names"as an unknown flag, putting a whole class of real searches — any CLI flag discussed in a session — out of reach. Two rules fix that without giving up typo detection:- a dash-leading argument containing whitespace is a query, because no flag has a space in it. A single argv entry with a space is proof the shell saw quotes, since it would otherwise have been split into several arguments;
--ends flag parsing, for the single-word case (cfind -- --json).
A dash-leading word is still an unknown-flag error, so
--jsonnis caught as a misspelling rather than silently searched for. The error now names the escape hatch, which is the one usage string that differs from the JS.
Accepted changes.
- The search is scoped to the current directory unless
-gis given. This is the one change you will notice; it is why the golden comparison passes-g. --jsonaddsscope.directory, naming the searched scope (nullwhen global).-euses Rust'sregex, which is linear-time and therefore has no lookaround or backreferences; those are rejected with a clear message. The JSRegExperror text cannot be reproduced verbatim either.-m/-n/-Cparse strictly. Node'sNumber()also accepts1e3→ 1000,0x10→ 16," 5 "→ 5, and""→ 0 (so-m ""silently meant "all").--since/--untilaccepth/d/w/moffsets (mis 30 days, not a calendar month),YYYY-MM-DD(local midnight; local 23:59:59.999 for--until) and RFC 3339. Node falls back toDate.parse, whose tolerant path is not worth reproducing.- Lengths and widths count Unicode scalars, not UTF-16 units, so a context window around
an astral character can differ by a character or two. In exchange, a snippet can never
split a surrogate pair the way the JS
slice()can. - The
--htmlfooter timestamp is locale-pinned rather thantoLocaleString(). --helpcomes fromhelp.txtrather than the binary reading its own source, and documents-gand--.
| Variable | Effect |
|---|---|
CLAUDE_CONFIG_DIR |
Overrides ~/.claude |
CLAUDE_PROJECTS_DIR |
Overrides the projects directory outright |
NO_COLOR / FORCE_COLOR |
Standard color control |
CLAUDECODE |
Set inside Claude Code; keeps !cfind ... output coloured |
cargo test # 82 unit + 15 end-to-end tests
cargo clippy --all-targets
cargo fmt --check
tests/golden/compare.sh # diff against the Node original (needs node + a corpus)
tests/golden/compare.sh -v # ...and show each diffcompare.sh snapshots ~/.claude/projects before it starts: Claude Code is probably
writing to that directory right now, and a transcript that grows between the two runs
looks exactly like a bug.
The end-to-end tests build their own synthetic corpus, so they cover what the differential
test cannot — the directory scoping, and the --tool fix, where matching the JS would
mean reproducing a bug.
| File | Lines | What |
|---|---|---|
src/scan.rs |
871 | enumerate, scan in parallel, merge, dedupe |
src/matcher.rs |
616 | the gate, the literal fast path, snippets |
src/model.rs |
603 | tolerant serde types for a transcript record |
src/render/ |
1101 | terminal, JSON and HTML output |
src/extract.rs |
385 | what strings a record contributes |
src/stats.rs |
382 | --stats |
src/time.rs |
357 | local time and the --since grammar, via libc |
src/args.rs |
357 | the CLI contract, transcribed rather than redesigned |
src/scope.rs |
301 | the two-tier directory scope |
src/jv.rs |
231 | a JSON value that keeps object key order |
src/main.rs |
133 | wiring, output mode, exit codes |
src/term.rs |
105 | colour decision, terminal width |
5,442 lines including tests, against 1,123 for the single-file Node original.
MIT
c-find is a third-party tool and is not affiliated with Anthropic.