Home › Articles

Status line in Claude Code, Codex and Cursor: show context % and cost

Updated 2026-11-17

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.

Checked against each vendor's docs (and, for Codex item IDs, the v0.169.0 source) on 17 November 2026. We tested the script and configs below with the input each tool documents; we did not run them inside a live Claude Code, Codex or Cursor session.

Side by side

Claude CodeCodexCursor
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.tomlCLI: ~/.cursor/cli-config.json or /config
Context %context_window.used_percentagecontext-used or context-remainingContext ring next to the prompt (editor)
Costcost.total_cost_usd (estimate, list price)estimated-thread-cost (Enterprise workspaces only)Dashboard, not in the chat
Plan limitsrate_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, /usageClick 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:

FieldWhat it isWatch out for
context_window.used_percentage / remaining_percentageHow full the context window is, pre-calculatedCan be null early in a session. Counts input tokens only (input + cache writes + cache reads), not output
context_window.context_window_size, total_input_tokensWindow size and tokens currently in itTokens are 0 before the first reply
cost.total_cost_usdEstimated session cost in USDList price unless your org set modelPricing; resets to $0 on /clear
rate_limits.five_hour.used_percentage, seven_day.used_percentage, resets_atHow much of your plan's 5-hour and 7-day limits you've usedOnly 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_idModel, folder, a per-session IDsession_id is the right key for cache files
exceeds_200k_tokensWhether the last response passed 200K tokensA 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

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

  1. Folder not trusted. statusLine runs a shell command, so it follows the same workspace trust rule as hooks. Until you accept the trust dialog it stays blank, and claude --debug logs Status line command skipped: workspace trust not accepted.
  2. 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 --debug to see its stderr.
  3. Hooks turned off. With disableAllHooks: true (outside managed settings), only a managed statusLine runs. If your organization sets allowManagedHooksOnly, your own status line disappears without a warning. More on hook settings in hooks in Claude Code, Cursor and Codex.
  4. 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.
  5. Values show as -- or empty. Fields are null before the first response. Use fallbacks (// 0 in jq, or 0 in 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 wantItem IDNote
Modelmodel, model-with-reasoning, reasoning, fast-modemodel-with-reasoning adds the reasoning level
Contextcontext-used, context-remaining, context-window-sizeUsed and remaining are percentages, window size is in tokens; omitted while unknown
Plan limitsfive-hour-limit, weekly-limitShow remaining usage on the primary and secondary limit
Tokensused-tokens, total-input-tokens, total-output-tokensSession totals
Costestimated-thread-cost, thread-creditsEnterprise workspaces only
Where you areproject-name, current-dir, git-branch, pull-request-numberGit items are omitted outside a repo
Sessionthread-id, thread-title, run-state, task-progress, permissions, approval-mode, codex-versiontask-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:

{
  "version": 1,
  "editor": { "vimMode": false },
  "permissions": { "allow": [], "deny": [] },
  "display": {
    "showStatusLineRunningTime": true,
    "showStatusIndicators": true
  }
}

Which numbers are worth the space

  1. 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.
  2. 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.
  3. Session cost if you pay per token, as a guide.
  4. 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

Official docs, checked 2026-11-17.

Get the free rules sampler + new tips by email

Confirm your email and we'll send you straight to the sampler download. Then one short email every two weeks covering tool format changes (Cursor, Claude Code, Codex, Windsurf, Copilot), new rules and kit updates. No spam.

We store only your email, with our email provider Resend. See the privacy policy.

Unsubscribe anytime from any email. Rather skip email? Get the sampler on GitHub or download the zip directly.