GuidesHosting choices

Claude Code statusline: /statusline, settings.json and the JSON

Set up the Claude Code status line: /statusline, the statusLine block in settings.json, every JSON field on stdin, a jq script, refresh timing, blank-line fixes.

November 22, 2026The Everpod team
The short answer

Type /statusline followed by what you want, for example /statusline show model name and context percentage, and Claude Code writes a script into ~/.claude/ and wires it up. To do it by hand, add a statusLine block to ~/.claude/settings.json with "type": "command" and a command pointing at an executable script. Claude Code pipes a JSON object (model, folder, cost, context window, rate limits, session and git details) into the script on stdin and shows whatever it prints on stdout, re-running it after each assistant message and a few other events, debounced to 300 ms. A blank status line almost always means the script is not executable, printed nothing, exited non-zero, or the folder is not yet trusted.

Setting it up with /statusline

/statusline takes a plain-language description. Per Anthropic’s status line documentation (as of November 2026, Claude Code 2.1.330), it generates a script file in ~/.claude/ and updates your settings, asking for approval of the file edits on the way:

/statusline show model name and context percentage with a progress bar
/statusline add the git branch and session cost
/statusline remove it
Copied

The last form (or /statusline delete, /statusline clear) takes it away again; deleting the statusLine key from the settings file does the same. If you keep your Claude Code configuration somewhere other than ~/.claude with CLAUDE_CONFIG_DIR, use 2.1.327 or later: earlier versions of /statusline wrote to ~/.claude/settings.json anyway, so the setting landed in a file Claude Code was not reading. Updating Claude Code covers checking your version and moving to the latest one.

The statusLine setting

By hand, the block goes in ~/.claude/settings.json for every project, or in a project’s .claude/settings.json (shared with the team when committed) or .claude/settings.local.json (just you). The usual settings precedence applies: local beats shared project, which beats user. Settings files are strict JSON, so a trailing comma or a // comment breaks the whole file.

{
  "statusLine": {
    "type": "command",
    "command": "~/.claude/statusline.sh",
    "padding": 2,
    "refreshInterval": 10
  }
}
Copied

Claude Code picks up the saved file without a restart. The status line sits in its own row above the footer badges rather than replacing them, though with one configured some footer hints such as ? for shortcuts stop showing. It runs locally and uses no API tokens. Settings are not instructions to the model; those go in CLAUDE.md.

A script to start from

The script reads one JSON object from stdin and prints one or more lines. With jq installed (on Debian and Ubuntu, sudo apt install jq), this shows the model, the folder, context used, the session’s estimated cost and, on a subscription, the five-hour limit. Every line of it follows the patterns in Anthropic’s own examples:

#!/bin/bash
input=$(cat)

MODEL=$(echo "$input" | jq -r '.model.display_name')
DIR=$(echo "$input" | jq -r '.workspace.current_dir')
PCT=$(echo "$input" | jq -r '.context_window.used_percentage // 0' | cut -d. -f1)
COST=$(echo "$input" | jq -r '.cost.total_cost_usd // 0')
FIVE_H=$(echo "$input" | jq -r '.rate_limits.five_hour.used_percentage // empty')

LINE="[$MODEL] ${DIR##*/} | ${PCT}% context | $(printf '$%.2f' "$COST")"
[ -n "$FIVE_H" ] && LINE="$LINE | 5h: $(printf '%.0f' "$FIVE_H")%"
echo "$LINE"
Copied

Save it, make it executable, and test it with fake input before Claude Code ever runs it:

chmod +x ~/.claude/statusline.sh
echo '{"model":{"display_name":"Opus"},"workspace":{"current_dir":"/home/user/project"},"context_window":{"used_percentage":25},"session_id":"test"}' | ~/.claude/statusline.sh
Copied

The // 0 and // empty fallbacks matter: several fields are null or missing until the first API response, and rate_limits never appears at all on an API key. Each echo becomes its own row, so a two-line status line is two echo statements.

Colours are ANSI escape codes. Anthropic’s git example sets them like this and prints with echo -e:

GREEN='\033[32m'; YELLOW='\033[33m'; RESET='\033[0m'
echo -e "${GREEN}[$MODEL]${RESET} ${YELLOW}$BRANCH${RESET}"
Copied

If the codes come out as literal text, or a clickable OSC 8 link shows as \e]8;;, print with printf '%b' instead of echo -e, which the docs say handles escapes more reliably across shells. Python and Node.js work just as well and need no jq; the docs give each example in all three. Community projects such as ccstatusline package ready-made themes.

The JSON Claude Code sends

The fields the documentation lists as of Claude Code 2.1.330, grouped. Many are absent rather than empty when they do not apply, so read every optional one with a fallback.

