Skip to content

DFKHelper/claude-code-statusline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

claude-code-statusline

A status bar for Claude Code that shows what you actually need mid-session.


Claude Code status bar showing: Sonnet 4.6 | 122K tokens | 61% context used | moon OFF-PK (16h 49m) | Projects directory

License: MIT — open source Requires Node.js 18 or higher Supported platforms: macOS, Linux, Windows Compatible with Claude Code


What it shows

Segment Meaning Color
Sonnet 4.6 Active model Magenta
122K Total input tokens this session Cyan
61% Context window used Green → yellow → orange → red
AC!! Auto-compact imminent (≤ 20% remaining) Yellow → orange → red
🌙 OFF-PK / PEAK Anthropic API peak hours (5–11 AM Pacific, Mon–Fri) Green (off-peak) / yellow (peak)
my-project Working directory (last path segment) Orange

The peak/off-peak indicator includes a live countdown to the next state change — useful if you're deciding whether to start a heavy session now or wait.


Installation

Prerequisites: Node.js (18+) and Claude Code.

  1. Copy statusline.js to ~/.claude/:
curl -o ~/.claude/statusline.js \
  https://raw.githubusercontent.com/DFKHelper/claude-code-statusline/main/statusline.js
  1. Add the statusLine key to ~/.claude/settings.json:
macOS / Linux
{
  "statusLine": {
    "type": "command",
    "command": "node /home/your-username/.claude/statusline.js"
  }
}
Windows
{
  "statusLine": {
    "type": "command",
    "command": "node C:/Users/your-username/.claude/statusline.js"
  }
}
  1. Restart Claude Code. The status bar updates on every turn.

Customization

The script is a single self-contained Node.js file (~100 lines). No build step, no dependencies.

Change peak hours or timezone

Find the isPeak assignment and edit the hour bounds or the timezone string:

// Change 5 and 11 to your preferred window, or swap the timezone
const isPeak = isWeekday && ptHour >= 5 && ptHour < 11;
// timeZone: 'America/Los_Angeles'  � change this
Adjust context color thresholds
if (used >= 95)      color = '\x1b[1;31m';       // red
else if (used >= 80) color = '\x1b[38;5;208m';   // orange
else if (used >= 60) color = '\x1b[1;33m';        // yellow
else                 color = '\x1b[0;32m';         // green

Change 95, 80, 60 to whatever breakpoints suit your workflow.

Remove a segment

Comment out the matching parts.push(...) call near the bottom of the file.


Debugging

statusline-debug.js captures the raw JSON payload Claude Code pipes to the command and writes it to disk — handy when building your own status line.

  1. Temporarily point settings.json at the debug script:
{
  "statusLine": {
    "type": "command",
    "command": "node /home/your-username/.claude/statusline-debug.js"
  }
}
  1. Run Claude Code for one turn. The status bar shows DEBUG: wrote ....

  2. Open the output file (default: ~/statusline-capture.json). Override the path with STATUSLINE_DEBUG_PATH.

example-input.json in this repo shows a sanitized example of the full payload schema, so you can build against it without running a live session.


How it works

Claude Code pipes a JSON payload to the status line command via stdin on every turn. The script parses the context window metrics and model info, builds an ANSI-colored string, and writes it to stdout. Claude Code renders that string in the status bar.

Claude Code  ──stdin──▶  node statusline.js  ──stdout──▶  status bar
               JSON                              ANSI string

The 3-second setTimeout exits the process if stdin never closes — without it, Node processes stack up across long sessions.


License

MIT

About

Custom Claude Code status line — model, token count, context usage with color tiers, auto-compact warning, API peak hours, and working directory

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors