Status Line
statusline.ps1 is a PowerShell 7+ script that renders a compact, information-dense status line at the end of every Claude Code session turn. It is wired as a Stop hook so Claude Code invokes it automatically each time the model finishes a reply. The output is printed directly to the terminal and gives an at-a-glance view of model identity, token budgets, working context, and git state — without requiring the developer to open any dashboard or run a separate command.
Demo / Sample Output
claude-sonnet-4-6 | [####......] 42.1k/200k (21%) | session: [##........] 85.3k (42% / ~2h) | 7d: [#.........] 1.2M (10% / ~5d) | ai-workspace | [dev]
Each field is separated by |. The bars use # for filled segments and . for empty segments, surrounded by [ and ]. Ten segments represent 0–100%, so each segment equals 10% of the relevant limit.
Status Line Elements
The elements appear in the following left-to-right order.
Model
Displays the active Claude Code model identifier (for example claude-sonnet-4-6). The identifier is read from the display_name field of the JSON data that Claude Code writes on each stop event. Color-coding distinguishes model tiers at a glance:
- Orange — Opus models
- Cyan — Haiku models
- White — all other models (Sonnet and any future tier)
Context Window
A 10-segment ASCII bar followed by the raw token counts and a percentage:
[####......] 42.1k/200k (21%)
used is the number of tokens already consumed in the current context window; total is the window size for the active model. The bar and percentage text are colored by fill level:
| Fill | Color |
|---|---|
| > 90% | Light red |
| > 80% | Dark red |
| > 65% | Yellow |
| > 0% | Green |
Session Tokens (5-Hour Rate-Limit Bar)
Displays cumulative tokens used since the session started, merged with a 5-hour rolling rate-limit bar and a reset countdown:
session: [##........] 85.3k (42% / ~2h)
85.3k is the sum of input_tokens and cache_read_input_tokens accumulated this session. The bar and percentage reflect how much of the 5-hour rate-limit window has been consumed. The countdown (~2h, ~Xm) shows how long until the current 5-hour window resets, giving a practical signal for when capacity will be replenished. The same color thresholds as the context bar apply.
7-Day Rolling Token Total (7-Day Rate-Limit Bar)
Displays the rolling 7-day token total, a rate-limit bar, and a reset countdown:
7d: [#.........] 1.2M (10% / ~5d)
Usage is persisted across sessions in D:\_workarea\script\usage-data.json. Each run computes the delta between the current cumulative session count and the last observed count (lastTokens), then adds that delta to the appropriate calendar-day bucket in the daily map. The 7-day total is the sum of the last seven days' deltas. The countdown (~5d, ~Xh) shows how long until the oldest day in the trailing window rolls off, partially freeing capacity. Entries older than 30 days are pruned on every run to keep the file compact.
The persistence file tracks three values alongside the daily map:
| Key | Description |
|---|---|
lastTokens |
Last observed cumulative token count; used to compute the per-run delta |
allTime |
All-time cumulative token total across all sessions |
daily |
Map of yyyy-MM-dd → token delta for that calendar day |
Current Working Directory
Displays the last folder name of the current workspace directory (for example ai-workspace). It is extracted from the cwd field of the stop-event JSON. Only the leaf folder name is shown to keep the status line concise.
Git Branch
Displays the current git branch name surrounded by square brackets (for example [dev]). The branch is read by running git rev-parse --abbrev-ref HEAD inside the workspace directory. Color distinguishes protected branches:
- Yellow —
mainormaster - Cyan — all other branch names
Installation
Prerequisites
- PowerShell 7 or later (
pwsh) - The script file at
D:\_workarea\script\statusline.ps1
Wire the Stop Hook
Add the following snippet to .claude/settings.json in your workspace root (create the file if it does not exist). The Stop hook array runs the script each time Claude Code finishes a reply.
{
"hooks": {
"Stop": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "pwsh -NoProfile -NonInteractive -Command \"Get-Content -Raw -Path $env:CLAUDE_STOP_DATA_FILE | D:\\_workarea\\script\\statusline.ps1\""
}
]
}
]
}
}
CLAUDE_STOP_DATA_FILE is an environment variable set by Claude Code on each stop event. It points to a temporary JSON file containing session metadata (model name, token counts, working directory, and other fields). The script reads this file via stdin, parses it, and writes the formatted status line to the terminal.
Note: The
matcherfield is intentionally empty so the hook fires on every stop event regardless of the command that just completed.