Claude Code

Claude Code statusline: custom status bar in settings.json with context %, cost and git branch

How do I set up a custom status line in Claude Code?

Run /statusline with a plain English description and Claude Code writes the script and updates your settings for you. To do it by hand, add a statusLine object with type "command" and a command path to ~/.claude/settings.json. Claude Code pipes session JSON to the script on stdin and shows whatever it prints.

Fastest way: the /statusline command

/statusline accepts natural language. It generates a script in ~/.claude/ and updates your settings automatically. Run it with no arguments to auto-configure from your shell prompt.

Inside Claude Code

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

To remove it, run /statusline delete (or clear, or remove), or delete the statusLine field from settings.json.

Manual setup in settings.json

Add statusLine to user settings (~/.claude/settings.json) or project settings. Set type to "command" and point command to a script or an inline shell command.

~/.claude/settings.json

{
  "statusLine": {
    "type": "command",
    "command": "~/.claude/statusline.sh",
    "padding": 2
  }
}
  • padding: optional extra horizontal spacing in characters, default 0
  • refreshInterval: optional, re-runs the command every N seconds on top of event updates, minimum 1. Use it for clocks or data that changes while the session is idle

Inline one-liner with jq

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

Example script: model, folder and context usage

~/.claude/statusline.sh

#!/bin/bash
# Read JSON data that Claude Code sends to stdin
input=$(cat)

MODEL=$(echo "$input" | jq -r '.model.display_name')
DIR=$(echo "$input" | jq -r '.workspace.current_dir')
# The "// 0" provides a fallback if the field is null
PCT=$(echo "$input" | jq -r '.context_window.used_percentage // 0' | cut -d. -f1)

echo "[$MODEL] ${DIR##*/} | ${PCT}% context"

Make it executable

chmod +x ~/.claude/statusline.sh

The script needs jq installed. Claude Code reloads settings automatically and runs the script as soon as you save.

Useful JSON fields

  • model.id, model.display_name: current model
  • workspace.current_dir, workspace.project_dir: working and launch directory
  • cost.total_cost_usd: estimated session cost at list price, resets on /clear
  • cost.total_duration_ms, cost.total_lines_added, cost.total_lines_removed
  • context_window.used_percentage, context_window.remaining_percentage, context_window.context_window_size
  • rate_limits.five_hour.used_percentage, rate_limits.seven_day.used_percentage: only for claude.ai Pro and Max subscribers (or behind a Claude apps gateway with a spend limit), may be absent
  • workspace.git_worktree: present only inside a linked git worktree

Some fields can be null or absent early in a session. Use jq fallbacks such as jq -r '.rate_limits.five_hour.used_percentage // empty'.

When it updates

The script runs at session start, then again when a new assistant message arrives, /compact finishes, the permission mode changes, vim mode toggles, the command setting changes, or a refreshInterval timer fires. Updates are debounced at 300ms, and an in-flight run is cancelled if a new update triggers. The status line runs locally and uses no API tokens.

Sources

More on Claude Code

Other guides

Cursor: allow all terminal commandsClaude Code: allow commands without promptsCodex CLI: approval and sandbox modesGemini CLI: YOLO mode, auto_edit and allowing specific shell commandsCursor Privacy Mode: telemetry, training and data retentionClaude Code telemetry and data retention: what is sent and how to turn it offGemini CLI: turn off usage statistics and telemetryCLAUDE.md: where it goes, how it loads, and how it works with AGENTS.mdClaude Code hooks: format on save, block risky edits, get notifiedClaude Code subagents: create one, limit its tools, and call itAdd MCP servers to Cursor with mcp.json: Keep files out of Cursor with .cursorignore: Configure Codex with config.toml: Configure Gemini CLI with settings.json: Add MCP servers to Claude Code (claude mcp add, .mcp.json, scopes): Claude Code custom slash commands and skills (SKILL.md): GitHub Copilot custom instructions: Adding MCP servers to GitHub Copilot: Claude Code settings.json: file locations, precedence, and key settingsClaude Code plugins and marketplaces: install, create, and shareGemini CLI extensions and custom commands: Configuring OpenCode with opencode.json: Cline Rules: workspace, global, and conditional rulesKiro steering files: .kiro/steering, inclusion modes, and AGENTS.mdZed agent: instruction files, MCP servers, tool permissions, and ACP agentsCursor CLI: install, headless mode, permissions and CIAider: CONVENTIONS.md, .aider.conf.yml and API keysJunie guidelines, MCP and the Action Allowlist: Amp AGENTS.md, settings.json and MCP: Configure Goose extensions, hints, recipes and permissions: Customize OpenHands with skills, AGENTS.md, setup.sh and MCP: Configure Factory Droid CLI: AGENTS.md, settings.json, autonomy, custom droids and MCPConfigure Qwen Code: settings.json, providers, QWEN.md, MCP and approval modesCursor hooks: hooks.json, beforeShellExecution, afterFileEdit and exit codesCursor sandbox: sandbox.json, network allowlist and run modesCursor settings: settings.json, Cursor Settings and the ~/.cursor config filesCursor browser agent: @browser, browser automation and approval modesCursor subagents: .cursor/agents, frontmatter, built-in Explore, Bash and BrowserCursor telemetry and OpenTelemetry export (Privacy Mode, OTLP, Analytics API): Cursor rules setup: .cursor/rules, .mdc frontmatter, globs, alwaysApply and AGENTS.mdClaude Code headless mode: claude -p, --output-format json, --bare and CI flagsClaude Code /model: switch models, aliasesClaude Code /cost and /usage: check token spend, usage limits and reduce costsClaude Code VS Code extension: install, shortcuts, settings and /ideCodex AGENTS.md: global, project and override instruction files explainedCodex MCP servers: codex mcp add and [mcp_servers] in config.tomlCodex sandbox modes: read-only, workspace-write, danger-full-access and network accesscodex exec: run Codex non-interactively in scripts and CI with JSON outputCodex skills: create SKILL.md, skill folder locations and $skill invocationGEMINI.md in Gemini CLI: context file locations, imports and /memoryGemini CLI MCP servers: gemini mcp add and mcpServers in settings.jsonGemini CLI custom slash commands: TOML files, {{args}}, !{shell} and @{file}Gemini CLI headless mode: gemini -p, JSON output and exit codes for scripts and CIGemini CLI sandbox: enable Docker, Podman, macOS Seatbelt or gVisorcopilot-setup-steps.yml: set up the GitHub Copilot cloudGitHub Copilot CLI permissions: --allow-tool, --deny-tool, --allow-all-tools and trusted directoriesGitHub Copilot custom agents: .github/agents/*.agent.md profiles, tools and frontmatterGitHub Copilot code review settings: automatic PR reviews, rulesets, effort level and approvals

Get the weekly agent stack update

New official MCP servers, spec changes and harness releases, checked against the source. One email a week, no fluff.

Reviewed Oct 13, 2026. Settings change often; the linked vendor docs are the source of truth.