Raw capture โ€” raw/session-analysis.md


url: https://github.com/lhl/fsr4-rdna3-optimization/tree/main/session-analysis date_fetched: 2026-07-05 backfilled: true


Tools and documentation for analyzing AI coding assistant session data from Claude Code and Codex CLI.

When using AI coding assistants for non-trivial work (like our FSR4 kernel optimization campaign), it's useful to understand:

This helps with reproducibility planning, cost estimation, and understanding the practical dynamics of AI-assisted development.

Sessions are stored as JSONL files under:

~/.claude/projects/<encoded-project-path>/<session-uuid>.jsonl

The project path is the filesystem path with / replaced by -, e.g.:

~/.claude/projects/-home-lhl-github-lhl-fsr4-rdna3/af1c788b-c174-4d2f-bf69-56e2d5ebda85.jsonl

Subagent sessions live in a subagents/ subdirectory within the project.

Sessions are stored under:

~/.codex/sessions/YYYY/MM/DD/rollout-<ISO-timestamp>-<uuid>.jsonl

Additional data:

Type Description Key Fields
user User message message.content(text),timestamp
assistant Assistant response message.usage(token counts),message.model,message.content
progress Tool execution progress data(progress info),toolUseID
system System events (hooks, etc.) slug,subtype,hookInfos
file-history-snapshot File state snapshots snapshot(file contents)

Token usage (in assistant entries under message.usage):

Type Description Key Fields
session_meta Session metadata payload.cwd,payload.id,payload.cli_version,payload.model
turn_context Per-turn context payload.model,payload.approval_policy,payload.turn_id
event_msg Lifecycle events payload.type(see subtypes below)
response_item Messages & tool calls payload.role,payload.content,payload.type
compacted Compacted history payload.replacement_history(array of prior messages)

Event message subtypes (event_msg.payload.type):

Token usage (in token_count events under info.total_token_usage):

python3 analyze_sessions.py --project-filter fsr4``python3 analyze_sessions.py --project-filter fsr4 --json > sessions.jsonBy default, gaps > 5 minutes between events are considered idle. To use 10 minutes:

hon3 analyze_sessions.py --idle-threshold 600 python3 analyze_sessions.py \ --claude-dir /path/to/.claude/projects \ --codex-dir /path/to/.codex \ --project-filter myproject

Get just the big Codex session's token usage

python3 analyze_sessions.py --project-filter fsr4 --json | \ jq '.[] | select(.tool == "codex-cli" and .wall_seconds > 3600) | .tokens'

List all user messages from all sessions

python3 analyze_sessions.py --project-filter fsr4 --json | \ jq '.[] | select(.user_messages) | .user_messages[] | .text'

Get wall time and active time for all sessions

python3 analyze_sessions.py --project-filter fsr4 --json | \ jq '.[] | {session_id: .session_id[:12], tool, wall: .wall_seconds, active: .active_seconds}'

The script auto-discovers sessions by scanning the standard data directories. To analyze sessions from a different project, just change `--project-filter`:

python3 analyze_sessions.py --project-filter shisad python3 analyze_sessions.py --project-filter mistral-vibecheck `` To add support for another AI coding tool, implement ananalyze__session()` function that returns a dict with at minimum: