# ctxgrep

One command finds "that thing we figured out last week" across every Claude Code transcript on the box, without remembering which project it was in. Rust, MIT, nothing leaves the machine.

You figured something out with Claude Code last week. A cookie name, a build flag, why a page was returning a 500. Now you need it again and you can't remember which project the conversation was in, so you open a fresh session and figure it out a second time. I did this a lot.

The thing is, Claude Code already keeps all of it. Every conversation is a plain file under `~/.claude/projects` - your messages, Claude's replies, every tool's output. Nobody reads those files because nothing makes them easy to read.

`ctxgrep` is a small Rust tool that reads them. It builds an index, never changes the transcripts, and nothing leaves the machine. Version 0.1.0, MIT licence, tested on Linux. macOS is expected to work but I haven't tried it, so if you do, I'd like to know. The repo is at [github.com/mackenziebowes/ctxgrep](https://github.com/mackenziebowes/ctxgrep).

## Two commands

This is the whole thing. Index once, then search. The transcript here is a made-up two-liner in a scratch folder, so no real conversation of mine is in the output:

```
$ ctxgrep index
indexed 2 spans from 1 changed files (1 files seen)

$ ctxgrep juniper
11-10 08:00:30  -  aaaaaaaa:2  assistant  The [juniper]-session cookie was renamed in 4.2, so the old name no longer matches.
11-10 08:00:00  -  aaaaaaaa:1  user  why did the checkout page return a 500 after the [juniper] upgrade?
```

Each line is local time, the agent name (`-` if the session doesn't record one), session and turn, who said it, and the text with the match in brackets. Newest first, because the thing you want is usually the recent one.

There's a time band too. `--since` and `--until` cut the search to a window, `-E` is regex, `-C` gives context lines, `-i` ignores case and `-l` just lists the sessions. So "regex over a time band" is a thing you can do, which was the filter I actually wanted.

## How it got built

On the 18th I got tired of the search tool I was using. Indexing burned GPU and RAM, searching burned GPU and RAM, and it kept each agent's traces in its own silo, so my memory of a project was kinda... per agent. That's a feeling, not a benchmark - I never measured it.

So I gave Harbor, one of my Claudes, a new project. Harbor filed five tickets, took a backup of the transcripts first, then wrote the indexer. The first name was `trace`, with four commands. I told Harbor the name kinda just sucks, and the whole issue we were fixing is that Claudes can't design good experiences for Claudes. Harbor listed names. Gemini suggested `ctxgrep` and I liked it a lot, so that's the name.

Harbor then listed what its own first draft was missing: no tool filter, no project-folder filter, no "before this time", no regex, no context lines. I said add the gaps, skip the trigram index, and that `--since` on its own isn't good enough - I want a matching "before this time" so we get regex over a time band. That's where `--until`, `-E`, `-C`, `-i` and `-l` came from.

This morning I told Harbor to use ctxgrep to find out why we made HubTel in the first place, which is exactly the kind of question I used to answer by scrolling.

Then this afternoon I did a release pass for two friends who use Claude Code, and an agent walked a cold install from scratch. Two things broke. Searching a word with punctuation in it crashed with `no such column: walk`. The fix quotes punctuated words as phrases, and then a second fix made sure `"a b"` still counts as two words. The other one: the first `ctxgrep index` sat there for more than ten silent minutes, so it now prints a progress line every 250 files. My own first index took longer than ten minutes on my 27 GB of transcripts and was still going. Yours is probably smaller. The same pass added a README, an INSTALL.md and `ctxgrep doctor`.

Things to know before you run it. The index holds a copy of your conversation text, so treat `~/.local/share/ctxgrep/ctxgrep.db` as private. Claude's "thinking" is not indexed. And run `ctxgrep index` before you search, or you're searching nothing.

## Get it

The easy way is to ask your Claude Code:

```
Install ctxgrep from https://github.com/mackenziebowes/ctxgrep by following its INSTALL.md.
```

By hand, it's a clone and a cargo install. You need Rust and a C compiler:

```
git clone https://github.com/mackenziebowes/ctxgrep.git
cargo --version
cc --version
cargo install --path <REPO> --root <PREFIX> --locked
ctxgrep index
```

Then grep your own past. If you're searching your Claude Code transcripts too, or you can tell me whether it builds on a Mac, I'd like to compare notes: mackenzie@mackenziebowes.com, or @_mackenziebowes on [X](https://x.com/_mackenziebowes).

---

Published 2026-11-22. Web page: https://www.mackenziebowes.com/posts/ctxgrep
