Codex Session Browser
Use the bundled parser instead of hand-grepping raw JSONL.
Preferred entrypoint:
python3 scripts/codex_sessions.py list --repo /abs/repo/pathpython3 scripts/codex_sessions.py messages --repo /abs/repo/path --limit-sessions 3 --tail 10
What this skill knows
- Codex sessions live under
~/.codex/sessions/YYYY/MM/DD/*.jsonl. - The repo or worktree is recorded in
session_meta.payload.cwdnear the top of each file. - Plain conversation text is easiest to extract from
event_msgrecords: user_message-> user prompt textagent_message-> assistant text output, withphasesuch ascommentaryorfinal_answer- Tool calls and tool outputs live in other record types such as
response_itemwithfunction_call,function_call_output, orcustom_tool_call; ignore them unless the user explicitly asks for tool traces. - Some sessions may not have
event_msgconversation entries. In that case the parser falls back toresponse_itemrecords whose payload is a plainmessagefromuserorassistant.
Workflow
- Identify the target repo or session.
- For one repo/worktree, use
--repo /absolute/pathfor exactcwdmatching. - If the exact path is unknown, use
--cwd-contains partial-namefirst. - If the user already knows a session id or filename fragment, use
messages --session <id-or-path>.
- List candidate sessions first.
- Run
python3 scripts/codex_sessions.py list --repo /abs/repo/path --limit 10 - This shows session timestamp, file path, repo
cwd, message count, and short previews of the last user and assistant text.
- Extract plain conversation text.
- Run
python3 scripts/codex_sessions.py messages --repo /abs/repo/path --limit-sessions 1 --tail 8 - This prints only user/assistant text messages, not tool calls.
- Increase
--limit-sessionsto inspect multiple recent sessions. - Use
--tail 0to print the full text conversation for each matched session.
- Narrow the assistant output when needed.
- Use
--assistant-phase final_answerwhen the user wants only final answers. - Use
--assistant-phase commentarywhen the user wants progress updates instead. - Use
--role useror--role assistantto isolate one side.
- Use JSON output when another script or agent will consume the result.
python3 scripts/codex_sessions.py list --repo /abs/repo/path --jsonpython3 scripts/codex_sessions.py messages --repo /abs/repo/path --limit-sessions 3 --tail 12 --json
Examples
Find the latest forgedemy Codex sessions:
python3 scripts/codex_sessions.py list \
--repo /home/latand/Projects/forgedemy \
--limit 5Pull the last few prompts and replies for that repo, without tool calls:
python3 scripts/codex_sessions.py messages \
--repo /home/latand/Projects/forgedemy \
--limit-sessions 2 \
--tail 8Only show final assistant answers from the latest matched session:
python3 scripts/codex_sessions.py messages \
--repo /home/latand/Projects/forgedemy \
--assistant-phase final_answer \
--tail 4Inspect one exact session by filename fragment:
python3 scripts/codex_sessions.py messages \
--session 019cf134-ec89-77d3-a78f-1710bc2a8c03 \
--tail 0Reporting back
When summarizing results for the user, include:
- the matched repo path or session id
- the session timestamp
- the last relevant user prompt(s)
- the assistant reply text the user actually cares about
- a note that tool calls were excluded unless the user asked for them