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:
~/.codex/history.jsonl- consolidated history across all sessions~/.codex/state_5.sqlite- session state database~/.codex/config.toml- CLI configuration| 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):
input_tokens- direct input tokensoutput_tokens- generated output tokenscache_creation_input_tokens- tokens used to create prompt cachecache_read_input_tokens- tokens served from prompt cache| 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):
task_started/- task_completed- turn lifecyclemodel_response_started/- model_response_completed- inference lifecycletoken_count- running token usage (has- info.total_token_usage)exec_started/- exec_completed- tool execution lifecycleexec_approval_pending/- exec_approval_granted- approval flowreasoning- model reasoning eventsToken usage (in token_count events under info.total_token_usage):
input_tokens- total input tokens (cumulative)cached_input_tokens- tokens served from cacheoutput_tokens- total output tokensreasoning_output_tokens- tokens used for chain-of-thought reasoningtotal_tokens- input + output totalpython3 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
python3 analyze_sessions.py --project-filter fsr4 --json | \ jq '.[] | select(.tool == "codex-cli" and .wall_seconds > 3600) | .tokens'
python3 analyze_sessions.py --project-filter fsr4 --json | \ jq '.[] | select(.user_messages) | .user_messages[] | .text'
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:
tool,- session_id,- filestart,- end,- wall_seconds,- active_seconds,- idle_secondstokensdict with whatever breakdown the tool provides
Claude Code cache tokensdominate total API token counts. Thecache_read_input_tokensare served from Anthropic's prompt cache and are much cheaper than regular input tokens. A session showing "4M total API tokens" may have only 6K regular input + 13K output, with the rest being cache operations.
token_countevents report running totals, so the script takes the last value as the session total.