npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

claude-usage-line

v1.0.2

Published

Cross-platform Claude Code statusline showing session, 5h, and 7d rate limits

Readme

claude-usage-line

npm license node

Cross-platform Claude Code statusline — session context, 5-hour & 7-day rate limits, git branch, diff stats, cost, and duration. Zero runtime dependencies, no jq required.

Full output (when Claude Code sends extended data):

~/dev/project  main
Opus 4.6 │ Session █████░░░ 62% │ 5h ████░░░░ 48% ⟳3h28m │ 7d █████░░░ 63% ⟳22h30m │ +123 -45 │ $0.50 │ 12m

Minimal output (backward compatible — only context_window provided):

Session █████░░░ 62% │ 5h ████░░░░ 48% ⟳3h28m │ 7d █████░░░ 63% ⟳22h30m

Prerequisites

  • Node.js ≥ 18
  • Claude Code with statusline support
  • OAuth login — required for rate limit data (5h / 7d bars). Session bar works without it.

Quick Start

npx claude-usage-line setup

Or manually add to ~/.claude/settings.json:

{
  "statusLine": {
    "type": "command",
    "command": "npx claude-usage-line"
  }
}

Custom bar style:

{
  "statusLine": {
    "type": "command",
    "command": "npx claude-usage-line --style dot"
  }
}

Restart Claude Code and the statusline appears.

How It Works

Claude Code                      claude-usage-line
    │                                   │
    │  stdin: {                         │
    │    "context_window": {...},        │
    │    "cwd": "/path",                │
    │    "model": {"display_name":".."},│
    │    "cost": {...}                  │
    │  }                                │
    ├──────────────────────────────────▶│
    │                                   ├─▶ Detect git branch (if cwd given)
    │                                   ├─▶ Read cached rate limits (60s TTL)
    │                                   ├─▶ If stale: background OAuth fetch
    │                                   │
    │  stdout: ANSI statusline          │
    │◀──────────────────────────────────┤

The tool accepts these fields via stdin JSON:

| Field | Required | Description | |-------|----------|-------------| | context_window.used_percentage | Yes | Session context usage % | | cwd | No | Working directory → enables git branch detection | | model.display_name | No | Model name shown on line 2 | | cost.total_lines_added | No | Lines added (green) | | cost.total_lines_removed | No | Lines removed (red) | | cost.total_cost_usd | No | Session cost in USD | | cost.total_duration_ms | No | Session duration |

When cwd or model is present → 2-line output. Otherwise → single-line (backward compatible).

Rate limit data comes from https://api.anthropic.com/api/oauth/usage via OAuth token. API key auth does not provide rate limit visibility — bars show 0% and --.

Bar Styles

| Style | Preview | Width | |-------|---------|-------| | classic (default) | █████░░░ | 8 | | dot | ●●●●●○○○ | 8 | | braille | ⣿⣿⣿⣿⣿⣀⣀⣀ | 8 | | block | ▰▰▰▰▰▰▱▱▱▱ | 10 | | ascii | #####----- | 10 | | square | ▪▪▪▪▪····· | 10 | | pipe | ┃┃┃┃┃╌╌╌ | 8 |

Colors

Each bar changes color at thresholds:

  • < 50%: base color (Session=magenta, 5h=cyan, 7d=green)
  • ≥ 50%: yellow
  • ≥ 80%: red

Additional: model name=magenta, cwd=blue, branch=green, additions=green, removals=red, cost=yellow

JSON Output

echo '{"context_window":{"used_percentage":62}}' | npx claude-usage-line --json
{
  "model": null,
  "cwd": null,
  "git_branch": null,
  "session": { "utilization_pct": 62, "resets_at": null, "remaining": "--" },
  "five_hour": { "utilization_pct": 48, "resets_at": "2026-02-26T14:00:00Z", "remaining": "3h28m" },
  "seven_day": { "utilization_pct": 63, "resets_at": "2026-02-28T00:00:00Z", "remaining": "22h30m" },
  "diff": { "added": 0, "removed": 0 },
  "cost_usd": null,
  "duration_min": null
}

CLI Reference

Usage: claude-usage-line [options]
       claude-usage-line setup

Options:
  --style <name>  Bar style (classic, dot, braille, block, ascii, square, pipe)
  --hide <fields> Hide fields (comma-separated): cost,diff,duration,model,cwd,branch
  --json          Output JSON
  --help          Show help
  --version       Show version

Hiding Fields

Use --hide to selectively hide parts of the output:

{
  "statusLine": {
    "type": "command",
    "command": "npx claude-usage-line --hide cost,duration"
  }
}

Available fields: cost, diff, duration, model, cwd, branch

Credential Resolution

OAuth token lookup order:

  1. CLAUDE_CODE_OAUTH_TOKEN env var (consumed once, deleted from env)
  2. macOS Keychain (security find-generic-password)
  3. Linux secret-tool (requires D-Bus session — skipped in headless/Docker)
  4. Windows Credential Manager (PasswordVault API via PowerShell)
  5. ~/.claude/.credentials.json (fallback)

Development

npm run build
echo '{"context_window":{"used_percentage":62}}' | node dist/cli.js
echo '{"cwd":"/tmp","model":{"display_name":"Opus 4.6"},"context_window":{"used_percentage":85},"cost":{"total_lines_added":42,"total_lines_removed":10,"total_cost_usd":1.23,"total_duration_ms":3720000}}' | node dist/cli.js

License

MIT