Color-Coded Context

Node status line with an autocompact-aware context bar (subtracts the compaction buffer), project, branch, last-activity time, and 5h/7d rate-limit segments. Source: github.com/philipshurpik/claude-code-status-line

Before you install

  • This version was reviewed before it was listed on Jun 29, 2026
  • Doesn't ask to connect to the internet
  • Calls git for the branch and leaves the branch out in a folder that is not a repo.
  • Writes claude-status-line-state.json to your temp folder on every run.
  • Near a full context the bar can read 100% with more tokens than the limit, such as 182K/167K.
Not showing after you paste? Fix it

Preview

Clean repo
◆ Opus 4.8 │ ▪ app │ ⎇ main │ ◷ 13:32 │ ██▄░░░░░░░ 26% (44K/167K) │ 26% ↻2h6m │ 7% ⟳2d0h
New session
◆ Opus 4.8 │ ▪ app │ ⎇ main │ ◷ 13:32 │ ░░░░░░░░░░ 0% (0K/167K)
Dirty branch
◆ Sonnet 4.6 │ ▪ app │ ⎇ feat/auth │ ◷ 13:33 │ █████▄░░░░ 57% (96K/167K) │ 40% ↻1h11m │ 18% ⟳2d21h
Near-full
◆ Opus 4.8 │ ▪ app │ ⎇ main │ ◷ 13:33 │ ██████████ 100% (182K/167K) │ 88% ↻17m │ 61% ⟳19h59m
1M context
◆ Fable 5 │ ▪ app │ ⎇ main │ ◷ 13:33 │ ██████▄░░░ 66% (640K/967K) │ 33% ↻3h29m │ 80% ⟳4d23h
Post-compact
◆ Haiku 4.5 │ ▪ app │ ⎇ main │ ◷ 13:33 │ ░░░░░░░░░░ 0% (0K/167K) │ 52% ↻4h1m
Worktree
◆ Opus 4.8 │ ▪ feature │ ⎇ worktree-feature │ ◷ 13:33 │ ████▄░░░░░ 44% (74K/167K) │ 44% ↻2h49m │ 20% ⟳1d6h
Non-git
◆ Opus 4.8 │ ▪ scratch │ ◷ 13:33 │ ██▄░░░░░░░ 26% (44K/167K)

In Claude Desktop

Color-Coded Context in Claude Desktop

Recorded with statusline-anywhere.

What it does

One line with model, project, branch, the time of last activity, a context bar sized to the room left before auto-compact, and 5-hour and 7-day rate limits.

Written in
Node.js
Network access
None requested
Works in
Terminal

How it works

  1. Subtracts a 33K auto-compact buffer from the window, so a 200K window counts as 167K.
  2. Turns the bar yellow at 60K tokens used and orange at 80K, whatever the window size.
  3. Saves the token count to a temp file and shows ◷ the time it last changed.
  4. Adds 5h ↻ and 7d ⟳ usage with countdowns once Claude Code reports them.

Source

#!/usr/bin/env node

const path = require('path');
const fs = require('fs');
const os = require('os');
const { execSync } = require('child_process');

const STATE_FILE = path.join(os.tmpdir(), 'claude-status-line-state.json');
const AUTOCOMPACT_BUFFER_TOKENS = 33_000;
const WARN_TOKENS = 60_000;
const COMPACT_TOKENS = 80_000;

const RST = '\x1b[0m';
const DIM = '\x1b[38;5;238m';
const MUTED = '\x1b[38;5;245m';

function formatDuration(epoch) {
  if (!epoch) return '';
  const diff = Math.max(0, Math.round(epoch - Date.now() / 1000));
  if (diff <= 0) return 'now';
  if (diff < 60) return '<1m';
  const d = Math.floor(diff / 86400);
  const h = Math.floor((diff % 86400) / 3600);
  const m = Math.floor((diff % 3600) / 60);
  if (d > 0) return `${d}d${h}h`;
  return h > 0 ? `${h}h${m}m` : `${m}m`;
}

function rateLimitColor(pct) {
  return pct > 80 ? '\x1b[31m' : pct > 50 ? '\x1b[33m' : '\x1b[32m';
}

function formatRateLimit(rl, icon) {
  if (rl?.used_percentage == null) return '';
  const pct = Math.round(rl.used_percentage);
  const reset = formatDuration(rl.resets_at);
  let part = ` │ ${rateLimitColor(pct)}${pct}%${RST}`;
  if (reset) part += ` ${MUTED}${icon}${reset}${RST}`;
  return part;
}

