# Claude Code vs Codex CLI session logs

> How Claude Code and Codex CLI differ in where they store sessions, file format, retention, compression, resume commands and training defaults - side by side.

Source: https://groundedby.com/guides/claude-code-vs-codex-session-logs (updated 2026-10-29)

The two most used terminal agents both keep sessions as JSONL files on your machine. The details differ in ways that matter if you want to keep, measure or share them.

## Side by side

| | Claude Code | Codex CLI |
| --- | --- | --- |
| Folder | `~/.claude/projects/<project>/` | `~/.codex/sessions/YYYY/MM/DD/` |
| Organized by | Project (working directory) | Date |
| File | `<session-id>.jsonl` | `rollout-<time>-<id>.jsonl` |
| Old sessions | **Deleted after 30 days** by default | **Compressed** to `.jsonl.zst` |
| Keep longer | `cleanupPeriodDays` in settings.json | Kept by default |
| Resume | `claude --continue`, `claude --resume` | `codex resume`, `codex resume --last` |
| Fork | `--fork-session`, `/branch` | `codex fork` |
| Delete | `claude purge` | `codex delete` |
| Don't save a run | `--no-session-persistence` (with `-p`) | `codex exec --ephemeral` |
| Moves with | `CLAUDE_CONFIG_DIR` | `CODEX_HOME` |
| Prompt history | `~/.claude/history.jsonl` | `history.jsonl`, set by `history.persistence` |
| Index | None; files only | SQLite `state_*.sqlite` and `session_index.jsonl` |

## The difference that bites: retention

Claude Code removes sessions older than 30 days unless you raise `cleanupPeriodDays`. Codex keeps everything and compresses what is old. If you use both, your Codex history probably goes back further than your Claude Code history, even if you used Claude Code more.

```json
{ "cleanupPeriodDays": 365 }
```

## The difference that bites tools: compression

Tools that only look for `.jsonl` files miss Codex's compressed sessions. ccusage and the groundedby [evaluator](/evaluate) read both.

## Training defaults

- **Claude Code** on Free, Pro and Max plans may be used for training unless you opt out. Team, Enterprise and API use are excluded.
- **Codex** on personal ChatGPT plans follows the "Improve the model for everyone" setting. Business, Enterprise and Edu are not used by default.

[What the terms say](/blog/ai-terms-of-service-and-your-sessions).

## Details

[Claude Code storage](/agents/claude-code) · [Codex storage](/agents/codex) · [What is inside a session file](/guides/whats-inside-an-agent-session-file)

## Sources

- [Claude Code docs, sessions](https://code.claude.com/docs/en/sessions)
- [OpenAI Codex docs, developer commands](https://learn.chatgpt.com/docs/developer-commands?surface=cli)
- [openai/codex source, rollout storage](https://github.com/openai/codex/tree/main/codex-rs/rollout/src)
