Sparkie

Claude Code session history: where it is stored and how to search it

Claude Code session history is the set of JSONL transcript files Claude Code writes to ~/.claude/projects/, one file per conversation, grouped in a folder per project directory.

Where the files are

Each project directory you run claude in gets its own folder under ~/.claude/projects/. The folder name is the absolute path of the project with the slashes replaced by dashes, so /Users/you/code/app becomes a folder named like -Users-you-code-app. Inside it, every session is one <session-id>.jsonl file.

ls ~/.claude/projects/
ls -lt ~/.claude/projects/-Users-you-code-app/ | head

Sorting by modification time (-lt) puts the most recently active conversation first. Each line of a file is one JSON object, usually a user message, an assistant message, or a tool call or result. The format is not a documented interface, so field names can change between Claude Code versions.

Search old conversations with grep and jq

To find which sessions mention a phrase, search the whole folder and list the matching files:

grep -rl "refresh token" ~/.claude/projects/

To read one file as plain text, extract the text of user and assistant messages with jq. Message content is either a string or a list of parts, so the filter handles both:

jq -r 'select(.type=="user" or .type=="assistant")
  | .message.content
  | if type=="string" then . else map(select(.type=="text").text) | join("\n") end' \
  ~/.claude/projects/-Users-you-code-app/<session-id>.jsonl

If a filter prints nothing, open the file with head -c 2000 and check the actual field names in your version. Search results from grep include tool output and file contents the agent read, so expect noise; add the project folder to the path to narrow it.

Resume a session

Claude Code can reopen a past conversation itself:

  • claude --continue resumes the most recent conversation in the current directory.
  • claude --resume opens a picker of past sessions; you can also pass a session id, which is the filename without .jsonl.

Run these from the same project directory the session was created in, because sessions are looked up by the folder described above. If you moved or renamed the project, the folder name no longer matches and the session will not be listed.

Old sessions can disappear

Claude Code deletes local transcripts older than 30 days by default, silently, in a background sweep after a session starts. You can raise the limit with the cleanupPeriodDays setting in ~/.claude/settings.json (for example 3650; 0 is not accepted). If you rely on old conversations as project memory, copy the ~/.claude/projects/ folder somewhere safe, or use a tool that indexes the files into its own database.

Full-text session search in Sparkie

Sparkie is a macOS app that runs Claude Code and Codex in a real terminal. It automatically indexes the Claude Code JSONL sessions in ~/.claude/projects/ into a local SQLite database with full-text search (FTS5, with CJK trigram support), so you can search message content, including tool calls and error output, from a sidebar search box instead of grepping.

  • Sessions are grouped by the project and files they touched.
  • The session viewer shows the full transcript, with tool inputs and outputs inline and collapsible.
  • Typical searches take under 5 ms; very common terms on a 10,000-session, 1M-message test set take roughly 160 ms (English) to 270 ms (CJK) at p95.
  • Codex transcripts are indexed too.
  • Secrets are masked in exports and in MCP search and read results.

Sparkie is free during the macOS beta and needs no account. The history stays on your machine, in ~/.sparkie/.