Last updated: · Applies to: Claude Code terminal status line

Claude Code statusline: setup, examples and blank-line fixes

Configure the Claude Code statusline with /statusline and a description, or add a statusLine command to your settings. The command reads JSON session data from stdin and prints the display to stdout. Start with the official status line documentation and its examples.

What is the Claude Code status line?

The status line is a customizable bar at the bottom of Claude Code, driven by a shell command you configure.

It can show context usage, cost, session identity and git state. It renders above the built-in footer badges and leaves those badges in place, while hiding most footer keyboard hints. Running the configured status line is local and consumes no API tokens; it can temporarily disappear during help menus or permission prompts. Source: how status lines work.

How do I configure statusline?

Run /statusline with a description to generate a script in ~/.claude/ and update your settings automatically.

/statusline show model name and context percentage with a progress bar

This setup request is from the official walkthrough. Approve any file edit prompts during setup. For manual configuration, add this field to ~/.claude/settings.json or your project settings:

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

The command can be a script path or an inline shell command. For example, the official docs provide this exact jq configuration:

{
  "statusLine": {
    "type": "command",
    "command": "jq -r '\"[\\(.model.display_name)] \\(.context_window.used_percentage // 0)% context\"'"
  }
}

jq must be available for these jq examples. padding defaults to 0; refreshInterval optionally reruns the command every N seconds, with a minimum of 1; hideVimModeIndicator can hide the built-in Vim mode label when your script displays it. See the settings reference for the options and settings scopes for file locations.

To disable it, ask /statusline to delete, clear or remove the status line, or delete the statusLine field.

Which JSON fields are useful?

The session JSON includes model, workspace, cost, context and session identifiers for your script to read.

Official fieldUse
model.display_nameDisplay the current model name.
workspace.current_dirShow the current working directory.
workspace.project_dirShow the directory where the session started.
cost.total_cost_usdDisplay estimated session cost in USD; it may differ from actual billing.
context_window.used_percentageShow input context usage from the latest API response.
session_idDistinguish sessions.

Fields can be null before the first API response. Use fallbacks such as // 0 in jq. See the full official JSON schema rather than assuming other field names.

Is there an official context-bar example?

Yes: the official status line docs include this Bash context-percentage bar.

Save it as ~/.claude/statusline.sh and use the script-path settings above. This is the docs’ Bash example, not a community template:

#!/bin/bash
# Read all of stdin into a variable
input=$(cat)

# Extract fields with jq, "// 0" provides fallback for null
MODEL=$(echo "$input" | jq -r '.model.display_name')
PCT=$(echo "$input" | jq -r '.context_window.used_percentage // 0' | cut -d. -f1)

# Build progress bar: printf -v creates a run of spaces, then
# ${var// /▓} replaces each space with a block character
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%"

On macOS or Linux, make the script executable:

chmod +x ~/.claude/statusline.sh

The docs also supply colored git status, multiline output and caching examples, plus Windows configuration.

When does the status line update?

The command runs on session start or resume and on documented session events.

Those events include a new assistant message, completed /compact, permission or Vim mode changes, a changed status-line command, a configured refresh timer, and rate-limit reset or prompt-cache expiry times from the last received data. Updates are debounced by 300 ms; changing the command runs it immediately. Set refreshInterval if time-based or external data needs updates during idle periods.

Output can span multiple lines and use ANSI colors or OSC 8 links. Read COLUMNS and LINES to size the display; the docs advise against tput cols. See update and output behavior.

How do I fix a blank or broken status line?

Check script execution, output, workspace trust and settings policy first when the status line is blank.

  • Nothing appears: make the script executable, run it manually, and verify it writes to stdout rather than stderr. On Windows with Git Bash, use forward slashes in the command path.
  • Workspace not trusted: restart Claude Code and accept the workspace trust dialog. The status-line shell command does not run before workspace trust is accepted.
  • Hooks policy blocks it: disableAllHooks set outside managed settings allows only a managed statusLine. When disableAllHooks is set in managed settings, it disables the status line entirely. Organization policy allowManagedHooksOnly also restricts status lines to managed settings; ask your administrator whether it applies.
  • Script errors or hangs: output appears only after an exit code of 0. Nonzero exits or no output leave it blank. Keep scripts fast; another update can cancel an unfinished run. Use claude --debug to inspect stderr and the first invocation’s exit code.
  • -- or empty values: handle null fields before the first response; restart if they stay empty after multiple messages.
  • Context differs from /context: the status line uses the last API response, while /context adds estimates for newer messages.
  • Links or colors break: OSC 8 requires terminal support and can be stripped by SSH or tmux. Check the official hyperlink guidance; simplify to plain text if escape sequences garble the output.

These checks come from the official troubleshooting section.

FAQ

Does the Claude Code statusline use API tokens?

Running the configured status line is local and does not consume API tokens.

Why is my status line blank?

Check that the script is executable, writes to stdout and exits with code 0. Workspace trust and managed hooks policies can also prevent it from running.

Why is the context percentage different from /context?

The status line uses the last API response. /context also estimates messages added since that response, so it can show a higher value until the next response.

How do I remove the status line?

Ask /statusline to delete, clear or remove it, or delete the statusLine field from settings.json.

Sources

All setup examples and troubleshooting steps above come from Anthropic’s documentation.

This is an independent, unofficial guide. It is not affiliated with or endorsed by Anthropic. Check the linked official documentation for your version and environment.