let input = '';
process.stdin.setEncoding('utf8');
process.stdin.on('data', (chunk) => { input += chunk; });
process.stdin.on('end', () => {
  try {
    const data = JSON.parse(input);
    const ctx = data.context_window || {};
    const model = data.model || {};
    const cwd = data.cwd || '';

    const windowSize = ctx.context_window_size ?? 200000;
    const effectiveWindow = windowSize - AUTOCOMPACT_BUFFER_TOKENS;
    const rawUsedPct = ctx.used_percentage ?? 0;
    const tokensUsed = Math.round((rawUsedPct / 100) * windowSize);
    const usedPct = Math.min(100, Math.round((tokensUsed / effectiveWindow) * 100));
    const level = tokensUsed >= COMPACT_TOKENS ? 'danger' : tokensUsed >= WARN_TOKENS ? 'warn' : 'ok';
    const color = level === 'danger' ? '\x1b[38;5;208m' : level === 'warn' ? '\x1b[33m' : '\x1b[32m';

    const project = cwd ? path.basename(cwd) : '';
    let branch = '';
    if (cwd) {
      try {
        branch = execSync('git --no-optional-locks branch --show-current',
          { cwd, encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] }).trim().slice(0, 30);
      } catch { /* not a git repo */ }
    }

    const bar = Array.from({ length: 10 }, (_, i) => {
      const filled = usedPct - i * 10;
      const char = filled >= 8 ? '█' : filled >= 3 ? '▄' : null;
      return char ? `${color}${char}${RST}` : `${DIM}░${RST}`;
    }).join('');

    let lastCallMs;
    try {
      const prev = JSON.parse(fs.readFileSync(STATE_FILE, 'utf8'));
      lastCallMs = prev.tokensUsed === tokensUsed ? prev.timestamp : Date.now();
    } catch { lastCallMs = Date.now(); }
    fs.writeFileSync(STATE_FILE, JSON.stringify({ tokensUsed, timestamp: lastCallMs }));
    const last = new Date(lastCallMs);
    const time = `${String(last.getHours()).padStart(2, '0')}:${String(last.getMinutes()).padStart(2, '0')}`;
    const tokensK = (tokensUsed / 1000).toFixed(0);
    const windowK = (effectiveWindow / 1000).toFixed(0);

    let output = `◆ ${(model.display_name ?? 'Claude').replace(/\(1M context\)/, '1M').trim()}`;
    if (project) output += ` │ ▪ ${project}`;
    if (branch) output += ` │ ⎇ ${branch}`;
    output += ` │ ◷ ${time}`;
    output += ` │ ${bar} ${usedPct}% (${tokensK}K/${windowK}K)`;

    const rateLimits = data.rate_limits || {};
    output += formatRateLimit(rateLimits.five_hour, '↻');
    output += formatRateLimit(rateLimits.seven_day, '⟳');

    process.stdout.write(output);
  } catch {
    process.stdout.write('Ctx: --');
  }
});

Badge for your README

Own this listing? Add it to your README. The badge shows the install count as it grows.

Reviewed on statuslin.es
[![Reviewed on statuslin.es](https://staging.statuslin.es/badge/c/color-coded-context-859f0b81.svg)](https://staging.statuslin.es/c/color-coded-context-859f0b81?utm_source=readme-badge)

Or show the preview card:

Preview on statuslin.es
[![Preview on statuslin.es](https://staging.statuslin.es/og/c/color-coded-context-859f0b81.png)](https://staging.statuslin.es/c/color-coded-context-859f0b81?utm_source=readme-badge)

More status lines

Opus 4.8 high ✦ │ ctx 22% │ app (main) │ PR #1287 ● │ $0.41 · 10m +128 -34 Session ● ● ● ● ● ● ● ● ○ ○ ○ 74% left Resets in 2h 6m Weekly ● ● ● ● ● ● ● ● ● ● ○ 93% left Resets in 2d 0h
✧ ███████████▋ 73% 🗝 Ultima Weapon ✦ app ∙ main ♥ ████████████████████████ 100% 「SAVE POINT」 ✶ Limit Form ◉ 41
🤖 Opus 4.8 [200K] │ 🎯 high │ 📁 app │ 🌿 main 📅 07/07/26 Tue │ ⏰ 22:59:15 │ ₿$63k │ ☀️ +90°F Ctx: ● ▓▓░░░░ 33% [66K/200K] │ ⏱ 10m │ 🔧 2.1.155
Opus 4.8 │ ✍️ 78% │ app (main) │ +128/-34 Cost $0.4100 Tokens in 44.0k │ cache write 5000 │ cache read 2000 │ out 1.4k

Related mods

Deck in Claude Desktop

A cockpit for Claude Code: plan bars and subagent strips, context, usage limits with reset countdowns and burn rates, spend, the model route and a pet. Six bar styles, three collapsed looks. CLI and Desktop.

Flightdeck in Claude Desktop

Flightdeck: a live agent dashboard for Claude Code. Main model vitals, an on-call architect, every permission check, subagent cards and swimlanes, a turn receipt and a session log, all from real session events

▀▄ ▄▀ [-] ▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀ ▀▄ ▄▀▀▀▀▀▀▀ ▀▀▀▄▄▄ ▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀ ctx 22% [ Pet ♥ ] [ ⚙ ] [ ↻ Adventurer ] [ Hide ]

A little pixel cat that wanders above the Claude Code prompt, watches your usage limits and announces when work finishes; or switch packs for an adventurer who mines, chops trees and fights zombies