OmniscioGuidesStatus line examplesContext usage bar
Claude Code status line context usage bar
A bar answers one question at a glance: how much of this session's window is spent. This page gives you the script, then the context fields behind it, the way to prove the bar renders, and the one number that will not match what you expect.
Checked against Claude Code 2.1.332 documentation, November 25, 2026. By the Omniscio team. Updated .
What it shows
One row: the model, then a ten-block bar where a filled block is a tenth of the window, then the percentage as a whole number.
[Opus] ▓▓░░░░░░░░ 25%Two filled blocks out of ten is 20 to 29 percent used. The bar is coarse on purpose: ten blocks on a bar you glance at is enough to tell comfortable from nearly full, and a wider bar costs terminal width you need for the model name.
The percentage is a whole number because the script drops any decimal part, so the block arithmetic stays integer arithmetic throughout. It truncates rather than rounds: a window at 99.9 percent draws nine of the ten blocks, never ten, and anything under a tenth draws none.
The full script
Save this as ~/.claude/statusline.sh and make it executable with chmod +x. It is Anthropic's context window usage example, reproduced whole, without the comments the documentation carries.
#!/bin/bash
input=$(cat)
MODEL=$(echo "$input" | jq -r '.model.display_name')
PCT=$(echo "$input" | jq -r '.context_window.used_percentage // 0' | cut -d. -f1)
BAR_WIDTH=10
FILLED=$((PCT * BAR_WIDTH / 100))
EMPTY=$((BAR_WIDTH - FILLED))
BAR=""
[ "$FILLED" -gt 0 ] && printf -v FILL "%${FILLED}s" && BAR="${FILL// /▓}"
[ "$EMPTY" -gt 0 ] && printf -v PAD "%${EMPTY}s" && BAR="${BAR}${PAD// /░}"
echo "[$MODEL] $BAR $PCT%"The // 0 is a fallback, not decoration. Without it a null percentage reaches the arithmetic as the word null, and the row reads null%; with it the row reads 0%. That is the difference it buys.
The script also needs jq installed — a separate download from jqlang.org that is not on a stock Mac. Check with jq --version. Without it the model name and the percentage both come back empty, which looks like a bug in the script.
The block characters are the trick: printf -v builds a run of spaces and the // /▓ substitution turns each space into a filled block, so the bar is a string, not a loop.
The settings entry
In ~/.claude/settings.json, or a project's settings file:
{
"statusLine": {
"type": "command",
"command": "~/.claude/statusline.sh"
}
}Add the object beside whatever else the file holds, inside the same braces; it is not a whole file to paste over.
Nothing else is needed. The context figures change when a response arrives and when /compact finishes, and both of those re-run the script, so a bar does not usually need refreshInterval. Save the file and Claude Code runs the script straight away. Add the field only if you want the row refreshed while the session sits idle.
On Windows, when Git Bash is installed Claude Code runs the command through it, and Git Bash treats an unquoted backslash as an escape character — so a path written with backslashes loses its separators and the failure is silent. The path above already uses forward slashes; keep them that way wherever you put the script. The PowerShell page in this set gives the native version.
What each field means
The context block describes the live window as of the most recent API response, not a running total for the session. Here is the block, with the one field a bar is drawn from at the top and the two that will mislead you if you read them as something else.
| Field | What it holds |
|---|---|
context_window.used_percentage | A percentage Claude Code has already calculated. This is the one to draw: it is a fraction of the real window whatever size that window is |
context_window.remaining_percentage | Its complement. Use it if you would rather label the bar with what is left |
context_window.context_window_size | The size of the current window in tokens. It is a field rather than a constant, which is why a hand-computed percentage has to divide by it instead of by a number you remember |
context_window.total_input_tokens, total_output_tokens | The tokens currently in the window, from the most recent API response. The input figure includes cache reads and cache writes |
context_window.current_usage | The same counts broken out as fresh input, output, cache writes and cache reads. It is null until the conversation has an API response, and null or all zeros after /compact until the next call. Treat both as empty |
exceeds_200k_tokens (a top-level field, not inside context_window) | Whether the last response's total passed 200k. A fixed threshold whatever your window size, so it is not a replacement for a percentage |
COLUMNS | Not a JSON field: the terminal width, refreshed before each run. It is what tells you how much room the bar and the model name have |
The formula behind the field is worth knowing even though you never type it: used_percentage is fresh input plus cache writes plus cache reads, divided by the window. Output tokens are not in the fraction.
That is also the reason a hand-rolled percentage disagrees with the built-in one. If you compute it from current_usage and include output_tokens, you get a higher number than Claude Code does, and no amount of checking will reconcile them.
How to confirm it renders
Give the script a percentage you can count. Anthropic's tip is to pipe mock JSON in, and a bar is the one example where the mock carries everything you need to see:
echo '{"model":{"display_name":"Opus"},"context_window":{"used_percentage":25},"session_id":"test"}' | ~/.claude/statusline.shTwenty-five percent of ten blocks is two and a half, and the integer arithmetic drops the half, so two blocks fill. If you see [Opus] ▓▓░░░░░░░░ 25%, the script works and the setting is all that is left.
Read the row in a real session next to /context, and expect the status line to read a little lower. That gap is documented, not a fault in your script.
If the row is blank instead, claude --debug logs the script's stderr on every invocation and its exit code on the first one in a session, which tells you whether the script failed or never ran.
The common failure
The failure people report is not a broken bar. It is a bar that disagrees with /context, and the explanation is that the two measure different moments. The status line reports the counts from the last API response; /context adds an estimate for the messages sent since that response, so it reads higher until the next one arrives.
Anthropic's own advice is to trust used_percentage for the simplest accurate state of the window. Everything else on this page is a variation on reading that one field.
| What you see | What is happening |
|---|---|
The percentage is lower than /context | Two documented reasons: the field counts input tokens only, and /context includes an estimate for messages since the last response |
The row reads 0% at the start, or right after /compact | The counts are 0 before the first API response, and current_usage is null or all-zeros after a compaction until the next call. The // 0 fallback is why the row still prints |
| The bar jumps when nothing big changed | Compaction rewrites the conversation, so the next response reports a much smaller window. That is a real change, not a glitch |
| The bar reads nearly full on a model with a bigger window | Someone divided tokens by a hard-coded window size. Draw the bar from used_percentage, or divide by context_window_size |
| Nothing appears at all | The documented causes are a folder whose trust dialog has not been accepted, a script that failed, and a setting that switched the row off. claude --debug shows which one you have |
The other scripts in this set
Each one is a complete script and settings entry, not a fragment.
- Model, folder and git branch — plus staged and modified file counts
- Cost so far — the session's estimated spend and elapsed time
- PowerShell on Windows — the same idea where Git Bash is not installed
- Two rows — this bar on the second row, with cost and time
- The context window itself — what the numbers mean beyond the bar
Where Omniscio fits
The status line is Claude Code's own, and nothing on this page needs Omniscio. Omniscio is a desktop app for running several Claude Code agents side by side, in one list rather than a wall of terminals.
Its agent sessions run Claude Code in print mode, so they show Omniscio's session list rather than a terminal row, while a status line you configure still applies to any claude you run yourself in a terminal.
The features page lists what the app does today.
How this page was checked
Every statement here about Claude Code comes from Anthropic's own documentation, read in its Markdown form on November 25, 2026: the status line page, the settings reference and the changelog. The version line comes from the changelog, whose newest release is 2.1.332, dated November 25, 2026.
The script is Anthropic's context window usage example reproduced in full. It was not written for this page and not run on our machine; where the page says what it prints, it is following the example's own arithmetic.
What this page says about Omniscio comes from our own pages. If Anthropic's page and this one ever disagree about Claude Code, Anthropic's page is right, because this part of Claude Code changes on nearly every release.
Sources
- Customize your status line: the setting, the context window example, the full JSON, the context window fields and the formula behind
used_percentage, the update triggers and the troubleshooting section - Settings reference: the
statusLineentry, its fields and its defaults - The changelog: release 2.1.332, the newest listed
- jq: the JSON parser the script calls
Omniscio's own pages, for what this section says about this app:
- Omniscio's homepage: the product description
- Features: what the app does today
- Claude Code status line: the setting and the payload this page assumes
Common questions
Why is my status line percentage lower than /context?
They measure different moments. used_percentage is calculated from input tokens only, and the status line reports the counts from the last API response, while /context adds an estimate for messages sent since that response. So /context can read higher until the next response lands.
What is a good context percentage to keep an eye on?
Claude Code does not document a threshold, so the number is yours. What the field does tell you is how much of the current window is spent, and a bar that fills is a signal to compact or start a fresh session. The two-row script in this set turns green, amber and red at 70 and 90 percent; those are that example's numbers, not a recommendation.
Why does the bar read 0% at the start of a session?
The context figures are 0 before the session's first API response, and current_usage is null then and again after /compact until the next call. That is expected rather than broken; the script here falls back to 0 so the row still prints.
Is the bar right on a model with a bigger context window?
Yes, as long as you draw it from used_percentage, which is already a fraction of whatever window the session has. A script that divides tokens by a number it hard-coded reads wrong the moment the window size differs, because context_window_size is a field rather than a constant.
Run the sessions behind those status lines, from one window
Install Omniscio, keep your Claude Code sessions in one list, and see what each one needs without hunting through terminals. The features page lists what is in it today.