Bar

A battery-themed statusline that lives inside your Claude Code terminal. Context usage, session rate-limits, and git info - all rendered as a persistent 3-line display with intensity-aware colors.

$ npx @allthingsclaude/bar
Star us on GitHub
claude — ~/repos/allthingsclaude/bar
Claude Code v2.1.63Opus 4.6 · Claude API~/repos/allthingsclaude/bar
Add intensity-aware colors to the progress bars
I'll update the color system to shift based on usage percentage.
Read src/colors.js
Read src/render.js
Adding intensityColor() function with four threshold levels.
Edit src/colors.js - added intensityColor()
Edit src/render.js - wired intensity to both bars
Changes applied to 2 files
Opus 4.6 │ 87k/167k [52%
Session │ [19% │ 4h 31m
𖠰 bar │ ⎇ feat/intensity-colors │ +42 -8
3
Lines
Context, session, and git - each individually toggleable
4
Color Levels
Intensity shifts from lightest to darkest as usage climbs
30s
Cache TTL
Usage API responses cached to avoid rate-limiting
0
Dependencies
Built entirely on Node.js built-ins. No chalk, no axios, no inquirer

Features

Everything you need to stay aware of your Claude Code resource consumption without leaving the terminal.

01
Context Tracking
Live token count with a visual progress bar. Model name, tokens used vs total, and fill percentage - all updating in real time as you work.
02
Session Rate-Limits
5-hour window utilization with countdown timer. Fetches real data from the Anthropic API via OAuth so you know exactly how much capacity remains.
03
Git Integration
Current branch, worktree name, and lines added/removed. Your repo state is always visible without switching context.
04
Intensity-Aware Colors
Progress bars shift from light to dark as usage increases. A visual battery drain metaphor using ANSI 24-bit true color escape sequences.
05
Smart Context Calculation
Detects auto-compact settings and subtracts the 33k token compaction buffer. Shows your effective context limit, not the raw window size.
06
One-Command Setup
Interactive wizard handles line selection, global install, OAuth login, and Claude Code configuration. Up and running in under a minute.

Statusline Anatomy

Three lines, each independently toggleable. Every element is carefully formatted to maximize information density while remaining scannable at a glance.

Model & Token Usage
Shows the active model name, current token usage vs effective limit, a fill-proportional progress bar, and the percentage consumed. Color shifts from light to dark as usage climbs.
Model · Tokens · Progress bar · Percentage
Rate-Limit Window
Tracks your 5-hour rate-limit window utilization. When OAuth is configured, fetches real usage data from the Anthropic API. Falls back to estimating from session duration when offline.
Utilization · Progress bar · Countdown
Repository State
Displays current branch name, worktree indicator (when in a git worktree), and cumulative diff stats for the session. Cached for 5 seconds per working directory.
Worktree · Branch · Diff stats
Intensity Colors

Progress bars and percentages shift color based on how much of your capacity is consumed. Four thresholds create a visual heat gradient.

Range
Color
Meaning
0-25%
Lightest
Plenty of headroom
25-50%
Light
Normal usage
50-75%
Medium
Getting warm
75-100%
Dark
Approaching limit
Line Toggles
contextModel & Token Usage
sessionRate-Limit Window
gitRepository State

Toggle lines via ~/.bar/config.json or the interactive setup wizard.

Context Line
ModelActive Claude model (e.g., Opus 4.6)
TokensUsed / total in compact format (87k/167k)
Progress bar10-character visual fill indicator
PercentageContext utilization with intensity color
Session Line
UtilizationPercentage of 5-hour window consumed
Progress barSession fill with intensity coloring
CountdownTime remaining until window resets
Git Line
WorktreeProject name shown when in a worktree
BranchCurrent branch with branch symbol
Diff statsLines added (+) and removed (-)

Architecture

11 focused modules, zero npm dependencies. Everything is built on Node.js built-ins - no chalk, no axios, no inquirer. Even the interactive prompt and HTTP client are hand-rolled.

index.jsCLI entry point and mode dispatcher
render.jsCore 3-line statusline renderer
usage.jsAnthropic API usage fetcher + cache
tokens.jsOAuth token resolution and refresh
login.jsOAuth 2.0 + PKCE authentication flow
git.jsGit info extraction with caching
colors.jsANSI 24-bit true color constants
config.js~/.bar/config.json read/write
setup.jsInteractive setup wizard
prompts.jsCustom multi-select terminal UI
http.jsMinimal HTTP(S) client (zero deps)
Caching Strategy

Two separate caches keep renders fast without hammering external services. Both use /tmp for automatic cleanup on reboot.

Layer
TTL
Description
Usage API
30 seconds
Avoids hammering the Anthropic API on every render
Git info
5 seconds
One cache file per working directory, keyed by path hash
Token Resolution

Bar checks four sources in priority order to find an OAuth token. Auto-refreshes on 401 responses.

BAR_TOKENEnvironment variable (highest priority)
CLAUDE_CODE_OAUTH_TOKENClaude Code's own OAuth token
~/.bar/tokens.jsonStored tokens from claude-bar login
~/.battery/tokens/Cross-compatible with Battery app
Piped stdin
claude-bar
Main path - Claude Code pipes JSON context
Interactive TTY
npx @allthingsclaude/bar
Runs the setup wizard
Login
claude-bar login
OAuth 2.0 + PKCE authentication
Logout
claude-bar logout
Remove stored tokens

How It Works

Claude Code invokes Bar via the statusLine setting. Bar reads piped JSON, fetches usage data, and prints formatted ANSI output.

Receive
JSON from Claude Code
Claude Code pipes context data to stdin - model name, token counts, workspace info, and session duration.
Authenticate
OAuth token resolution
Checks four sources in priority order for an OAuth token. Auto-refreshes expired tokens on 401 responses.
Fetch
Anthropic usage API
Queries api.anthropic.com for real rate-limit data. Cached for 30 seconds to stay fast and avoid rate-limiting.
Calculate
Smart context limits
Reads ~/.claude.json to detect auto-compact. Subtracts the 33k compaction buffer from the raw context window size.
Render
3-line terminal output
Assembles context, session, and git lines with ANSI 24-bit true color. Intensity shifts based on usage percentage.
Display
Claude Code statusline
Output is printed to stdout. Claude Code reads it and renders the lines persistently at the bottom of your terminal.

Get Started

One command runs the interactive setup wizard. It handles line selection, global install, OAuth login, and Claude Code configuration.

$ npx @allthingsclaude/bar

Zero dependencies. No lock-in. Uninstall with npm uninstall -g @allthingsclaude/bar and remove the statusLine key from your settings.

View on GitHub
Requirements
Node.js 16.0.0 or higher
Claude Code installed and authenticated
macOS, Linux, or Windows
Setup Wizard Steps

The interactive wizard walks you through everything in under a minute.

1. Choose linesMulti-select which of the 3 lines to display
2. Save configWrites preferences to ~/.bar/config.json
3. Global installInstalls @allthingsclaude/bar globally via npm
4. OAuth loginOpens browser for Anthropic authentication (if session line enabled)
5. ConfigureWrites statusLine setting to ~/.claude/settings.json
Privacy
All data stays local on your machine
Tokens stored with 0600 file permissions
Caches in /tmp - cleaned on reboot
No telemetry, no cloud sync

Also from All Things Claude