Status line in Claude Code, Codex and Cursor: show context % and cost
In short: Claude Code runs any script you point statusLine at and
shows what it prints, so you can put context %, session cost, plan limits and the git branch under the prompt. Codex
has a fixed menu of footer items in tui.status_line (pick them with /statusline), including
context used and remaining plan limits, but no script hook. Cursor has no custom status line: use the context ring
next to the prompt in the editor, and your dashboard for usage. Below: a tested Claude Code script, the Codex config,
and what each number really means.
Side by side
| Claude Code | Codex | Cursor | |
|---|---|---|---|
| Custom status line? | Yes, any command (statusLine) | Built-in items only (tui.status_line) | No (CLI: running time and terminal title only) |
| Set it up | /statusline <what you want> or ~/.claude/settings.json | /statusline picker or ~/.codex/config.toml | CLI: ~/.cursor/cli-config.json or /config |
| Context % | context_window.used_percentage | context-used or context-remaining | Context ring next to the prompt (editor) |
| Cost | cost.total_cost_usd (estimate, list price) | estimated-thread-cost (Enterprise workspaces only) | Dashboard, not in the chat |
| Plan limits | rate_limits.five_hour / seven_day (Pro, Max, Ultra) | five-hour-limit, weekly-limit (remaining) | Dashboard; editor settings on newer plans |
| One-off check | /context, /usage | /status, /usage | Click the context ring |
Claude Code
The fast way: /statusline
Type what you want after the command, for example /statusline show model name and context percentage with a
progress bar. Claude Code writes a script into ~/.claude/ and adds the setting for you (approve the
file edits if it asks). /statusline delete removes it again. If you'd rather own the script, set it up by
hand as below.
What the script gets
Claude Code runs your command with a JSON object on stdin and shows whatever it prints to stdout. The fields people want most:
| Field | What it is | Watch out for |
|---|---|---|
context_window.used_percentage / remaining_percentage | How full the context window is, pre-calculated | Can be null early in a session. Counts input tokens only (input + cache writes + cache reads), not output |
context_window.context_window_size, total_input_tokens | Window size and tokens currently in it | Tokens are 0 before the first reply |
cost.total_cost_usd | Estimated session cost in USD | List price unless your org set modelPricing; resets to $0 on /clear |
rate_limits.five_hour.used_percentage, seven_day.used_percentage, resets_at | How much of your plan's 5-hour and 7-day limits you've used | Only for Pro, Max and Ultra (or behind a Claude apps gateway with a spend limit), only after the first reply, and each window can be absent |
model.display_name, workspace.current_dir, session_id | Model, folder, a per-session ID | session_id is the right key for cache files |
exceeds_200k_tokens | Whether the last response passed 200K tokens | A fixed 200K line, whatever your real window size is |
The docs list more: lines added and removed, effort level, prompt cache stats, the open PR for the branch, worktree details, vim mode and others.
A tested script: context, cost, limits, branch
This uses only Python's standard library (no jq), handles missing and null fields, colours the context
segment green, yellow at 50% and red at 80%, and checks the git branch at most every 5 seconds per session so it stays
fast. If the terminal is narrow, it drops segments from the end instead of wrapping. Save it as
~/.claude/statusline.py:
#!/usr/bin/env python3
"""Claude Code status line: model, context %, session cost, plan limits, git branch.
Claude Code pipes session JSON to stdin and shows what this prints.
Setup: save as ~/.claude/statusline.py, then in ~/.claude/settings.json:
"statusLine": {"type": "command", "command": "python3 ~/.claude/statusline.py"}
Test: echo '{"model":{"display_name":"Opus"},"context_window":{"used_percentage":42}}' | python3 statusline.py
Python 3.8+, standard library only. Set NO_COLOR=1 for plain text.
"""
import json, os, re, subprocess, sys, tempfile, time
GIT_CACHE_SECONDS = 5 # git runs at most this often per session
WARN, DANGER = 50, 80 # context % thresholds for yellow / red
def num(v):
"""Number or None. Fields can be absent or null early in a session."""
return v if isinstance(v, (int, float)) and not isinstance(v, bool) else None
def tokens(n):
return f"{n / 1_000_000:.1f}M".replace(".0M", "M") if n >= 1_000_000 else f"{round(n / 1000)}k"
def git_branch(cwd, session_id):
if not cwd or not os.path.isdir(cwd):
return ""
safe = re.sub(r"[^A-Za-z0-9_-]", "", session_id or "")[:64] or "nosession"
cache = os.path.join(tempfile.gettempdir(), f"statusline-git-{safe}")
try:
if time.time() - os.path.getmtime(cache) < GIT_CACHE_SECONDS:
with open(cache, encoding="utf-8") as f:
return f.read().strip()
except OSError:
pass
try:
out = subprocess.run(["git", "-C", cwd, "branch", "--show-current"],
capture_output=True, text=True, timeout=1)
branch = out.stdout.strip() if out.returncode == 0 else ""
except (OSError, subprocess.SubprocessError):
branch = ""
try:
with open(cache, "w", encoding="utf-8") as f:
f.write(branch)
except OSError:
pass
return branch
def main():
try:
data = json.load(sys.stdin)
except (ValueError, UnicodeDecodeError):
data = {}
if not isinstance(data, dict):
data = {}
get = lambda obj, key: obj.get(key) if isinstance(obj, dict) else None
color = not os.environ.get("NO_COLOR")
paint = lambda text, code: f"\033[{code}m{text}\033[0m" if color else text
parts = [get(get(data, "model"), "display_name") or "Claude"]
ctx = get(data, "context_window")
pct, size = num(get(ctx, "used_percentage")), num(get(ctx, "context_window_size"))
if pct is not None:
text = f"ctx {pct:.0f}%"
used = num(get(ctx, "total_input_tokens"))
if size and used is not None:
text += f" ({tokens(used)}/{tokens(size)})"
parts.append(paint(text, "31" if pct >= DANGER else "33" if pct >= WARN else "32"))
cost = num(get(get(data, "cost"), "total_cost_usd"))
if cost is not None:
parts.append(f"${cost:.2f}")
limits = get(data, "rate_limits") # only on Pro/Max/Ultra plans, after the first reply
for key, label in (("five_hour", "5h"), ("seven_day", "7d")):
used = num(get(get(limits, key), "used_percentage"))
if used is not None:
parts.append(f"{label} {used:.0f}%")
ws = get(data, "workspace")
branch = git_branch(get(ws, "current_dir") or get(data, "cwd"), get(data, "session_id"))
if branch:
parts.append(branch)
# Claude Code sets COLUMNS; drop segments from the end rather than wrap.
cols = os.environ.get("COLUMNS", "")
visible = lambda ps: len(re.sub(r"\033\[[0-9;]*m", "", " | ".join(ps)))
while cols.isdigit() and len(parts) > 1 and visible(parts) > int(cols):
parts.pop()
print(" | ".join(parts))
if __name__ == "__main__":
try:
main()
except Exception: # never leave the status line blank because of a bad field
print("Claude")
Then point Claude Code at it in ~/.claude/settings.json (a project's .claude/settings.json
works too, if the whole team should get it):
{
"statusLine": {
"type": "command",
"command": "python3 ~/.claude/statusline.py",
"padding": 0
}
}
Claude Code reloads settings on save and runs the script right away. Test it with fake input first, as the docs recommend:
$ echo '{"model":{"display_name":"Opus"},"context_window":{"used_percentage":85.4,"total_input_tokens":854000,"context_window_size":1000000},"cost":{"total_cost_usd":6.18},"rate_limits":{"seven_day":{"used_percentage":52}},"session_id":"demo","cwd":"'"$PWD"'"}' | NO_COLOR=1 python3 ~/.claude/statusline.py
Opus | ctx 85% (854k/1M) | $6.18 | 7d 52% | feat/redis-sessions
$ echo '{nope' | python3 ~/.claude/statusline.py
Claude
Want the 5-hour reset time? rate_limits.five_hour.resets_at is Unix epoch seconds. Want two lines?
Print two lines; each becomes its own row.
When it updates, and the other options
- It runs when a session starts or resumes, after each assistant message, when
/compactfinishes, when the permission mode or vim mode changes, and when you change the command. Updates are debounced by 300 ms, and a new update cancels a script that's still running. - If your line shows something time-based (a clock, a countdown to
resets_at), add"refreshInterval": 10to re-run it every N seconds (minimum 1). paddingadds extra horizontal spacing (default 0).hideVimModeIndicatorhides the built-in-- INSERT --when your script printsvim.modeitself.- The script runs locally and doesn't use API tokens. It does run often, so keep slow commands like
git statuscached; the docs' own examples key the cache onsession_id, not the process ID, which changes every run. - Read width from the
COLUMNSenvironment variable. Claude Code captures the output, sotput colscan't see the terminal.
What the numbers mean
Context % vs /context. The status line uses counts from the last API response.
/context adds an estimate for messages added since, so it can read higher until the next reply. Right
after /compact, current_usage is null until the next call. For what to do when the number gets
high, see context window full: what to do.
Cost is an estimate. Claude Code computes it from token counts at list price (or your org's
modelPricing rates), the same figure as the Total cost line in /usage. On a Pro,
Max or Ultra plan the docs say that session cost isn't relevant for billing; the useful numbers there are the
rate_limits percentages. On the API it's a good running guide, not an invoice. It resets when
/clear starts a new session.
Plan limits only appear after the first reply. A fresh session shows no 5h/7d segment yet, and a
window drops out once its resets_at passes. The script above simply skips what's missing.
Status line blank? Check these
- Folder not trusted.
statusLineruns a shell command, so it follows the same workspace trust rule as hooks. Until you accept the trust dialog it stays blank, andclaude --debuglogsStatus line command skipped: workspace trust not accepted. - Script failed. Output only shows after an exit code of 0; a non-zero exit or empty output blanks
the line. Run it by hand with the mock JSON above, and use
claude --debugto see its stderr. - Hooks turned off. With
disableAllHooks: true(outside managed settings), only a managedstatusLineruns. If your organization setsallowManagedHooksOnly, your own status line disappears without a warning. More on hook settings in hooks in Claude Code, Cursor and Codex. - Windows paths. Claude Code runs the command through Git Bash when it's installed, else
PowerShell. Write paths with forward slashes (for example
python C:/Users/you/.claude/statusline.py); backslashes get eaten as escapes. - Values show as
--or empty. Fields are null before the first response. Use fallbacks (// 0in jq,or 0in Python).
Notifications (MCP errors, the context-low warning, auto-updates) share the status line's row outside fullscreen mode and can truncate it on a narrow terminal.
Codex
Codex's footer status line is a list of built-in items. Type /statusline, toggle and reorder items in
the picker, and confirm; the footer updates immediately and the choice is saved to tui.status_line in
config.toml. Or write it yourself:
# ~/.codex/config.toml (or run /statusline in the Codex TUI to pick and order items)
[tui]
status_line = [
"model-with-reasoning",
"context-used",
"five-hour-limit", # shows remaining, not used
"weekly-limit", # shows remaining, not used
"git-branch",
]
Order in the array is order on screen. The docs describe the items in groups (model, model + reasoning, context stats, rate limits, git branch, token counters, session ID, current directory or project root, Codex version) but don't list the IDs. These come from the item list in Codex's source at v0.169.0:
| You want | Item ID | Note |
|---|---|---|
| Model | model, model-with-reasoning, reasoning, fast-mode | model-with-reasoning adds the reasoning level |
| Context | context-used, context-remaining, context-window-size | Used and remaining are percentages, window size is in tokens; omitted while unknown |
| Plan limits | five-hour-limit, weekly-limit | Show remaining usage on the primary and secondary limit |
| Tokens | used-tokens, total-input-tokens, total-output-tokens | Session totals |
| Cost | estimated-thread-cost, thread-credits | Enterprise workspaces only |
| Where you are | project-name, current-dir, git-branch, pull-request-number | Git items are omitted outside a repo |
| Session | thread-id, thread-title, run-state, task-progress, permissions, approval-mode, codex-version | task-progress comes from the agent's plan updates |
Two things trip people up. First, the limit items count down: they show what's left, while Claude Code's
rate_limits fields count up. Second, there's no dollar figure on personal plans; use
/usage for account token usage and /status for the session's remaining context.
To try a layout for one session without saving it, list the items after the command, for example
/statusline model project-name. /statusline --clear hides everything for the session.
/title does the same job for the terminal
tab title (tui.terminal_title), which helps when you run
several agents in parallel.
A script-driven status line like Claude Code's isn't available. It's an open feature request (openai/codex #17827, active as of mid-November 2026).
Cursor
Cursor's docs don't describe a custom status line in either the editor or the CLI. What you get:
- The context ring (editor). It sits next to the prompt input and shows how full the context window is. Click it for a breakdown of tokens by system prompt, tools, rules, skills, MCP, subagents, summarized conversation and conversation. A big fixed slice there is the first thing to trim; see too many skills and MCP config.
- CLI display options. In
~/.cursor/cli-config.json(global only; a project's.cursor/cli.jsontakes permissions only),display.showStatusLineRunningTimeshows elapsed running time in the CLI's status line anddisplay.showStatusIndicatorsputs status indicators in the terminal title./status-indicatorstoggles the latter and/configedits settings interactively. The file needs its required fields:
{
"version": 1,
"editor": { "vimMode": false },
"permissions": { "allow": [], "deny": [] },
"display": {
"showStatusLineRunningTime": true,
"showStatusIndicators": true
}
}
- Usage and spend. These live on the web dashboard for your plan, not in the chat: the Spending tab on legacy Cursor plans, the Usage page on newer plans (where Cursor's settings also show remaining usage). Spend limits and team spend alerts are set on the dashboard too.
- A context % you can act on. Cursor's
preCompacthook receivescontext_usage_percentandcontext_window_sizeright before Cursor summarizes a chat. It can't draw a status line, but it can show you a message at that moment; the context window article has a tested hook that does.
Which numbers are worth the space
- Context %. It tells you when compaction is coming. Our rule of thumb: once it's high, finish the current step, then compact or start fresh at a clean break rather than mid-edit.
- Plan limits if you're on a subscription (5h/7d in Claude Code, remaining limits in Codex). They tell you whether to start a big task now.
- Session cost if you pay per token, as a guide.
- Git branch when you juggle worktrees, so you know which checkout the agent is editing (and can undo its changes in the right place).
Skip anything you won't act on. The line is narrow, and each extra command the script runs adds lag.
FAQ
How do I show the context percentage in Claude Code's status line?
Add a statusLine entry to ~/.claude/settings.json with type "command" and a command that reads the JSON Claude Code sends on stdin and prints context_window.used_percentage. Or run /statusline with a description, such as /statusline show model and context percentage, and Claude Code writes the script and the setting for you. The value can be null early in a session, so give it a fallback.
Is the cost in Claude Code's status line my real bill?
No. cost.total_cost_usd is an estimate Claude Code computes locally at list price, unless your organization set a modelPricing table, and it resets to $0 when /clear starts a new session. On a Pro, Max or Ultra plan the dollar figure isn't what you pay; show rate_limits.five_hour and seven_day instead, which are the plan limits you actually hit.
Why does the status line show a different context % than /context?
The status line uses the token counts from the last API response. /context adds an estimate for messages added since then, so it can read higher until the next response arrives. used_percentage also counts input tokens only (input plus cache writes plus cache reads), not output.
Can Codex run a custom status line script like Claude Code?
No. Codex's status line is a list of built-in items in tui.status_line in config.toml, which /statusline edits for you. You choose and order items such as model-with-reasoning, context-used, five-hour-limit, weekly-limit and git-branch, but you can't print your own text. A command-backed status line is an open feature request (openai/codex issue #17827).
Does Cursor have a custom status line?
Not in Cursor's docs. In the editor, the context ring next to the prompt shows how full the context window is, and clicking it opens a breakdown by category. The Cursor CLI can show elapsed running time in its status line and status indicators in the terminal title, but it has no script hook. Usage and spend live in your Cursor dashboard.
Sources
- Claude Code docs: Customize your status line
- Claude Code docs: Manage costs effectively (/usage, list-price estimates)
- Claude Code docs: All settings (statusLine, disableAllHooks, modelPricing)
- Codex docs (ChatGPT Learn): Developer commands (/statusline, /status, /title)
- Codex docs (ChatGPT Learn): Configuration reference (tui.status_line)
- Codex source on GitHub, v0.169.0: status line item IDs
- openai/codex issue #17827: command-backed status line (open feature request)
- Cursor docs: Prompting agents (Context usage ring)
- Cursor docs: CLI configuration (cli-config.json display options)
- Cursor docs: CLI slash commands (/status-indicators, /config)
- Cursor docs: Hooks (preCompact context fields)
- Cursor help: Usage and limits (where to check usage)