JSPM

contextbricks-universal

4.2.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 74
  • Score
    100M100P100Q75603F
  • License MIT

Universal cross-platform statusline for Claude Code CLI with context brick visualization. Windows, Linux, macOS. No bash or jq required.

Package Exports

  • contextbricks-universal
  • contextbricks-universal/scripts/statusline.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (contextbricks-universal) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

ContextBricks Universal

Cross-platform statusline for Claude Code CLI with real-time context brick visualization.

Works on Windows, Linux, and macOS — pure Node.js, no bash or jq required.

[Sonnet 4.5] claude-skills:main *↑2 | +145/-23
[5f2ce67] Remove auth-js skill
[■■■■■■■■■■■■■□□□□□□□□□□□□□□□□□] 43% | 113k free | 0h12m | $0.87
5h:64% ~23m | 7d:57% ~1d23h | sonnet:9% ~3d23h

Features

  • Real-time context tracking — brick visualization of context window usage
  • Rate limit tracking — 5-hour and 7-day utilization with reset timers (Max/Pro subscribers)
  • Official percentage fields (Claude Code 2.1.6+) with fallback calculation (2.0.70+)
  • Git integration — repo, branch, commit hash, message, dirty/ahead/behind indicators
  • Session metrics — model name, lines changed, duration, cost (hidden for Max subscribers)
  • Environment configCONTEXTBRICKS_SHOW_DIR, CONTEXTBRICKS_BRICKS, CONTEXTBRICKS_SHOW_LIMITS

Installation

npm install -g contextbricks-universal
contextbricks install

Or one-liner via npx (installs and runs automatically):

npx contextbricks-universal

Node.js is the only requirement (already present if you use Claude Code).

From GitHub (without npm)

npm install -g github:thebtf/contextbricks-universal
contextbricks install

From Source

git clone https://github.com/thebtf/contextbricks-universal.git
cd contextbricks-universal
node bin/cli.js install

What the Installer Does

  1. Copies statusline.js to ~/.claude/statusline.js
  2. Updates ~/.claude/settings.json with the statusLine command
  3. Backs up existing configuration before any changes

Display Layout

Line 1 — Model + Git + Changes

[Sonnet 4.5] claude-skills:main *↑2 | +145/-23

Line 2 — Commit Details

[5f2ce67] Remove auth-js skill

Line 3 — Context Bricks

[■■■■■■■■■■■■■□□□□□□□□□□□□□□□□□] 43% | 113k free | 0h12m | $0.87

Line 4 — Rate Limits (Max/Pro subscribers)

5h:64% ~23m | 7d:57% ~1d23h | sonnet:9% ~3d23h
Symbol Meaning
(cyan) Used context
(dim) Free space
* Uncommitted changes
↑3 Ahead of remote by 3
↓2 Behind remote by 2
5h:X% 5-hour rolling limit utilization
7d:X% 7-day overall limit utilization
sonnet:X% 7-day Sonnet sub-limit (if applicable)
opus:X% 7-day Opus sub-limit (if applicable)
~22m / ~1d23h Time until limit resets (exact by default)

Configuration

Environment Variable Default Description
CONTEXTBRICKS_SHOW_DIR 1 Show current subdirectory (0 to hide)
CONTEXTBRICKS_BRICKS 30 Number of bricks in the visualization
CONTEXTBRICKS_SHOW_LIMITS 1 Show rate limit utilization (0 to hide)
CONTEXTBRICKS_RESET_EXACT 1 Exact reset times ~1d23h (0 for approximate ~1d)

How It Works

Context Tracking (Claude Code 2.1.6+)

Uses pre-calculated percentage fields:

{
  "context_window": {
    "context_window_size": 200000,
    "used_percentage": 43.5,
    "remaining_percentage": 56.5
  }
}

Fallback (Claude Code 2.0.70+)

Calculates from current_usage token counts when percentage fields are unavailable.

Settings

The installer configures ~/.claude/settings.json:

{
  "statusLine": {
    "type": "command",
    "command": "node ~/.claude/statusline.js",
    "padding": 0
  }
}

Rate Limit Tracking

Line 4 shows your current utilization of Claude's rate limits — useful for Max and Pro subscribers to avoid hitting caps.

How It Works

  1. Reads your OAuth token from Claude Code credentials (~/.claude/.credentials.json, or macOS keychain)
  2. Fetches usage data from api.anthropic.com/api/oauth/usage
  3. Caches the response for 5 minutes (~/.claude/.usage-cache.json)
  4. Displays utilization percentages with color coding:
    • Green (0-49%) — plenty of capacity
    • Yellow (50-79%) — approaching limit
    • Red (80-100%) — near or at limit

Requirements

  • Active Claude Max or Pro subscription with OAuth credentials
  • API-only users will not see Line 4 (gracefully skipped)

Privacy

  • Your OAuth token is never logged or exposed in command arguments
  • Token is passed to the HTTPS subprocess via environment variable
  • Cache file (~/.claude/.usage-cache.json) is stored locally

Troubleshooting

Issue Solution
Line 4 not showing Verify ~/.claude/.credentials.json exists with claudeAiOauth.accessToken
Stale data Delete ~/.claude/.usage-cache.json to force refresh
Want to hide Line 4 Set CONTEXTBRICKS_SHOW_LIMITS=0

Testing

contextbricks test

Requirements

  • Node.js >= 14
  • git (optional, for git info display)

No bash, jq, bc, sed, cut, or any other Unix tools required.

Bash vs Node.js

Bash (v3.5) Node.js (v4.x)
Platform Linux/macOS only Windows + Linux + macOS
Dependencies bash, jq, git, bc, sed, cut Node.js only (git optional)
JSON parsing External jq Native JSON.parse()
Install Shell scripts npm i -g contextbricks-universal
Output Identical Identical

Uninstallation

contextbricks uninstall

Or manually:

  1. Delete ~/.claude/statusline.js
  2. Remove the statusLine section from ~/.claude/settings.json
  3. Restart Claude Code

Acknowledgements

This project is a cross-platform Node.js rewrite of ContextBricks created by Jeremy Dawes (jezweb.com.au). The original bash implementation provided the foundation for the statusline format, brick visualization, and git integration.

Also inspired by ccstatusline.

License

MIT — Copyright (c) 2025 Jeremy Dawes (Jezweb)