Claude Code

Status line

Configure statusLine, consume session JSON, display cost/context, understand refreshes, Windows support, and caching.

The status line is a custom display at the bottom of Claude Code. It runs a local command, sends session JSON on stdin, and displays stdout.

The script runs locally without model tokens. It can display context usage, model, estimated cost, Git branch, PR state, limits, and output style.

#Quick setup

Ask Claude Code to generate it:

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

Or configure statusLine manually:

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

An inline command also works:

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

#Working script

~/.claude/statusline.sh
#!/bin/bash
input=$(cat)

model=$(echo "$input" | jq -r '.model.display_name // .model.id // "model"')
dir=$(echo "$input" | jq -r '.workspace.current_dir // .cwd')
pct=$(echo "$input" | jq -r '.context_window.used_percentage // 0' | cut -d. -f1)
cost=$(echo "$input" | jq -r '.cost.total_cost_usd // 0')
branch=$(git -C "$dir" branch --show-current 2>/dev/null || true)

printf "[%s] %s" "$model" "${dir##*/}"
[ -n "$branch" ] && printf " · %s" "$branch"
printf " · %s%% context · $%s\n" "$pct" "$cost"

Make it executable:

chmod +x ~/.claude/statusline.sh

#Refresh behavior

TriggerBehavior
New assistant responseRun the script again
Compaction completesUpdate context/cost fields
Permission mode changesRefresh permission-related display
Vim mode changesUpdate vim.mode
refreshIntervalAdditional timed refresh in seconds

Updates are debounced by about 300 ms. A new update cancels an unfinished script. Output can include multiple lines, ANSI colors, and supported OSC 8 links.

Keep the script fast. Network calls, heavy commands, or scanning large repositories on every refresh can make the TUI sluggish.

#Common fields

FieldPurpose
model.id, model.display_nameActive model
workspace.current_dir, cwdCurrent directory
workspace.project_dirLaunch directory
workspace.added_dirsAdded directory access
cost.total_cost_usdClient-estimated cost
context_window.used_percentageContext usage
context_window.current_usage.cache_read_input_tokensLatest cache-read tokens
context_window.current_usage.cache_creation_input_tokensLatest cache-write tokens
rate_limits.five_hour.used_percentageFive-hour usage percentage
session_id, session_nameSession identity/name
prompt_idPrompt UUID for telemetry correlation
output_style.nameCurrent style
agent.nameMain agent chosen by flag/settings
pr.number, pr.review_stateBranch PR information
worktree.name, worktree.branchWorktree session information

#Passion8 use

The status line reads local session data. Useful fields include:

GoalFields
Inspect cache reusecache_read_input_tokens and cache_creation_input_tokens
Decide when to compactcontext_window.used_percentage
Track cost trendscost.total_cost_usd
Distinguish taskssession_name, current_dir, worktree.name

Client estimates may differ from Passion8 billing. The console remains authoritative for balance and charges.

#Windows configuration

PowerShell example:

$HOME\\.claude\\statusline.ps1
$inputJson = [Console]::In.ReadToEnd() | ConvertFrom-Json
$model = $inputJson.model.display_name
$pct = $inputJson.context_window.used_percentage
Write-Output "[$model] $pct% context"

Settings:

~/.claude/settings.json
{
  "statusLine": {
    "type": "command",
    "command": "powershell -ExecutionPolicy Bypass -File \"$HOME\\.claude\\statusline.ps1\""
  }
}

#Cache effects

ActionEffect
Add/edit statusLineDoes not normally change the system prompt or cache
Generate with /statuslineOrdinary model conversation with normal prefix reuse
Refresh scriptLocal execution, no model tokens
Run Git/shell within scriptAffects local performance, not model context

#Official references

Support

Need help?

For setup, billing, or model issues, email us. Check the status page for uptime.

WeChat / QQ support is available at the bottom right.