GroupFieldsNotes
Model
model.id, model.display_name, effort.level, thinking.enabled, fast_modeeffort is absent on a model without the effort setting.
Folders
cwd, workspace.current_dir, workspace.project_dir, workspace.added_dirs, workspace.git_worktree, workspace.repo.host/owner/namecwd and current_dir are the same; project_dir is where Claude Code was launched. repo comes from the origin remote.
Cost
cost.total_cost_usd, cost.total_duration_ms, cost.total_api_duration_ms, cost.total_lines_added, cost.total_lines_removedThe cost is an estimate at list price, worked out on your machine, and may differ from your bill; /clear resets it to $0.
Context window
context_window.used_percentage, remaining_percentage, context_window_size, total_input_tokens, total_output_tokens, current_usage, exceeds_200k_tokensThe percentages can be null early in a session and count input tokens only. exceeds_200k_tokens is a fixed 200k threshold whatever the window size.
Plan limits
rate_limits.five_hour, rate_limits.seven_day (each used_percentage, resets_at), rate_limits.spend_limitOnly for Pro, Max and Ultra subscribers, or behind a Claude apps gateway with a spend limit, and only after the first response. resets_at is Unix epoch seconds.
Prompt cache
prompt_cache.warm, hit_ratio, ttl, expires_at, misses, last_miss_cause and othersMain conversation only, from 2.1.251.
Session
session_id, session_name, prompt_id, transcript_path, version, output_style.name, vim.mode, agent.namesession_name appears once you name the session or it has a generated title; vim only with vim mode on.
Pull request
pr.number, pr.url, pr.review_state, pr.kindWhile the branch has an open PR, or a GitLab merge request from 2.1.234 (pr.kind is then mr).
Worktree session
worktree.name, path, branch, original_cwd, original_branchOnly while the session is in a Claude Code worktree session.

The two limit windows are the same numbers /usage shows; what they mean and when they reset is in Claude Code usage limits. To see the full object your own setup produces, make the command cat > /tmp/statusline.json for one message, read the file, and put your script back.

How often it runs

The script runs when a session starts or resumes, then again when a new assistant message arrives, /compact finishes, the permission mode changes, vim mode toggles, the command setting changes, a refreshInterval timer fires, or a rate-limit window or warm prompt cache reaches the time in its data. Updates are debounced at 300 ms, so a burst of events gives one run. If a new update comes while the script is still running, the running one is cancelled.

So the line does not tick on its own while Claude Code sits waiting: a clock, or a git branch that background subagents change, stays stale until the next event unless you set refreshInterval. Edits to the script itself show on the next run; there is nothing to reload. The line also hides while the help menu or a permission prompt is open.

When it shows nothing, or the wrong thing

Claude Code shows the output only after the script exits with code 0. Work down this list:

To see what is going wrong, start Claude Code with debug logging, which records the script’s stderr on every run and its exit code on the first:

claude --debug
Copied

An untrusted folder shows up there as Status line command skipped: workspace trust not accepted.

Values show as empty or --: fields are null until the first response; add // 0 fallbacks. A context figure lower than /context is expected: /context adds an estimate for messages since the last response, which the status line does not.

It lags or stutters: a slow script holds the line until it finishes. git status in a large repository is the usual cause; the docs’ fix is to cache the result in a file named after session_id (not $$, which changes on every run) and refresh it every few seconds.

Wrong width: the script’s output is captured, so tput cols cannot see the terminal; read $COLUMNS and $LINES, which Claude Code sets before each run. On a narrow terminal, notifications sharing the row can cut the line short.

Colours or links missing over SSH or in tmux: the terminal at your end has to support them, and the docs warn that SSH and tmux may strip the OSC sequences links use. Terminal.app does not support clickable links at all. If the text appears but will not click in a terminal that does support links, launch with FORCE_HYPERLINK=1 claude. Running Claude Code in tmux needs other settings too, for keys; the Shift+Enter guide has the tmux lines.

Freezes or memory use: before 2.1.329, a script that printed without ever ending could freeze the prompt and use gigabytes of memory. Releases between 2.1.323 and 2.1.329 also fixed a status line keeping its old width, folder or session name after a resize, /cd or /rename, the line vanishing on Ctrl+C, and a multi-row line pushed off screen by a long prompt in fullscreen mode, so update first if you see any of those. 2.1.323 also removed the subagentStatusLine setting; subagent rows now always use the default look.

Run Claude Code on an always-on developer pod.

A developer pod is a permanent cloud computer (VPS), set up and secured for you, with your pick of Claude Code, Codex, OpenCode, Pi, Hermes and OpenClaw installed. Run more agents at once than your laptop can hold, and keep them working when it’s closed. From $24 a month, built in about ten minutes.