VOOZH about

URL: https://alexop.dev/posts/customize_claude_code_status_line/

⇱ How to Customize Your Claude Code Status Line | alexop.dev


Next Talk: Automating Web Development with Claude Code

July 1, 2026 — DWX Developer World, Mannheim

Conference

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.

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:

  • Notification hooksClaude Code Notifications: Get Alerts When Tasks Finish (Hooks Setup)How to set up Claude Code notifications using hooks. Get desktop alerts when Claude finishes a task, needs your input, or requests permission, instead of watching the terminal.claude-codenotificationshooks+1 to get desktop alerts when Claude needs input
  • Slash commandsClaude Code Slash Commands: A Complete Guide (2026)Learn how to transform Claude Code from a chatbot into a deterministic engine using Slash Commands. This guide covers the technical setup and a complete 'Full Circle' workflow that automates your entire feature lifecycle.aiclaude-code to automate repetitive tasks
  • The full Claude Code feature stackClaude Code Explained (2026): MCP, Skills, Subagents, Hooks & PluginsA practical guide to Claude Code's features: MCP, CLAUDE.md, slash commands, subagents, hooks, plugins, skills, and scheduled tasks. Updated April 2026 with deferred tool loading, worktree isolation, agent teams, and more.claude-codeaimcp+2 for MCP, skills, and subagents

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.

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
Share this post on:
Share this post via WhatsAppShare this post on FacebookTweet this postShare this post via TelegramShare this post on PinterestShare this post via emailShare this post on LinkedIn