Resources>Developer Tools

Claude Code Statusline

Add a persistent context usage bar, model name, and session cost to your Claude Code terminal

Last updated March 6, 2026

What it does

A shell script that adds a persistent status bar to your Claude Code CLI, showing three things at a glance:

  1. Model name — the current model (e.g. "Opus 4.6") in bold
  2. Context usage bar — a 20-character progress bar showing how much of your context window you've used
  3. Session cost — running USD total for the current session

Gray statusline at 20% usage Orange statusline at 63% usage Red statusline at 95% usage

Install

One command:

curl -sL https://gist.githubusercontent.com/thfrench/3c1470f7dcabfcf5b455d2f693d1b812/raw/install.sh | bash

This downloads the script to ~/.claude/statusline.sh and adds the statusLine setting to your Claude Code config.

What each element shows

The status bar renders in your terminal as a single line with three components:

  • Model — shown in bold, extracted from the Claude Code session data
  • Context bar[==========..........] style, 20 characters wide, filling up as you use context
  • Cost — cumulative session spend in USD

Autocompact-aware scaling

This is the key feature. Claude Code has autocompact enabled by default — when your context reaches ~84% of the window, it automatically compacts the conversation to free up space.

The script detects whether autocompact is enabled by checking:

  • autoCompact in ~/.claude/settings.json
  • autoCompact in ~/.claude/settings.local.json
  • Project-level .claude/settings.json and .claude/settings.local.json
  • The CLAUDE_AUTOCOMPACT_PCT_OVERRIDE environment variable

When autocompact is on (the default), the progress bar scales to the compaction threshold (~84%) rather than the full context window. This means the bar represents your actual usable space before compaction triggers, not the theoretical 200K max.

When autocompact is off, the bar scales to the full 100%.

Colour coding

Colours are based on effective usage after scaling:

  • Gray — under 60% of the effective ceiling. Plenty of room.
  • Orange — 60-84%. Getting warm.
  • Red — 85%+. Compaction is imminent (or you're hitting the context limit if autocompact is off).

Compaction tracking

The script writes the last-seen percentage to a temp file (/tmp/claude-statusline-*). If the percentage drops by more than 20 points between updates, it counts that as a compaction event and displays a counter: (x1), (x2), etc.

This lets you see at a glance how many times your conversation has been compacted in the current session.

Customisation

The script lives at ~/.claude/statusline.sh. Edit it directly to change:

  • Bar width or characters
  • Colour thresholds
  • What information is displayed
  • Compaction detection sensitivity

Uninstall

Remove the statusLine entry from your ~/.claude/settings.json:

{
  "statusLine": "~/.claude/statusline.sh"
}

Delete that line (or the whole key), then remove the script:

rm ~/.claude/statusline.sh

About Claude Code's statusLine feature

Claude Code supports a statusLine setting that points to a shell script. The script is executed periodically and its stdout is rendered as a persistent status bar in the terminal. This is the same mechanism used here — the script simply reads Claude Code's own session data and formats it for display.

Tagged with

claude-codeterminalproductivity