Search your past Claude Code conversations: grep, ccgrep and MCP tools compared
Published · Updated · Checked against Claude Code 2.1.319
grep -l over ~/.claude/projects/, then jq on the file it names. That is the fastest way to search old Claude Code conversations. Tools like ccgrep wrap the same idea with nicer output, and none of them can find a session Claude Code has already deleted.
Why /resume is not enough
The /resume picker lists sessions for the current project and filters as you type. The sessions docs say each row shows the session name, an AI-generated title, a summary or the first prompt, plus age, branch and size. That suits picking a session you remember. The docs do not describe full-text search over message bodies, and none is confirmed.
It also shows only sessions Claude Code can find. In issue 9898, a user on Claude Code 2.0.22 reported conversations vanishing from /resume while their files were still in ~/.claude/projects/, with history tied to the absolute project path. The stale bot closed it as not planned in January 2026. The files on disk are the source of truth, so search them directly.
Where the text lives
There is one JSONL file per session, ~/.claude/projects/<project>/<session-id>.jsonl, and subagent transcripts sit in <session-id>/subagents/; see where Claude Code stores sessions. ~/.claude/history.jsonl holds only the prompts you typed, with timestamp and project path (claude-directory page). It finds a prompt quickly but has no assistant replies and no tool output.
grep
# which sessions mention it, newest first
grep -rl --include='*.jsonl' 'ECONNRESET' ~/.claude/projects | xargs ls -t | head
# only this project
grep -l 'ECONNRESET' ~/.claude/projects/-Users-me-myapp/*.jsonl
It is fast and needs nothing installed. It has three real weaknesses. JSON escapes text, so a newline in the original is \n in the file and a quote is \", and multi-word searches that span lines will miss. It matches everything: your prompts, assistant text, tool inputs, tool results, and the system prompt and tool definitions Claude Code records with requests (docs), so a hit says the string is in the file, not who said it. And output lines can be megabytes long, so use -l or -o with a bounded pattern rather than bare grep.
grep to find, jq to read
Narrow by speaker with jq. Prompts you typed are user entries whose message.content is a plain string; assistant text is in message.content[] items of type text:
f=~/.claude/projects/-Users-me-myapp/<session-id>.jsonl
# what you asked
jq -r 'select(.type=="user") | .message.content | strings' "$f"
# what Claude answered
jq -r 'select(.type=="assistant") | .message.content[]? | select(.type=="text") | .text' "$f"
To search one speaker across a time window:
find ~/.claude/projects -name '*.jsonl' -mtime -30 -print0 |
xargs -0 jq -r 'select(.type=="user") | input_filename as $f |
.message.content | strings | select(test("retry";"i")) | "\($f | split("/")[-1][0:8]) \(.[0:100])"'
The [0:8] prefix is the start of the session id, which claude --resume accepts. The docs warn that the entry format is internal and changes between versions, so a script that works on 2.1.319 may need edits later.
For a command Claude ran rather than a phrase, see find the command Claude Code ran last week.
ccgrep
ccgrep calls itself "a grep for Claude Code and Codex conversation history". PyPI lists one release, 0.1.0, uploaded 22 Feb 2026, pure Python with no dependencies; the source is at github.com/499602D2/ccgrep. Install with uv tool install ccgrep, pipx install ccgrep or pip install ccgrep.
It detects the project from your working directory and takes a regex:
ccgrep search -i 'todo|fixme' # case-insensitive, current project
ccgrep search -t user 'deploy' # only your messages
ccgrep -a search 'ECONNRESET' # all projects
ccgrep search -l 'auth' | ccgrep dump - # dump the matching sessions
ccgrep search -j 'pattern' | jq . # JSON output
It also has list, projects, stats, tail and dump, and it searches Codex history with --source codex. It scans files and builds no index.
claude-historian-mcp
claude-historian-mcp (MIT) is an MCP server, not a command line tool. You add it with claude mcp add claude-historian-mcp -- npx claude-historian-mcp and Claude calls it. Its README lists a search tool with scopes such as conversations, files, errors, plans and tasks, and an inspect tool for one session, and says it keeps "zero persistent storage or indexing", scanning local JSONL on each query. The README page gives no current version number.
The appeal is that Claude searches your history for you mid-session. The cost is that every search is a model-driven tool call.
Side by side
| grep + jq | ccgrep | claude-historian-mcp | |
|---|---|---|---|
| Interface | Shell | Shell | Tool calls from Claude |
| Install | None | pip/uv/pipx | npx via claude mcp add |
| Filter by speaker | With jq | -t user | Via the tool |
| Index | None | None | None |
| Codex history | Different paths and format | Yes | Claude Code only, per its README |
| Survives deleted sessions | No | No | No |
The last row is the shared limit. Every tool above reads ~/.claude/projects/, and Claude Code removes transcripts after cleanupPeriodDays, 30 days by default, so a search for something from two months ago finds nothing if you never copied the files. See Claude Code silently deletes transcripts after 30 days. The grep and jq commands were run on real transcripts with Claude Code 2.1.319. The ccgrep and claude-historian-mcp READMEs were read on 10 Nov 2026 without running either tool.
Searching copies instead
Sealkeep keeps copies and then searches them: it seals each session's raw bytes into an encrypted archive, so old sessions stay searchable after the originals are gone. sealkeep search <query> searches metadata, sealkeep search <query> --content searches inside sessions once sealkeep index build has run, and sealkeep mcp install lets Claude Code and Codex call that search themselves.
It is not a lighter grep. It needs setup, a vault and a recovery phrase, so for recent local history grep or ccgrep is simpler. It covers Claude Code and Codex only.
FAQ
How do I search Claude Code history for a phrase?
Run grep -rl --include='*.jsonl' 'phrase' ~/.claude/projects to list files, then read the match with jq. Or use ccgrep search 'phrase'.
Why can't I find a conversation from two months ago?
Most likely Claude Code deleted it. The default retention is 30 days, set by cleanupPeriodDays in settings.json. Check ls ~/.claude/projects/<project>/ for old dates before assuming the search is broken.
Is the JSONL format stable enough to script against?
No promise. The sessions docs say the entry format is internal and changes between versions, so keep scripts small and re-test after upgrades.
All guides are at /guides/.