# Codex Session History

> Search locally saved Codex session history stored in SQLite and session_index.jsonl, with filters for provider, time range, and archived status.

- Skill: `zero-yx/codex-session-history` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add zero-yx/codex-session-history`
- Raw SKILL.md: https://api.skillmd.com/api/skills/zero-yx/codex-session-history/raw
- Safety review: CAUTION (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools, Productivity, Dev Tooling
- Tags: Cli, Codex, Search, Session History, Sqlite
- Author: zero-yx (https://skillmd.com/u/zero-yx)
- Updated: 2026-08-22
- Page: https://skillmd.com/skills/zero-yx/codex-session-history

---


# Codex Session History

Use the bundled CLI to inspect local Codex session history. The script reads:

- `state_*.sqlite` for persisted thread metadata
- `session_index.jsonl` for the latest user-facing thread names

The script auto-discovers the newest state database under `CODEX_SQLITE_HOME`, the configured `sqlite_home`, or `~/.codex`.

## Primary Command

Run:

```bash
python3 scripts/codex_session_history.py --limit 30
```

The default `cards` view shows:

- full `session_id`
- provider and source
- created and updated timestamps
- thread name, title, and preview
- cwd
- a ready-to-run `codex resume <session_id>` command

## Common Queries

Search by preview, title, id, provider, cwd, or thread name:

```bash
python3 scripts/codex_session_history.py --query "resume provider"
```

Show the newest sessions in a compact table:

```bash
python3 scripts/codex_session_history.py --view table --limit 50
```

Filter by provider:

```bash
python3 scripts/codex_session_history.py --provider openai --provider staticflow
```

Filter by time:

```bash
python3 scripts/codex_session_history.py --since 7d
python3 scripts/codex_session_history.py --sort-by created --since 2026-03-01 --until 2026-03-10
```

Include archived-only sessions:

```bash
python3 scripts/codex_session_history.py --archived only
```

Emit JSON for piping or ad hoc analysis:

```bash
python3 scripts/codex_session_history.py --view json --limit 200
```

## Time Filters

`--since` and `--until` accept:

- ISO timestamps like `2026-03-23T15:30:00`
- dates like `2026-03-23`
- epoch seconds
- relative values like `30m`, `12h`, `7d`, `2w`
- `today`, `yesterday`, `now`

## Notes

- `preview` is the stored first user message, not a generated conversation summary.
- `thread_name` comes from `session_index.jsonl` and may be missing.
- If the user wants to continue a session after locating it, run `codex resume <session_id>`.
- If auto-discovery fails, pass `--db /path/to/state_5.sqlite` or `--codex-home /path/to/.codex`.

