← Blog
Agents

How to save Claude Code and Codex session logs before they disappear

Claude Code deletes local transcripts after 30 days by default, and Codex rollouts live in one folder on one laptop. Where both store sessions, how to keep and search them, and how to attach each session to the issue it worked on.

Radial6 min read

Claude Code saves every session as a JSONL file under ~/.claude/projects/<project>/ and deletes those files after 30 days by default. Codex saves every session as a JSONL rollout under ~/.codex/sessions/YYYY/MM/DD/. To keep them, raise Claude Code's cleanupPeriodDays in ~/.claude/settings.json, back up both folders, and for the sessions that matter, attach the transcript to the issue it worked on, so the record outlives the laptop and your team can read it. Radial does that last step with a hook: each turn is redacted on your machine and appended to the issue's build record.

The rest of this post is the how, in that order.

#Where the logs are

AgentLocationFormat
Claude Code~/.claude/projects/<encoded-project-path>/<session-id>.jsonlOne JSON object per line: messages, tool calls, tool results
Codex CLI~/.codex/sessions/YYYY/MM/DD/rollout-<timestamp>-<id>.jsonlOne JSON object per line, starting with a session_meta line

If you set CLAUDE_CONFIG_DIR or CODEX_HOME, look there instead. Both agents also keep a separate history.jsonl of typed prompts. That is not the transcript.

#Stop Claude Code from deleting them

Claude Code cleans up transcripts older than cleanupPeriodDays at startup. The default is 30. Set it higher in ~/.claude/settings.json:

json
{
  "cleanupPeriodDays": 365
}

Run /status in a session to confirm the setting loaded. If your company manages Claude Code settings centrally, its value wins over yours.

Codex sessions are not covered by that setting. Wherever they live, they live on one disk.

#Back them up

Copy both folders somewhere that is not your laptop, on a schedule:

bash
rsync -a ~/.claude/projects/ ~/Backups/claude-sessions/
rsync -a ~/.codex/sessions/  ~/Backups/codex-sessions/

Or point restic, Borg or Time Machine at them. One warning: transcripts contain everything the agent saw, including any secret it read from a .env file or printed from a command. Treat a backup of them like a backup of your shell history, not like a backup of your notes.

#Search them

The files are plain JSONL, so rg and jq work:

bash
rg -l "ECONNRESET" ~/.claude/projects/ ~/.codex/sessions/
codex resume --all          # Codex's own picker, across projects
claude --resume             # Claude Code's picker for this project

This finds a session. It does not tell you which piece of work the session was for, which is the question you usually have three weeks later.

#Keep each session with the issue it worked on

A local log answers "what did the agent do on my machine". The useful question is "what happened on RAD-219", asked by someone who was not at your machine. That needs the session attached to the issue, in a place the whole team can open.

In Radial, install the hook once per machine:

bash
npm i -g radial.build && radial auth
radial build hook install --client claude     # a Stop hook
radial build hook install --client codex      # a notify entry

From then on, when an agent works an issue (radial build start RAD-219, which the rd-* skills run for you), the hook reads what is new in the transcript at the end of every turn, redacts it, and appends it to that issue's build. Redaction covers API keys, OAuth tokens, bearer headers, JWTs, connection strings, private-key blocks and NAME=value secrets, and runs twice: on your machine before anything is written, and on the server before anything is stored.

What you get on the issue is a Session tab: every session that touched the issue, Claude Code and Codex side by side, stitched into one timeline with tool calls folded. Next to it, Timeline shows the stages and time spent, and Gates shows each check with its evidence. The full model is in the builds docs.

Three details that matter for keeping logs:

  • The local journal lives outside the repo, in ~/.config/radial/builds/<workspace>/<ISSUE>/, so deleting a worktree does not take the build with it. It works offline; radial build sync catches up later.
  • The raw file is opt-in. radial build finish --with-raw uploads the raw session, gzipped and redacted, downloadable by the person whose session it was or a workspace admin.
  • You can capture after the fact. For a session that ran without the hook, radial build capture --transcript <path> attaches it.

Read it back from anywhere: the Session tab on the issue, radial build search RAD-219 "ECONNRESET" from a terminal, radial build export RAD-219 --events for the timeline as data, or the search_build_events MCP tool from another agent.

#Why the cloud copy matters

A transcript on one laptop helps one person. A transcript on the issue helps the reviewer deciding whether to merge, the teammate picking up the work tomorrow, and the next agent that reads the issue before it starts. That is the same reason several agents on one repo need a shared tracker rather than a shared folder.

If your agents also produce HTML mockups along the way, the same issue can hold them too: see how to share coding-agent HTML prototypes. And if you are wiring all of this into a repeatable pipeline, that is what people mean by a software factory.

#FAQ

#Where does Claude Code store session logs?

In ~/.claude/projects/<encoded-project-path>/<session-id>.jsonl, one file per session, unless you set CLAUDE_CONFIG_DIR. Each line is one JSON event: a message, a tool call or a tool result.

#Does Claude Code delete old sessions?

Yes. At startup it deletes transcripts older than cleanupPeriodDays, which defaults to 30 days. Set a larger value in ~/.claude/settings.json to keep them longer, and back them up if they matter.

#Where are Codex CLI session transcripts stored?

In ~/.codex/sessions/YYYY/MM/DD/ as rollout-*.jsonl files, or under $CODEX_HOME/sessions/ if you set it. codex resume --all lists them across projects.

#How do I share a Claude Code session with my team?

Attach it to the issue it worked on. With Radial's hook installed (radial build hook install --client claude), each turn is redacted and appended to the issue's build, and anyone in the workspace reads it in the issue's Session tab. Without a tracker, /export in Claude Code writes the conversation to a text file you can send.

#How do I attach an agent transcript to a pull request?

Attach it to the issue the pull request closes, then link the issue in the pull request. The issue is the stable place: a pull request can be closed and reopened as another, but the issue, its build record and its session stay together.

#Are secrets in the transcript uploaded?

Radial redacts known secret shapes (API keys, tokens, JWTs, connection strings, private keys, NAME=value secrets) on your machine before writing and again on the server before storing. The raw session file is only uploaded if you pass --with-raw.

RadialAn issue tracker. That’s it.

The team behind Radial, the fast, CLI-first issue tracker that lets your own agents work for free. We write about plain software, speed as respect, and bringing your own agent.

Track issues like it’s 2019. Ship like it’s 2026.

An issue tracker. That’s it. Your agents ride free.

Keep reading