<h1 align="center">
<a href="https://prompts.chat">
> **Real-time context window monitoring for Claude Code** – Know exactly how much context you have left before you hit the limit.
Sign in to like and favorite skills
Real-time context window monitoring for Claude Code – Know exactly how much context you have left before you hit the limit.
A lightweight, accurate statusline module that displays your current context usage in Claude Code, helping you manage long conversations and avoid unexpected context limits.
When working with Claude Code on complex projects, you might not realize you're running out of context until it's too late. This statusline gives you instant visibility into your context usage, displayed right at the bottom of your terminal.
Problems this solves:
/compact to free up spaceWhat you get:
/compact/context command exactly (more accurate than Claude's built-in indicator)Sonnet 4.5 | [█████░░░░░░░░░░░░░┃░] 25.3% used | 74.7% free session: 93e6f36e-be31-4466-956e-3279f6ad7790 ↑ auto-compact at 95%
Features:
Color coding:
Save the
context-statusline.js file to your Claude configuration directory:
# Download to ~/.claude/ curl -o ~/.claude/context-statusline.js https://gitlab.com/second-factory-tools/claude-code-context-statusline/-/raw/main/context-statusline.js # Make it executable chmod +x ~/.claude/context-statusline.js
Add the statusline configuration to your
~/.claude/settings.json:
{ "statusLine": { "type": "command", "command": "~/.claude/context-statusline.js", "padding": 0 } }
If you already have other settings, just add the
statusLine section:
{ "alwaysThinkingEnabled": true, "statusLine": { "type": "command", "command": "~/.claude/context-statusline.js", "padding": 0 } }
The statusline will appear automatically. If it doesn't show up immediately, try starting a new conversation.
Sonnet 4.5 | [███░░░░░░░░░░░░░░┃░] 15.2% used | 84.8% free
Green bar - you're early in a session. Yellow ┃ shows auto-compact threshold at 95%.
Sonnet 4.5 | [██████████████░░░┃░] 73.5% used | 26.5% free
Yellow warning - bar changes color, getting closer to the threshold.
Sonnet 4.5 | [█████████████████┃░] 91.0% used | 9.0% free
Red alert - threshold indicator FLASHES! Auto-compact will trigger at 95%.
Sonnet 4.5 | [███░░░░░░░░░░░░░░┃░] 18.3% used | 81.7% free
Back to green - context automatically reset after Claude's auto-compact!
The script:
/compact commands and resets trackingTechnical details:
cache_read_input_tokens, input_tokens, and output_tokensOur calculations match Claude's official
command exactly. You may notice Claude Code's built-in context indicator (bottom-right of terminal) sometimes shows different percentages - this appears to be a calculation inconsistency in Claude Code itself. Always trust /context
/context and our statusline for accurate numbers.
To verify: Run
/context and compare the percentages - you'll see our tool matches the official output perfectly.
Understanding the auto-compact indicator:
┃ line marks the 95% threshold - a critical warning pointNote: The statusline cannot detect if auto-compact is enabled, so the indicator always shows. This is intentional - it provides valuable context management guidance whether you rely on auto-compact or prefer manual control. You can disable the indicator by setting
SHOW_AUTO_COMPACT_INDICATOR = false in the script if you don't find it useful.
When to manually compact:
Tips:
/compact between major tasks or featuresWant to modify the display? The script is well-commented and easy to customize:
// Change the context window size (default: 200,000) const CONTEXT_WINDOW = 200_000; // Adjust progress bar width const PROGRESS_BAR_WIDTH = 20; // Number of segments // Toggle progress bar on/off const SHOW_PROGRESS_BAR = true; // Set to false for text-only mode // Auto-compact threshold (Claude defaults to 95%) const AUTO_COMPACT_THRESHOLD = 95; // Show/hide the auto-compact indicator const SHOW_AUTO_COMPACT_INDICATOR = true; // Customize color thresholds function color(p) { if (p >= 90) return "\x1b[31m"; // red if (p >= 70) return "\x1b[33m"; // yellow return "\x1b[32m"; // green }
Display modes:
[████░░░░░░┃░] 25.3% used | 74.7% freeSHOW_AUTO_COMPACT_INDICATOR = falseSHOW_PROGRESS_BAR = falseFound a bug? Have an idea for improvement?
MIT License - feel free to use, modify, and share!
Created by the Claude Code community. Special thanks to all contributors who helped refine the accuracy and user experience.
Pro tip: Combine this with the built-in
/context command for detailed breakdowns of where your tokens are going (system prompt, tools, memory files, messages).