Stay Updated!

Get the latest posts and insights delivered directly to your inbox

Skip to content

How to Customize Your Claude Code Status Line

Published: at 

Ever glanced at Claude Code and wondered which model you’re actually using? Or how much of the context window you’ve burned through? By default, this information is hidden away—but you can surface it right in your terminal.

A custom status line shows you what matters at a glance:

[Opus] Context: 12%

This tells you the active model and context usage without interrupting your flow. Let me show you how to set it up.

How the status line works#

Claude Code pipes JSON data to your status line script via stdin. Your script processes that data and outputs whatever text you want displayed.

JSON via stdin

Formatted text

Claude Code

Your Script

Terminal Status Line

The JSON contains everything you’d want to know: model info, token counts, costs, and workspace details.

Step 1: Create the status line script#

Create a new file at ~/.claude/statusline.sh:

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

MODEL=$(echo "$input" | jq -r '.model.display_name')
INPUT_TOKENS=$(echo "$input" | jq -r '.context_window.total_input_tokens')
OUTPUT_TOKENS=$(echo "$input" | jq -r '.context_window.total_output_tokens')
CONTEXT_SIZE=$(echo "$input" | jq -r '.context_window.context_window_size')

TOTAL_TOKENS=$((INPUT_TOKENS + OUTPUT_TOKENS))
PERCENT_USED=$((TOTAL_TOKENS * 100 / CONTEXT_SIZE))

echo "[$MODEL] Context: ${PERCENT_USED}%"

The script reads JSON from stdin, extracts the fields we care about using jq, calculates the percentage, and outputs the formatted string.

Step 2: Make it executable#

chmod +x ~/.claude/statusline.sh

Step 3: Configure Claude Code#

Add the status line configuration to ~/.claude/settings.json:

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

If you already have settings in this file, add the statusLine block alongside your existing configuration.

Step 4: Restart Claude Code#

Close and reopen Claude Code. Your new status line should appear.

Available variables#

The script receives JSON with these fields:

VariableDescription
model.idFull model ID (e.g., claude-opus-4-5-20251101)
model.display_nameShort name (e.g., Opus)
context_window.total_input_tokensInput tokens used
context_window.total_output_tokensOutput tokens used
context_window.context_window_sizeMax context size
cost.total_cost_usdSession cost in USD
cost.total_duration_msTotal duration
workspace.current_dirCurrent directory

Adding cost tracking#

Want to see how much your session is costing? Extend the script:

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

MODEL=$(echo "$input" | jq -r '.model.display_name')
INPUT_TOKENS=$(echo "$input" | jq -r '.context_window.total_input_tokens')
OUTPUT_TOKENS=$(echo "$input" | jq -r '.context_window.total_output_tokens')
CONTEXT_SIZE=$(echo "$input" | jq -r '.context_window.context_window_size')
COST=$(echo "$input" | jq -r '.cost.total_cost_usd')

TOTAL_TOKENS=$((INPUT_TOKENS + OUTPUT_TOKENS))
PERCENT_USED=$((TOTAL_TOKENS * 100 / CONTEXT_SIZE))

printf "[%s] Context: %d%% | $%.2f" "$MODEL" "$PERCENT_USED" "$COST"

Now you’ll see something like: [Opus] Context: 12% | $0.45

Troubleshooting#

Status line not showing?

  1. Check that jq is installed: brew install jq (macOS) or apt install jq (Linux)
  2. Verify the script is executable: ls -la ~/.claude/statusline.sh
  3. Restart Claude Code after making changes

Test your script manually:

echo '{"model":{"display_name":"Opus"},"context_window":{"total_input_tokens":1000,"total_output_tokens":500,"context_window_size":200000}}' | ~/.claude/statusline.sh

Should output: [Opus] Context: 0%

💡 Dependencies

The status line script requires jq for JSON parsing. If you don’t have it installed, the script will fail silently.

Taking it further#

The status line is one piece of the Claude Code customization puzzle. Once you’re comfortable with scripts like this, explore:

The status line script pattern—reading JSON from stdin and outputting formatted text—is the same foundation that powers many of Claude Code’s extensibility features.

Press Esc or click outside to close

Stay Updated!

Subscribe to my newsletter for more TypeScript, Vue, and web dev insights directly in your inbox.

  • Background information about the articles
  • Weekly Summary of all the interesting blog posts that I read
  • Small tips and trick
Subscribe Now