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.

50 installs

Before you install

  • This version was reviewed before it was listed on Jun 29, 2026
  • Doesn't ask to connect to the internet
  • Needs git for the branch. The ◷ time is kept in claude-status-line-state.json in your temp folder.
  • Bar color follows raw tokens (yellow at 60K, orange at 80K), so the 1M preview is orange at 66%.
  • Percentages read higher than Claude Code's own (22% shows as 26%) and stop at 100%, as in 182K/167K.
Not showing after you paste? Fix it

Preview

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

In Claude Desktop

Color-Coded Context in Claude Desktop

Recorded with statusline-anywhere.

What it does

Model, project, branch, last-activity time and a 10-cell context bar measured against the usable window, plus 5-hour and 7-day rate limits with reset countdowns.

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

How it works

  1. Reads the model, cwd, context window size, used percentage and both rate limits
  2. Turns usage into tokens and measures it against the window minus a 33K autocompact buffer
  3. Runs git branch --show-current and remembers when the token count last changed
  4. Branch drops outside a repo; each rate-limit part shows only when Claude Code sends it

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://statuslin.es/badge/c/color-coded-context-a73a8105.svg)](https://statuslin.es/c/color-coded-context-a73a8105?utm_source=readme-badge)

Or show the preview card:

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

More status lines

  • 15 installs
Op 4.8 │ app (main) │ █░░░░ 44k/200k │ cache 5% ↓2k +5k │ 5h:26%(2h7m) │ 7d:7%(2d)
[Opus 5.5] 📁 app | 🌿 main | $0.41 | ⏱️ 10m 12s ❤️❤️❤️❤️❤️❤️❤️🖤🖤🖤 26% 2h6m 🍗🍗🍗🍗🍗🍗🍗🍗🍗🦴 7% 2d0h 🟩🟩🟩🟩🟩⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛ 22%
Opus 4.8 · high · app (main) · ctx 44k · 5h 26% · 7d 7% · $0.41
◆ Opus 4.8 │ ▪ app │ ⎇ main │ ◷ 14:04 │ ██▄░░░░░░░ 26% (44K/167K) │ 26% ↻2h6m │ 7% ⟳2d0h
​ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ ▐ Opus 4.8 ▌ ▐ high ▌ ▐ …/user/app ▌ ▐ main ▌ ▐ 22% / 200k ━━━━━━━━━━ ▌ ▐ 26% ━━━━━━━━━━ 16:10 ▌ ▐ +128 −34 ▌ ▐ $0.41 ▌ ▐ 10m 12s ▌ │ │ MODEL EFFORT PATH BRANCH CONTEXT USAGE DIFF COST TIME │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ​
┌─────────────────────────────────────────────────────────────────────────────────┬────────────────────────────────┐ │ session summary session b8e1c0d2 │ │ ├──────────────────────────┬──────────────────────────────────────────────────────┤ │ │ 📁 user/app +0 -0 lines │ Opus 5.5 effort high · 0min │ │ │ app main │ cost $0.00 (all time) · $0.00 (this session) │ │ ├──────────────────────────┴──────────────────────────────────────────────────────┤ │ │ tokens 0 (all time) · 0 (this session) context ██░░░░░░░░ 22% compact 0 times │ │ ├─────────────────────────────────────────────────────────────────────────────────┤ │ │ 5h-quota ███░░░░░░░ 26% resets 2h6m 7d-quota █░░░░░░░░░ 7% resets 2d0h │ │ └─────────────────────────────────────────────────────────────────────────────────┴────────────────────────────────┘

Related mods

Token Weather Usage in Claude Desktop

One line above the prompt: context tokens with their weather, a bar per recent prompt, your 5-hour and 7-day limits against the time elapsed, the prompt cache with its time left, the session cost with the last prompt's share in dollars and in points of the 5-hour limit, the subagents running, and a one-click pill for the GOs Claude proposes. Labels in English, French or Russian. After Token Weather (Anthropic, Apache-2.0) and the ideas of usage-meter (HolyGrail) and prompt-cache-control (Daniel San).

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