The Deska blog

Finding That One Prompt: Searching Claude Code's Request History

Master Claude Code history search: find old prompts, recover AI outputs and search session transcripts with jq, grep and better workflows.

· 8 min read

You remember the answer was good. You do not remember which session produced it, which project you were in, or what you even asked. If that sounds familiar, this guide to Claude Code history search is for you. Claude Code keeps a complete record of your sessions on disk, and once you know where that record lives and how to query it, recovering a specific prompt or AI output takes seconds instead of an hour of scrolling. Below you will find where the transcripts are stored, how to search them with everyday terminal tools, which built in commands help, and how to set up your workflow so the next search is even faster.

Where Claude Code Stores Your History

Claude Code is local first by design: your conversation history lives on your own machine, not in a web dashboard. On macOS and Linux the main location is the ~/.claude/projects directory. Inside it you will find one folder per project, named after the absolute path of the working directory with slashes replaced by dashes. A project at /Users/ana/work/api-server becomes a folder named something like -Users-ana-work-api-server.

Each project folder contains session transcripts as JSONL files, one file per session, named with the session UUID. JSONL means JSON Lines: every line is a self contained JSON object representing one event, such as a user message, an assistant reply, a tool call, or a tool result.

Key facts worth remembering:

  • Transcripts are plain text JSONL, so any text tool can read them.
  • Each line typically has a type field (user, assistant, summary), a message object with content, a timestamp, and a sessionId.
  • The first lines of a file often include a summary line that compresses what the session was about.
  • Sessions are grouped by project directory, so knowing which repo you were in already narrows the search dramatically.
  • Deleting the ~/.claude/projects folder deletes your history, so treat it as data worth backing up if you rely on it.

Because everything is local and structured, Claude Code history search is really a structured text search problem, and structured text is exactly what Unix tools were built for.

Finding the Right Session File

Before you search inside transcripts, narrow down which files could contain the answer. Two filters do most of the work: project directory and modification time.

List your most recently active project folders:

ls -lt ~/.claude/projects | head -20

Then, inside the likely project folder, list sessions by date:

