Codex Session History
Overview
Use this skill to enumerate local Codex sessions and map each session to its id, title, project, and workspace path.
Prefer the bundled script so the output stays consistent and works even when session_index.jsonl is incomplete.
Workflow
- 1. Run the script to collect unarchived sessions by default.
- Use
session_meta.payload.id as the canonical session id. - Use
session_meta.payload.cwd as the workspace anchor. - Derive the project from the Git root when possible; otherwise fall back to
cwd. - Use
session_index.jsonl only as enrichment for thread_name and updated_at. - Convert stored UTC timestamps into local time before display and time-window filtering.
- If no
thread_name is available, fall back to the first user message summary.
Commands
List recent sessions:
CODEBLOCK0
List active and archived sessions together:
CODEBLOCK1
List more rows:
CODEBLOCK2
Filter by project:
CODEBLOCK3
Filter by a local time window on today's date:
CODEBLOCK4
Filter by a local time window on a specific date:
CODEBLOCK5
Inspect one session id:
CODEBLOCK6
Only show archived sessions:
CODEBLOCK7
Return JSON:
CODEBLOCK8
Output
Default table columns:
- - INLINECODE8
- INLINECODE9
- INLINECODE10
- INLINECODE11
- INLINECODE12
- INLINECODE13
With --details, also show:
- - INLINECODE15
- INLINECODE16
- INLINECODE17
- INLINECODE18
- INLINECODE19
- INLINECODE20
- INLINECODE21
Notes
- - Prefer the script over ad hoc
rg because session_index.jsonl may be incomplete. - Treat the session file itself as the source of truth for
id and cwd. - INLINECODE26 and
updated_at are displayed in local time, not raw Z time. - Time-window filters match actual session events inside the requested interval, not only broad session span coverage.
- If a workspace no longer exists on disk, still report the recorded
cwd. - When the user only asks for "有哪些会话、id 是什么、属于哪个项目", the default table is enough.
Script
Use:
CODEBLOCK9
Codex 会话历史
概述
使用此技能枚举本地 Codex 会话,并将每个会话映射到其 ID、标题、项目和工作区路径。
优先使用捆绑脚本,以便输出保持一致,即使在 session_index.jsonl 不完整的情况下也能正常工作。
工作流程
- 1. 默认情况下,运行脚本以收集未归档的会话。
- 使用 sessionmeta.payload.id 作为规范会话 ID。
- 使用 sessionmeta.payload.cwd 作为工作区锚点。
- 尽可能从 Git 根目录推导项目;否则回退到 cwd。
- 仅将 sessionindex.jsonl 用作 threadname 和 updatedat 的补充信息。
- 在显示和时间窗口过滤之前,将存储的 UTC 时间戳转换为本地时间。
- 如果没有可用的 threadname,则回退到第一条用户消息摘要。
命令
列出最近的会话:
bash
python3 scripts/listcodexsessions.py
同时列出活跃和已归档的会话:
bash
python3 scripts/listcodexsessions.py --source all
列出更多行:
bash
python3 scripts/listcodexsessions.py --limit 50
按项目过滤:
bash
python3 scripts/listcodexsessions.py --project PlayGround
按今天的本地时间窗口过滤:
bash
python3 scripts/listcodexsessions.py --from 11:00 --to 12:00
按特定日期的本地时间窗口过滤:
bash
python3 scripts/listcodexsessions.py --date 2026-03-19 --from 11:00 --to 12:00
检查一个会话 ID:
bash
python3 scripts/listcodexsessions.py --session-id 019ce206-aa11-7c81-a65a-fece3708ecf4 --details
仅显示已归档的会话:
bash
python3 scripts/listcodexsessions.py --source archived
返回 JSON:
bash
python3 scripts/listcodexsessions.py --json
输出
默认表格列:
- - id
- project
- startedat
- updatedat
- source
- title
使用 --details 时,还会显示:
- - matchedfrom
- matchedto
- cwd
- projectpath
- startedat
- sessionfile
- firstuser_message
注意事项
- - 优先使用脚本而非临时 rg,因为 sessionindex.jsonl 可能不完整。
- 将会话文件本身视为 id 和 cwd 的真实来源。
- startedat 和 updated_at 以本地时间显示,而非原始 Z 时间。
- 时间窗口过滤器匹配请求时间区间内的实际会话事件,而非仅宽泛的会话跨度覆盖。
- 如果工作区在磁盘上不再存在,仍报告记录的 cwd。
- 当用户仅询问有哪些会话、id 是什么、属于哪个项目时,默认表格就足够了。
脚本
使用:
bash
python3 scripts/listcodexsessions.py --help