Claude Code Status Line
A configurable status line binary for Claude Code that shows workspace info: current working directory, git branch, model name, context usage (integer percentage showing how close to auto-compact, optionally with decimal precision), quota limits (5h/7d as whole numbers) with reset timers, and optional API cost—all with per-section color customization, powerline arrows, and width-aware trimming.
Features
- Powerline-style arrows with per-section color customization (bg, fg, muted) for each section.
- Fallback to classic pipe separator for terminals without powerline font support.
- Sections: current directory, git branch + dirty indicator, model name, context usage, quota (5h/7d), optional session cost.
- Width-aware rendering: drops lower-priority sections when the terminal is narrow; quota timers drop before quota percentages.
- Terminal width detection with fallbacks (supports
CLAUDE_TERMINAL_WIDTHandCOLUMNS). - Cross-platform: macOS keychain via
security; other platforms via thekeyringcrate; also supportsCLAUDE_OAUTH_TOKEN.
Example output
Powerline style (default, requires powerline-compatible font):
~/projects/statusline (main)* Sonnet 4.5 ctx: 71% 5h: 12% (2h 30m) 7d: 5% (4d 12h)
Each section can have its own background color with smooth arrow transitions.
Classic pipe separator (fallback, set USE_POWERLINE = false):
~/projects/statusline | (main) * | Sonnet 4.5 | ctx: 71% | 5h: 12% (2h 30m) | 7d: 5% (4d 12h)
Medium terminal (timers dropped first):
~/projects/statusline (main)* Sonnet 4.5 ctx: 71% 5h: 12% 7d: 5%
Narrow terminal (low-priority sections dropped):
~/projects/statusline (main)* Sonnet 4.5
Notes:
*appears when the git working tree is dirty (i.e. the branch has uncommitted changes).- Context usage (
ctx: 96%) shows percentage until auto-compact, not raw context token usage. The calculation includes the 22.5% autocompact buffer that Claude Code reserves (45k tokens for a 200k window). This means:ctx: 0%= conversation just started, plenty of spacectx: 96%= approaching auto-compact, ~4% free space remainingctx: 100%= auto-compact will trigger (free space ≈ 0%)- The percentage represents how "full" your context window is including the reserved buffer, making it easier to understand when compaction will occur rather than showing raw token counts. By default, context is displayed as a floored integer (e.g., 99.9% → 99%) to match Claude Code's notification style. Set
CONTEXT_USE_FLOAT = trueto show decimal precision (e.g., 99.9%).
- Quota percentages (
5h: 12%,7d: 5%) are provided by the official Anthropic API and displayed as whole numbers without decimals. This is by design—the API returns integer precision only. Limitation: When quota reaches 100%, the displayed percentage may be inaccurate due to API behavior. This is an Anthropic limitation, not a bug in the statusline. - Exact truncation depends on your terminal width and
RIGHT_MARGIN.
Quick start
Prerequisites
- Rust toolchain: https://rustup.rs/
- After installing Rust: Either restart your shell OR run
source $HOME/.cargo/env(Linux/macOS) orsource $env:USERPROFILE\.cargo\env(Windows PowerShell) to makecargoavailable
- After installing Rust: Either restart your shell OR run
- Claude Code installed
- Powerline-compatible font (recommended): Nerd Fonts, Powerline fonts, or similar for proper arrow rendering. If you don't have one, set
USE_POWERLINE = falsefor classic pipe separators. - Runtime dependencies:
git(for git section)curl(for quota fetching; ensure it's in PATH)
Installation (macOS / Linux)
HTTPS:
SSH:
Installation (Windows PowerShell)
HTTPS:
git clone https://github.com/ndave92/claude-code-status-line.git $env:USERPROFILE\.claude\statusline
cd $env:USERPROFILE\.claude\statusline
cargo build --release
SSH:
git clone git@github.com:ndave92/claude-code-status-line.git $env:USERPROFILE\.claude\statusline
cd $env:USERPROFILE\.claude\statusline
cargo build --release
Updating
To update to the latest version:
If you haven't customized the code:
# Navigate to your statusline directory
# Pull the latest changes
# Rebuild
If you have customizations:
# Navigate to your statusline directory
# Stash your changes
# Pull the latest changes
# Reapply your customizations
# Resolve any conflicts if they occur
# Edit src/main.rs to merge your customizations with new changes
# Rebuild
After rebuilding, restart Claude Code to see the updated statusline.
Configure Claude Code
Claude Code runs your command, passes session context as JSON on stdin, and uses the first line of stdout as the status line.
Settings file locations:
- User settings:
~/.claude/settings.json - Project settings:
.claude/settings.json
(Exact locations can vary depending on how Claude Code is installed/configured.)
If the settings file doesn't exist, create it first:
# macOS/Linux
# Windows PowerShell
Add the statusLine configuration:
Examples:
- macOS/Linux:
~/.claude/statusline/target/release/claude-code-status-line
- Windows:
- Use a full absolute path to
claude-code-status-line.exe
- Use a full absolute path to
Restart Claude Code to see the status line.
Configuration
Edit constants at the top of src/main.rs, then rebuild with:
Toggle sections
const SHOW_CWD: bool = true; // enables current working directory section
const CWD_FULL_PATH: bool = true; // whether to show the full path or just the last directory
const SHOW_GIT: bool = true; // enables git section
const SHOW_MODEL: bool = true; // enables model name section
const SHOW_CONTEXT: bool = true; // enables context usage section
const CONTEXT_USE_FLOAT: bool = false; // set to true to show floating point (e.g., 99.9%), false for integer floored (e.g., 99.9% → 99%)
const SHOW_QUOTA: bool = true; // enables quota usage section with reset timers
const SHOW_COST: bool = false; // optional; enables API cost section (mainly for API key users)
const DEFAULT_TERMINAL_WIDTH: usize = 120; // fallback terminal width if detection fails
const RIGHT_MARGIN: usize = 20; // reserve space for Claude Code's right-side messages to prevent soft wrapping (0 = no margin)
Percentage formatting:
- Context (
ctx: 96%): Shows floored integer by default (e.g., 99.9% → 99%) to match Claude Code's notification style. Represents percentage until auto-compact (includes the 22.5% buffer). Atctx: 100%, auto-compact triggers. SetCONTEXT_USE_FLOAT = trueto show decimal precision (e.g.,ctx: 99.9%). - Quota (
5h: 12%,7d: 5%): Shows whole numbers without decimals since the Anthropic API returns integer precision. Note that quota percentages may be inaccurate when reaching 100% due to API limitations.
Quota caching:
const QUOTA_CACHE_TTL: u64 = 0; // Cache TTL in seconds (0 = disabled, set to e.g. 300 for 5 minutes)
Priority: earlier sections (added first in main) are higher priority and will remain visible longer when width is limited.
Powerline arrows
const POWERLINE_ARROW: char = '\u{E0B0}'; // - requires powerline-compatible font
const USE_POWERLINE: bool = true; // set to false for classic pipe separator style
Font requirement: Powerline arrows require a powerline-compatible font (e.g., Nerd Fonts, Powerline fonts). If you see a missing character symbol instead of smooth arrows, either install a compatible font or set USE_POWERLINE = false.
Classic pipe separator mode
When USE_POWERLINE = false, the statusline uses the classic global color system with pipe separators:
const SEPARATOR_CHAR: char = '|'; // you can try '/' or '·' for alternative separators
const USE_DARK_THEME: bool = true; // theme selection for classic mode colors
// Dark theme colors (classic mode)
const DARK_BG: = ; // Claude Burnt Orange #D97757
const DARK_FG: = ; // Claude Dark Gray #262624
const DARK_SEP: = ; // Claude Dark Gray #262624
const DARK_MUTED: = ; // Claude Medium Gray #41413E
// Light theme colors (classic mode)
const LIGHT_BG: = ; // Claude Burnt Orange #D97757
const LIGHT_FG: = ; // Claude Cream #FAF9F5
const LIGHT_SEP: = ; // Claude Cream #FAF9F5
const LIGHT_MUTED: = ; // Claude Light Gray #82817A
const SHOW_BACKGROUND: bool = true; // Set to false for transparent background
Per-section colors (powerline mode)
When USE_POWERLINE = true, each section has its own SectionColors defining background, foreground, and muted colors (RGB tuples 0–255):
Per-section color constants (customize in src/main.rs):
const CWD_COLORS: SectionColors = SectionColors ;
const GIT_COLORS: SectionColors = SectionColors ;
const MODEL_COLORS: SectionColors = SectionColors ;
const CONTEXT_COLORS: SectionColors = SectionColors ;
const QUOTA_5H_COLORS: SectionColors = SectionColors ;
const QUOTA_7D_COLORS: SectionColors = SectionColors ;
const COST_COLORS: SectionColors = SectionColors ;
Customization examples:
- Create a multi-colored statusline by setting different
bgvalues for each section - Make quota timers stand out by setting
QUOTA_COLORS.mutedto a lighter/darker shade - Create a dark/light gradient by varying background brightness across sections
Official Claude colors for reference:
; // Claude Burnt Orange #D97757
; // Claude Cream #FAF9F5
; // Claude Dark Gray #262624
; // Claude Medium Gray #41413E
; // Claude Light Gray #82817A
Environment variables
CLAUDE_OAUTH_TOKEN: OAuth token override (bypasses credentials file, keychain, and keyring lookup).CLAUDE_TERMINAL_WIDTH: force a specific terminal width (integer).COLUMNS: used as a terminal width fallback (integer).STATUSLINE_DEBUG: if set, prints debug logs to stderr (quota fetch failures, width info).
Quota caching
Quota data can be cached in your system temp directory as claude-code-status-line-quota-{uid}.json (where {uid} is the user ID) to reduce latency and API calls. By default, caching is disabled (QUOTA_CACHE_TTL = 0). To enable caching, set QUOTA_CACHE_TTL to the desired TTL in seconds (e.g., 300 for 5 minutes). The user ID in the filename reduces collisions; combined with atomic temp-file patterns this improves safety.
Platform notes
macOS
- Reads Claude Code credentials via
security(Keychain) unlessCLAUDE_OAUTH_TOKENis set.
Linux
- First tries to read credentials from
~/.claude/.credentials.json(more reliable, works out of the box). - Falls back to the
keyringcrate if the credentials file doesn't exist. - The credentials file approach is recommended for systems where keyring services may not be available or properly configured.
Windows
- First tries to read credentials from
%USERPROFILE%\.claude\.credentials.json. - Falls back to the
keyringcrate backend if the credentials file doesn't exist. - The credentials file approach may be more reliable if Windows Credential Manager integration has issues.
FAQ
Understanding the Display
Q: What does the context percentage (ctx: X%) mean?
The context percentage shows percentage until auto-compact, not your raw context usage. This makes it easy to understand when Claude Code will trigger auto-compaction.
The calculation includes the 22.5% autocompact buffer that Claude Code reserves (45k tokens for a 200k context window). This buffer is counted as "used" space.
Examples:
ctx: 0%= Conversation just started, plenty of space availablectx: 96%= Approaching auto-compact, approximately 4% free space remainingctx: 100%= Auto-compact will trigger (free space ≈ 0%)
This approach is more intuitive than showing raw token counts because it directly answers "how close am I to auto-compact?"
Q: Why doesn't my context percentage match Claude Code's notifications exactly?
The statusline uses floored integer display by default (e.g., 99.9% → 99%), showing whole numbers without decimals. This provides a cleaner display and typically aligns well with Claude Code's notification percentages. However, minor differences (~1%) between the statusline and Claude Code's notifications can occur due to different rounding or display methods.
If you prefer decimal precision like ctx: 99.9%, you can enable it:
const CONTEXT_USE_FLOAT: bool = true; // Set in src/main.rs
Then rebuild with cargo build --release.
Q: Why are quota percentages whole numbers (like 5h: 8% instead of 5h: 8.3%)?
The Anthropic API returns quota utilization as integers only—this is by design, not a limitation of the statusline. The API simply doesn't provide sub-percentage precision.
Note: When quota reaches 100%, the displayed percentage may be inaccurate due to API behavior. This is an Anthropic limitation.
Q: What does the * next to my git branch mean?
The asterisk indicates your git working tree is "dirty", meaning you have uncommitted changes (modified, added, or deleted files).
Examples:
(main)= Clean working tree, no uncommitted changes(main)*= You have uncommitted changes
Q: Why do some sections disappear on narrow terminals?
The statusline uses width-aware rendering to prevent line wrapping. When your terminal is too narrow to fit all sections, lower-priority sections are dropped.
Priority order (highest to lowest):
- Current directory (
SHOW_CWD) - Git branch (
SHOW_GIT) - Model name (
SHOW_MODEL) - Context usage (
SHOW_CONTEXT) - Quota percentages (
SHOW_QUOTA) - Quota reset timers (dropped first)
- Cost (
SHOW_COST)
The priority is determined by the order sections are added in the main() function.
You can adjust the RIGHT_MARGIN constant to control how much space is reserved for Claude Code's right-side messages:
const RIGHT_MARGIN: usize = 20; // Default: 20 characters
Customization
Q: How do I change the colors?
For Powerline mode (USE_POWERLINE = true):
Edit the *_COLORS constants in src/main.rs. Each section has its own SectionColors with three RGB values:
const GIT_COLORS: SectionColors = SectionColors ;
RGB format: (red, green, blue) with values 0-255.
Official Claude color palette:
; // Claude Burnt Orange #D97757
; // Claude Cream #FAF9F5
; // Claude Dark Gray #262624
; // Claude Medium Gray #41413E
; // Claude Light Gray #82817A
For Classic mode (USE_POWERLINE = false):
Edit the theme constants:
const USE_DARK_THEME: bool = true; // Switch between dark/light themes
// Dark theme colors
const DARK_BG: = ; // Background
const DARK_FG: = ; // Foreground text
const DARK_SEP: = ; // Separator color
const DARK_MUTED: = ; // Muted text
After changing colors, rebuild: cargo build --release
Q: How do I hide/show specific sections?
Toggle the SHOW_* constants in src/main.rs:
const SHOW_CWD: bool = true; // Current working directory
const SHOW_GIT: bool = true; // Git branch + dirty indicator
const SHOW_MODEL: bool = true; // Model name (e.g., "Sonnet 4.5")
const SHOW_CONTEXT: bool = true; // Context percentage
const SHOW_QUOTA: bool = true; // Quota (5h/7d) with reset timers
const SHOW_COST: bool = false; // API cost (useful for API key users)
Example - hide model name and cost:
const SHOW_MODEL: bool = false;
const SHOW_COST: bool = false;
Rebuild after changes: cargo build --release
Q: How do I change section order/priority?
Section priority is determined by the order sections are added in the main() function. Earlier sections have higher priority and stay visible longer on narrow terminals.
To change the order, you'll need to modify the code in src/main.rs around line 850-950 where sections are added with sections.push().
The current order (highest to lowest priority):
- CWD → 2. Git → 3. Model → 4. Context → 5. Quota → 6. Cost
Q: How do I make the statusline shorter for narrow terminals?
Multiple approaches:
- Reduce right margin (most common):
const RIGHT_MARGIN: usize = 10; // Reduce from default 20
- Disable non-essential sections:
const SHOW_COST: bool = false; // Cost rarely changes
const SHOW_MODEL: bool = false; // You know which model you're using
- Show only directory name instead of full path:
const CWD_FULL_PATH: bool = false; // Show "statusline" instead of "~/projects/statusline"
Rebuild after changes: cargo build --release
Q: Can I use custom separators instead of powerline arrows?
Yes! Disable powerline mode and choose your separator:
const USE_POWERLINE: bool = false; // Switch to classic mode
const SEPARATOR_CHAR: char = '/'; // Try '/', '·', '|', '•', etc.
Examples:
const SEPARATOR_CHAR: char = '|';→~/projects | main | Sonnet 4.5const SEPARATOR_CHAR: char = '/';→~/projects / main / Sonnet 4.5const SEPARATOR_CHAR: char = '·';→~/projects · main · Sonnet 4.5
Rebuild after changes: cargo build --release
Q: How do I prevent text overlap with Claude's right-side messages?
Adjust the RIGHT_MARGIN constant to reserve more space:
const RIGHT_MARGIN: usize = 30; // Increase from default 20
This leaves 30 characters of space for Claude Code's notification messages like "X% left until auto-compact".
If your statusline is still overlapping:
- Increase
RIGHT_MARGINfurther - Disable some sections to make the statusline shorter
- Use
CWD_FULL_PATH = falseto shorten the directory display
Troubleshooting
Q: Status line not appearing at all
Check your settings:
- Verify
~/.claude/settings.json(or%USERPROFILE%\.claude\settings.jsonon Windows) contains:
-
Path must be absolute, not relative:
- ✅ macOS/Linux:
~/.claude/statusline/target/release/claude-code-status-line - ✅ Windows:
C:\Users\YourName\.claude\statusline\target\release\claude-code-status-line.exe - ❌ Bad:
./claude-code-status-line
- ✅ macOS/Linux:
-
Verify binary exists:
# macOS/Linux # Windows PowerShell -
Make it executable (macOS/Linux only - Windows doesn't need this):
-
Restart Claude Code after any changes to settings.
Q: Quota shows 5h: - / 7d: -
This happens when the statusline can't fetch quota data from the Anthropic API. Common causes:
1. Credential access issues (most common):
-
Linux: Verify
~/.claude/.credentials.jsonexists: -
Windows: Verify
%USERPROFILE%\.claude\.credentials.jsonexists:# PowerShell Get-Item $env:USERPROFILE\.claude\.credentials.json Get-Content $env:USERPROFILE\.claude\.credentials.json # Or cmd.exe dir %USERPROFILE%\.claude\.credentials.json type %USERPROFILE%\.claude\.credentials.jsonExample path:
C:\Users\YourName\.claude\.credentials.json
2. Network issues:
- Check your internet connection
- Firewall might be blocking
curl
3. Missing curl:
# macOS/Linux
# Windows PowerShell/cmd
4. Workaround - set token manually:
# macOS/Linux
# Windows PowerShell
$env:CLAUDE_OAUTH_TOKEN="your-token-here"
# Windows cmd.exe
Q: Powerline arrows display as boxes, question marks, or missing characters
You need a powerline-compatible font installed and configured in your terminal.
Solutions:
-
Install a compatible font (recommended):
- Nerd Fonts (recommended)
- Powerline Fonts
- Popular choices: "JetBrains Mono Nerd Font", "FiraCode Nerd Font", "Hack Nerd Font"
-
Configure your terminal to use the font:
- iTerm2: Preferences → Profiles → Text → Font
- VS Code terminal: Settings → Terminal → Font Family
- Windows Terminal: Settings → Profiles → Appearance → Font face
-
Fallback - use classic mode (no font required):
const USE_POWERLINE: bool = false; // Disable powerline arrows
Q: Colors look wrong or don't appear
Cause: Your terminal may not support 24-bit truecolor ANSI codes.
Check terminal support:
- Modern terminals (iTerm2, Windows Terminal, VS Code terminal): Full support ✅
- Older terminals (cmd.exe, basic xterm): Limited support ❌
Solutions:
- Use a modern terminal with truecolor support
- Try transparent background mode:
const SHOW_BACKGROUND: bool = false; // Classic mode only
- Adjust colors to use simpler RGB values:
const GIT_COLORS: SectionColors = SectionColors ;
- Test your terminal's color support (Unix/macOS only):
|
Q: Context percentage seems stuck or not updating
Possible causes:
-
Cached binary - Claude Code might be using an old version:
# Then restart Claude Code -
Check if Claude Code is sending updates (Unix/macOS):
STATUSLINE_DEBUG=1Windows PowerShell:
$env:STATUSLINE_DEBUG=1 & "$env:USERPROFILE\.claude\statusline\target\release\claude-code-status-line.exe"Look for error messages in stderr.
-
Verify the calculation matches
/contextoutput:- Run
/contextin Claude Code - Compare with statusline percentage
- Should match within rounding (statusline has 1 decimal precision)
- Run
Q: Build fails with Rust compilation errors
Common issues:
-
Rust not installed:
# macOS/Linux | # Windows - download from https://rustup.rs/ -
Cargo not in PATH after install:
# macOS/Linux # Windows - restart your terminal/PowerShell -
Outdated Rust version:
-
Corrupted build cache:
Q: "command not found" when Claude Code tries to run the statusline
Cause: The binary path in settings.json is incorrect or not absolute.
Fix:
-
Find the correct absolute path:
# macOS/Linux # Output: /Users/yourname/.claude/statusline/target/release/claude-code-status-line # Windows PowerShell # Output: C:\Users\yourname\.claude\statusline\target\release\claude-code-status-line.exe -
Update settings.json with the full path:
-
Verify the file exists:
# macOS/Linux # Windows PowerShell -
Check permissions (macOS/Linux only):
General
Q: Does this slow down Claude Code?
No, the performance impact is minimal:
- The binary runs once per prompt/message, not continuously
- Typical execution time: <50ms for everything except quota fetching
- Quota fetching adds ~100-200ms (only when
SHOW_QUOTA = true) - No persistent processes - the binary exits immediately after printing the statusline
To reduce latency further:
- Enable quota caching (avoids API calls):
const QUOTA_CACHE_TTL: u64 = 300; // Cache for 5 minutes - Disable quota display:
const SHOW_QUOTA: bool = false;
Q: Is this safe to use? (credential/security concerns)
Yes, the statusline is safe:
- Read-only credential access - Only reads credentials, never writes or modifies them
- Uses same sources as Claude Code - macOS Keychain, system keyring, or credentials file
- No data sent elsewhere - Only communicates with Anthropic's official API for quota (when enabled)
- Open source - You can audit the code yourself: GitHub repo
- MIT licensed - Free to use, modify, and audit
What data is sent:
- When
SHOW_QUOTA = true: OAuth token sent toapi.anthropic.com/v1/quota(official API) - Otherwise: No network requests
Q: Does this work with API keys (not Claude Pro subscription)?
Yes, but with limitations:
- API keys don't have quota limits, so quota sections will show
5h: -and7d: - - All other sections work normally (CWD, git, model, context)
- The cost section is useful for API users:
const SHOW_COST: bool = true; // Enable to track API costs
This will show your session cost in USD, e.g., $0.05.
Q: How do I update to the latest version?
If you installed via git clone (see Updating section for details):
# macOS/Linux
# Restart Claude Code
# Windows PowerShell
# Restart Claude Code
If you downloaded as ZIP:
- Download the latest release from GitHub Releases or download the repository as ZIP again
- If you have customizations, back them up first:
# macOS/Linux # Windows PowerShell # Windows cmd.exe - Extract the new ZIP to replace the old directory
- Reapply your customizations by copying constants from the backup to the new
src/main.rs - Rebuild:
- Restart Claude Code
With git stash (if using git):
# macOS/Linux
# Windows PowerShell
Q: Can I contribute to this project?
Yes! Contributions are welcome:
- Report issues: GitHub Issues
- Submit pull requests: Fork the repo and submit PRs
- Suggest features: Open an issue with your idea
- Share customizations: Show off your color schemes and configurations
Project is MIT licensed - you're free to modify, distribute, and use it however you like.
Development
Build (fast):
Build (optimized):
Run tests:
Testing the binary manually
You can simulate Claude Code input by piping JSON to stdin:
|
To debug width handling:
STATUSLINE_DEBUG=1 CLAUDE_TERMINAL_WIDTH=60
License
MIT