All articlesGuide

How to Save and Search Claude Code and Cursor Chat History

Where Claude Code and Cursor store chat history, how to keep it past 30 days, search and resume sessions, and link conversations to the commits they made.

The VibeHub Team

The VibeHub Team

VibeHub · October 31, 2026 · 6 min read

How to Save and Search Claude Code and Cursor Chat History

Claude Code saves every session locally as a JSONL transcript at ~/.claude/projects/<project>/<session-id>.jsonl and deletes transcripts older than 30 days by default. To keep them longer, raise cleanupPeriodDays in ~/.claude/settings.json; to find an old one, run claude --resume and type to search the session picker. Cursor keeps agent conversations on your machine and lets you search all of them from the Agents Window with Cmd+K (Ctrl+K on Windows and Linux). Neither tool links a conversation to the git commit it produced, so if you want history that lasts, follows the code, and can be shared with a team, export it or capture it alongside your commits.

Below: exactly where each tool keeps history according to its official docs, how to extend retention and search what you have, the limits of tool-local history, and how to capture sessions so they stay attached to your code.

Where Claude Code stores your chat history

Claude Code’s documentation describes two kinds of history on disk:

  • Session transcripts, at ~/.claude/projects/<project>/<session-id>.jsonl. <project> is your working directory path with every non-alphanumeric character replaced by -. Each line is a JSON object: a message, a tool use or result, a record of a request sent to the model, or metadata.
  • Prompt history, at ~/.claude/history.jsonl: the prompts you typed, with a timestamp and project path. It powers up-arrow recall and Ctrl+R history search, and it is kept until you delete it.

Two caveats from the same docs are worth knowing. First, the transcript format is internal and changes between versions, so scripts that parse these files directly can break on any release; the docs recommend /export or the scripting interfaces instead. Second, transcripts and history are plaintext and not encrypted at rest. Anything that passes through a tool, including file contents and command output, is written to the transcript, so a .env file the agent read ends up there too.

If you set CLAUDE_CONFIG_DIR, all of this moves under that directory instead of ~/.claude.

Keep Claude Code history longer than 30 days

Transcripts, along with the file snapshots used for checkpoint restore, are removed once they are older than cleanupPeriodDays. The default is 30; the minimum is 1, and 0 is rejected as invalid. To keep a year of sessions, set it in your user settings:

// ~/.claude/settings.json
{
  "cleanupPeriodDays": 365
}

Settings files are strict JSON, so leave the comment line out of the real file. Before you raise the number, remember the plaintext caveat: a longer retention window means any secret that passed through a session stays on disk longer. For a project you want to wipe, claude purge <path> deletes its transcripts and related state after showing you the plan; --dry-run previews it.

Find, resume, and export old Claude Code sessions

You rarely need to open the JSONL files yourself. The CLI has a session picker built for this:

  • claude --continue reopens the most recent session in the current directory.
  • claude --resume opens the picker. Start typing to filter sessions, press Space to preview one, and Enter to resume it.
  • In the picker, Ctrl+A widens the list to every project on the machine, Ctrl+W to all worktrees of the repository, and Ctrl+B filters to the current git branch.
  • Paste a pull request URL into the search to find the session that created it, or run claude --from-pr <number>.
  • Name sessions so they are easy to find: claude -n auth-refactor at startup, or /rename auth-refactor during a session. Then claude --resume auth-refactor goes straight back.
  • /export copies the current conversation to your clipboard or saves it as a plain-text file you can keep anywhere.

For a quick full-text search across everything on disk, grep still works. Treat it as an ad hoc tool rather than something to build on, since the format can change:

# which sessions mentioned rate limiting?
grep -l "rate limit" ~/.claude/projects/*/*.jsonl

If you want an automatic archive, Claude Code hooks receive a transcript_path field as input, and the docs suggest a SessionEnd hook as a way to archive the transcript when a session ends. A minimal version copies each finished transcript into a folder you control:

{
  "hooks": {
    "SessionEnd": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "mkdir -p ~/agent-archive && jq -r .transcript_path | xargs -I{} cp {} ~/agent-archive/"
          }
        ]
      }
    ]
  }
}

Cursor: search, resume, and share conversations

In the Cursor app, open the Agents Window and press Cmd+K (Ctrl+K on Windows and Linux) to search across past conversations. Cursor’s help docs say it builds a local search index that scales to thousands of conversations. Inside an open conversation, Cmd+F or Ctrl+F finds text, with a match counter to jump between hits.

If you use Cursor’s CLI, sessions can be listed and resumed from the terminal:

agent ls                       # open previous chats and pick one to resume
agent resume                   # resume the latest conversation
agent --continue               # continue the previous session
agent --resume="chat-id-here"  # resume a specific conversation

To share a conversation, Cursor offers shared transcripts: a read-only link that includes the full conversation, code snippets, tool calls, and results, which recipients can fork into their own editor. Per Cursor’s docs, this is available on Teams (team and public links) and Enterprise (team links by default) but not on Individual or Pro plans, is unavailable with No Storage Privacy Mode, and is limited to 50 shares a day. Redaction of secrets is best-effort, so review a transcript before you share it.

Cursor’s docs do not describe where conversations live on disk or a stable export format, so anything that reads its local storage directly relies on undocumented internals that may change between versions.

The limits of tool-local chat history

Built-in history is great for picking up where you left off. It is weaker as a long-term record of how your code was built:

  • It lives on one machine. A new laptop or a teammate’s checkout starts empty.
  • It expires or depends on local state. Claude Code’s default is 30 days.
  • It is organized by directory and session, not by commit. Finding the conversation behind a particular line of code means guessing dates.
  • Each tool is its own silo. If you use Claude Code in the terminal and Cursor in the editor, the history of one feature is split across two places.
  • It is invisible in code review. The reviewer sees the diff, not the conversation that produced it.

Capture sessions into VibeHub, attached to your commits

VibeHub stores agent transcripts alongside the git commits they produced, so the history follows the code instead of the machine. For Claude Code there is a plugin that captures sessions automatically through hooks:

claude plugin marketplace add aw3-technology/wanderly
claude plugin install vibehub@vibehub
export VIBEHUB_TOKEN=vbh_...   # Settings -> API tokens in the dashboard

Open a new Claude Code session and it appears under Runs in the dashboard. The plugin’s hooks turn SessionStart into a new VibeHub session, record each UserPromptSubmit as a user message and each PostToolUse as a tool message with input and output, store the assistant’s final turn on Stop and subagent turns on SubagentStop, and mark the session ended on SessionEnd. It also adds a /vibehub:capture skill, so you can ask Claude to attach this conversation to the last commit. Capture is fail-open: if the token is missing or the API is unreachable, the hook logs to stderr and never blocks Claude Code.

For Cursor, npx vibehub-cursor install (with VIBEHUB_TOKEN exported) adds the vibehub-mcp server, which shows up under Cursor Settings, MCP, after a restart. Tell the agent to start a VibeHub session for the chat, or add a Cursor rule that calls vibehub_start_session on chat start; the agent then records messages with vibehub_append_message and links them to a commit with vibehub_attach_to_commit.

Once sessions are attached, vb log lists recent commits with their conversation message counts, and vb show <sha> prints a commit’s message, diffstat, and transcript. The vb CLI is free; a transcript-captured commit costs 1 credit. Captured transcripts are encrypted at rest and only returned to you, and private vibes stay private unless you choose to publish them.