Input JSON Schema
Input JSON Schema
Claude Code communicates with your statusline script by passing a JSON object through stdin every time the prompt refreshes. The generated script uses jq to parse this data and update the visual blocks.
Understanding this schema is useful if you want to extend the script or troubleshoot how data is being mapped from Claude Code to your terminal.
Data Structure
The following properties are extracted from the input JSON:
| Key | Type | Description |
|---|---|---|
| model.display_name | string | The full name of the active model (e.g., "Claude 3.5 Sonnet"). |
| context_window.used_percentage | number | A float representing how much of the context window is full (0–100). |
| context_window.total_input_tokens | integer | Total input tokens consumed in the current session. |
| context_window.total_output_tokens | integer | Total output tokens generated in the current session. |
| cwd | string | The absolute path to the current working directory. |
| workspace.current_dir | string | Fallback used if cwd is not explicitly provided. |
Example Input
Below is an example of the JSON object Claude Code sends to the statusline script:
{
"model": {
"id": "claude-3-5-sonnet-20241022",
"display_name": "Claude 3.5 Sonnet"
},
"context_window": {
"used_percentage": 30.5,
"total_input_tokens": 12400,
"total_output_tokens": 3100,
"max_tokens": 200000
},
"cwd": "/Users/username/projects/my-app",
"workspace": {
"current_dir": "/Users/username/projects/my-app"
}
}
Script Extraction Logic
The editor generates specific jq filters to handle this data safely, including default values to prevent the statusline from breaking if a field is missing:
- Model Name:
.model.display_name // "Claude"(The script further strips the "Claude " prefix for brevity). - Context %:
.context_window.used_percentage // 0(Truncated to an integer for display). - Tokens:
.context_window.total_input_tokens // 0and.context_window.total_output_tokens // 0. - Directory:
.cwd // (.workspace.current_dir // "").
[!NOTE] Usage limits (Rate 5h/Week) are not part of this JSON. The generated script fetches that data directly from the Anthropic API and caches it locally to ensure high performance.