CSV State File Format

June 4, 2026 ยท View on GitHub

State files are stored at ~/.claude/statusline/statusline.<session_id>.state. Each line is a CSV record with 15 comma-separated fields.

Field Specification

IndexFieldTypeDescription
0timestampintegerUnix timestamp in seconds
1total_input_tokensintegerCumulative input tokens for the session
2total_output_tokensintegerCumulative output tokens for the session
3current_input_tokensintegerInput tokens for the current request
4current_output_tokensintegerOutput tokens for the current request
5cache_creationintegerCache creation input tokens
6cache_readintegerCache read input tokens
7cost_usdfloatTotal session cost in USD
8lines_addedintegerTotal lines added in session
9lines_removedintegerTotal lines removed in session
10session_idstringSession identifier (UUID)
11model_idstringModel identifier (e.g., claude-opus-4-5)
12workspace_project_dirstringProject directory path (commas replaced with underscores)
13context_window_sizeintegerContext window size in tokens
14api_duration_msintegerCumulative API wait time in milliseconds (cost.total_api_duration_ms); powers the tok/s throughput display

Constraints

  • Fields are separated by commas with no quoting or escaping.
  • The workspace_project_dir field (index 12) is sanitized before writing: all comma characters (,) are replaced with underscores (_) to prevent CSV corruption.
  • Numeric fields default to 0 when absent. String fields default to empty string.
  • Lines are newline-terminated (\n).
  • Files are append-only.
  • Files are automatically rotated at 10,000 lines (keeps most recent 5,000) by the Python statusline script.
  • Duplicate entries (same token count as previous line) are skipped to prevent file bloat.

Legacy Format

Older state files may contain 2-field lines: timestamp,total_input_tokens. The reader defaults all other fields to zero/empty for these lines.

State files written before the api_duration_ms field was added contain 14 fields (through context_window_size). The reader defaults api_duration_ms to 0 for these lines, and field access is length-guarded so both 14- and 15-field rows parse correctly. Conversely, older readers ignore the extra trailing field, so the change is backward-compatible in both directions.

Example

1710288000,75000,8500,50000,5000,10000,20000,0.05234,250,45,abc-123-def,claude-opus-4-5,/home/user/my-project,200000,5000