Show Claude Code context usage in the status line
One setting that displays your agent's context percentage, so you know when to clear before history compresses.
Published here · 2 sources · Resume reading
Your coding agent's context fills up quietly. When it gets close to the limit, Claude Code summarizes older history to make room, and details can go. A live gauge tells you before that happens.
Use the slash command
Type this in Claude Code [1]:
/statusline show model name and context percentage with a progress barClaude Code writes the script into ~/.claude/ and updates your settings. Approve the file edit prompts when they appear.
You should see the model name and context percentage in the status line.
Add the line by hand
If you have jq installed, add this to ~/.claude/settings.json [1]:
{
"statusLine": {
"type": "command",
"command": "jq -r '\"[\\(.model.display_name)] \\(.context_window.used_percentage // 0)% context\"'"
}
}You should see output like [Sonnet] 87% context when your session is running.
Check the percentage before each task
My rule, not a built-in limit: past about 80%, finish the step you are on, then /clear before the next task. That keeps history from compressing mid-task.
The percentage counts input tokens only [2]. It can be empty early in a session. The // 0 in the jq line shows 0% until there is data.
I ran the jq line on sample JSON (no live session): 42 in, [Sonnet] 42% context out; 87 in, [Sonnet] 87% context out.
Your status line now shows context usage. Clear when it climbs past 80% to keep full history for your current task.
Send this to the friend whose Claude Code forgets details halfway through a long session.
Keep this guide
Filed under Claude Code, Cost and context
Questions about this guide
Does the status line show output tokens?
No. The percentage is input tokens only, per the Claude Code costs docs. Output tokens are tracked separately.
What happens at 100% context?
Claude Code summarizes older history to make room. Details can be lost in the summary, which is why clearing before that point helps.
Sources
- Claude Code docs: status linecode.claude.com
- Claude Code docs: costscode.claude.com
Next in this stack
Keyword IDLE
Control Claude Code idle compaction
Keyword MEMORY
Give new Claude Code sessions your project facts
Keyword HACKS
Use five built-in Claude Code shortcuts