Shabash
Blog · Claude Code guides

How do I search my Claude Code history?

Short answer

Ctrl+R searches every prompt you've typed in the terminal, and claude --resume lists your sessions by title. To search inside conversations, run ripgrep over ~/.claude/projects. By default Claude Code deletes conversations after 30 days, so raise cleanupPeriodDays first.

By Robin Mehta · September 25, 2026

Claude Code has kept every prompt I've typed in the terminal since January. But it deletes the conversations themselves after a month.

Two of my prompts that mention "stripe webhook" are from March. Both of their conversations are gone.

Claude Code can search your session titles and your prompts. Searching the words inside a conversation takes one command in your terminal, and keeping conversations past 30 days takes one setting.

claude --resume and the session list

claude --resume

This opens a list of the sessions in the folder you're in. Each row shows the name you gave the session. Without one, it shows the title Claude Code wrote from your first prompt, a summary, or the prompt itself.

Start typing to filter the list. These keys change what's in it:

If you remember a session's exact name or title, claude --resume <name> opens it straight away, as long as it's from the repo you're in. If more than one session has that name, you get the list with the name already typed in.

Picking a session from a different project copies a cd and resume command to your clipboard, because Claude Code works in the folder you start it from. Paste it and you're back in. If that project's folder no longer exists, it opens the session right where you are.

For the session behind a pull request, run claude --from-pr 1234 or paste the pull request's URL into the search. Pasting works with GitHub, GitLab and Bitbucket links.

To find a word from the middle of a conversation, search the files themselves with ripgrep, below.

Ctrl+R for every prompt you've typed

Inside a session, press Ctrl+R and type. It searches the prompts you've typed, newest first, like reverse search in your shell. Claude's replies aren't in it.

The keys depend on which screen mode you're in. Run /tui to see which one you have.

These prompts live in ~/.claude/history.jsonl, and the 30-day cleanup never touches that file. That's why mine go back to January: about 18,500 prompts, plus the commands I typed, like /clear.

Session IDs for old prompts

Ctrl+R hands you back the prompt, not the session it came from. But history.jsonl also saves each prompt's session ID and project folder, so a short function can turn them into the command that reopens the session.

  1. Paste this at the end of ~/.zshrc:

    ccprompts() {
      python3 - "$*" <<'EOF'
    import json, sys, os, datetime
    term = sys.argv[1].lower()
    for line in open(os.path.expanduser("~/.claude/history.jsonl")):
        d = json.loads(line)
        if term in d.get("display", "").lower() and d.get("sessionId"):
            day = datetime.datetime.fromtimestamp(d["timestamp"] / 1000).strftime("%Y-%m-%d")
            print(day, d["display"][:60].replace("\n", " "))
            print(f"  cd '{d.get('project', '.')}' && claude --resume {d['sessionId']}")
    EOF
    }
  2. Open a new terminal window.
  3. Search your prompts:

    ccprompts stripe webhook

    Each matching prompt prints with its date, oldest first, and under it the command that reopens its session.

  4. Copy that command and run it. It moves into the session's project folder first, so Claude picks up where it was working.

If it says No conversation found with session ID, the conversation is most likely more than 30 days old, and Claude Code has deleted it. That's what happened to my two from March. The prompt is all that's left.

ripgrep over every transcript

Every conversation is a plain text file at ~/.claude/projects/<project>/<session-id>.jsonl. Claude Code has no search for them, but any search tool can read them.

Mine add up to over 7 GB, and ripgrep searches all of them in about five seconds. Plain grep can't even start: there are so many files that grep -il "stripe webhook" ~/.claude/projects//.jsonl fails on my Mac with "argument list too long".

  1. Install ripgrep:

    brew install ripgrep
  2. Paste this at the end of ~/.zshrc:

    ccfind() {
      rg -il --max-depth 2 --sortr modified -g "*.jsonl" -- "$*" ~/.claude/projects | head -20 |
        while read -r f; do
          dir=$(rg -m1 -o --no-filename '"cwd":"[^"]*"' "$f" | cut -d'"' -f4)
          echo "cd '$dir' && claude --resume $(basename "$f" .jsonl)"
        done
    }
  3. Open a new terminal window.
  4. Search every transcript:

    ccfind stripe webhook

    It prints up to 20 sessions that mention "stripe webhook", newest first, each as the command that reopens it.

  5. Copy a line and run it.

To keep what you found, type /export notes.txt once it's open: more on how to export a Claude Code conversation, including to Markdown.

Sessions that ran in the cloud on claude.ai/code aren't on your Mac, so ccfind can't see those. It will also list sessions where the words only showed up in a file Claude read or in a command's output.

cleanupPeriodDays: keep conversations for a year

Searching only helps if the conversation still exists. So set Claude Code to keep them longer. Add this to ~/.claude/settings.json:

{ "cleanupPeriodDays": 365 }

It doesn't bring back anything already deleted, so do it before you need it. More on keeping sessions longer.

The 30-day cleanup is also why Shabash, the Mac app I'm building, keeps its own copy of the sessions you typed in, from the day you install it. Reopening one from Shabash brings it back, as long as its project folder is still there. It can't save sessions the cleanup deleted before then.

Questions

Can I search old Claude Code conversations?

Yes. claude --resume opens a list of sessions you can filter by typing, and Ctrl+A widens it to every project. To search the words inside every conversation, run ripgrep over ~/.claude/projects.

What does Ctrl+R search in Claude Code?

Every prompt you've typed in the terminal, newest first. The classic search covers every project. The fullscreen search lets you switch between this session, this project and all projects with Ctrl+S. It doesn't search Claude's replies. Inside the session list, Ctrl+R renames the highlighted session instead.

How do I find the session that created a pull request?

Run claude --from-pr 1234, or paste the pull request's URL into the search in claude --resume. It finds the sessions linked to that pull request, such as the one that created it.

Why can't I find a Claude Code conversation from two months ago?

Claude Code deletes conversations after 30 days by default, except ones you started or last continued in Claude Desktop or Cowork. The prompts you typed stay in ~/.claude/history.jsonl. Set cleanupPeriodDays higher to keep conversations longer.