ls -lt ~/.claude/projects/-Users-ana-work-api-server/*.jsonl | head

If you remember a distinctive word from the prompt or the answer, skip straight to content search. grep -l prints only the filenames of sessions that contain a match:

grep -l "rate limit" ~/.claude/projects/-Users-ana-work-api-server/*.jsonl

For a cross project search, recurse over everything and let ripgrep do the heavy lifting:

rg -l "refresh token rotation" ~/.claude/projects/

One practical warning: a single session can contain thousands of lines, and one JSONL line can be very long. Always use -l first to find candidate files. Only print matching lines once you know the file is the right one, and prefer jq for that step so the output stays readable.

Searching Inside a Session with jq

Raw JSONL is dense. The jq tool turns it into a readable conversation. Install it with your package manager (brew install jq on macOS) and these patterns cover most recovery jobs.

Extract only your own prompts from a session:

jq -r 'select(.type == "user") | .message.content' session.jsonl

Extract only the assistant's text replies:

jq -r 'select(.type == "assistant") | .message.content[] | select(.type == "text") | .text' session.jsonl

Find the lines where a keyword appears and show a timestamp with them:

jq -r 'select((.message.content | tostring) | test("migration"; "i")) | [.timestamp, .type] | @tsv' session.jsonl

Chain the two ideas to answer the most common question of all: what did Claude actually tell me about X?

jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "text") | .text' session.jsonl | grep -i -A 5 -B 5 "migration"

A few field notes that save frustration:

  • message.content can be a string or an array of content blocks, which is why the []? and select(.type == "text") filters appear in the examples. The question mark makes jq skip lines where the field is missing instead of failing.
  • Tool calls and tool results live in separate content blocks, so if you are hunting for a command Claude ran or a file it wrote, search the whole line with tostring rather than only the text blocks.
  • Timestamps are ISO 8601 strings, so sorting or filtering by date is straightforward string comparison.

If you recover outputs often, save your favorite incantations as shell aliases or small scripts. Treat them like any other piece of developer tooling.

Built in Commands: /resume and Friends

Terminal surgery is powerful, but Claude Code also ships with session recovery built in. Running claude --resume (or /resume inside an active session) presents a list of past sessions for the current project, with summaries, and lets you pick up where you left off. claude --continue jumps straight back into the most recent session in the current directory.

These commands are the fastest path when you know the session you want and simply need to reopen it. They are less helpful when you do not know which session holds the answer, because the picker shows one project at a time and relies on short summaries. That is the gap where the jq and grep techniques above shine, and where a workspace level view of all your agents becomes valuable.

Comparing Your Search Options

MethodBest forEffort
/resume pickerReopening a known sessionLow
grep or rgKeyword known, session unknownLow
jq queriesExtracting full prompts or repliesMedium
Workspace searchMany agents, many projects at onceLow

The first three are free, scriptable and completely offline. The fourth is what tools like Deska add on top.

Searching History When You Run Several Agents

Everything above works well for one agent in one project at a time. The picture changes when your daily workflow involves Claude Code, Codex CLI and OpenCode running in parallel across multiple repositories, which is increasingly common. Now the question is not just which session, but which agent, in which project, on which day.

This is the problem Deska is built around. Deska is a free desktop app for Mac, Windows and Linux that gives you an infinite canvas where terminals, code editors, browsers and notes live side by side as panels, and where AI coding agents like Claude Code, Codex CLI and OpenCode run as panels you can see all at once, as described on the agents overview. Because sessions live as visible threads in one workspace, finding a past conversation is a matter of zooming out and scanning, not reconstructing paths under ~/.claude. The agent threads documentation covers how those threads are organized, and the command palette gives you a single keyboard driven entry point to jump to panels and sessions without remembering folder names.

Two Deska traits matter specifically for history recovery:

  • It is local first: sessions and files stay on your machine, so searching your history never depends on a network round trip or a vendor dashboard.
  • The mobile app lets you monitor and continue sessions from your phone through a secure relay with direct device pairing, which means the prompt you wrote at your desk is reachable when you are away from it.

None of this replaces knowing the raw file layout. If you run Claude Code inside Deska, the transcripts are still ordinary local data, and the jq techniques from earlier still apply. The difference is that you rarely need them, because the session list and the workspace view answer most recovery questions visually. If you want the setup details, the getting started guide and the coding agents documentation walk through connecting your own API keys or managed inference.

Make Your Future Self's Searches Easier

The best history search is the one you barely have to run. A few habits dramatically improve your hit rate months later:

  • Start prompts with a specific noun phrase. Asking "add retry logic to the stripe webhook handler" is findable; "can you fix this" is not.
  • Keep one project per directory. Since sessions group by working directory, disciplined directory hygiene is free search indexing.
  • Ask Claude to summarize decisions at the end of long sessions. Those summaries are easy to spot at the top of transcripts and in the resume picker.
  • Rename or note important sessions in a scratch file or a notes panel, with the session UUID and a one line description.
  • Back up ~/.claude along with your dotfiles. History you lose cannot be searched.

For general hygiene around what Claude Code stores and how to manage it, the troubleshooting guide and the data and storage notes in the Deska docs are useful references even if you do not use Deska itself, since the underlying agent behavior is the same.

FAQ

How do I find an old Claude Code conversation?

Run claude --resume in the project directory to browse past sessions with summaries. If you do not know the project, search the transcripts directly with rg -l "keyword" ~/.claude/projects/ to list every session file that mentions your keyword, then open the matching file with jq to read the conversation.

Where does Claude Code store chat history?

In ~/.claude/projects on macOS and Linux. Each working directory gets its own folder named after its path, and each session is a JSONL file named with a UUID inside that folder. Every line of the file is one event, such as a user message or an assistant reply, with timestamps and session identifiers.

Can I search Claude Code history from my phone?

Not natively, since transcripts live on your workstation. A remote access setup solves it: Deska's mobile app pairs directly with your desktop through a secure relay, with no ports exposed, so you can monitor running agents and continue past sessions from your phone while the data itself stays on your machine.

Stop Losing Good Answers

Claude Code history search boils down to three moves: know that transcripts live in ~/.claude/projects, use rg to find the right file and jq to read it, and use /resume when you already know the session. Master those, and no good answer stays lost for long. If you would rather search visually across Claude Code, Codex CLI and OpenCode in one local first workspace, download Deska for free and keep every session in sight.

💡 Ideas+🐛 BugsSuggest a feature or report a bug