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 🙏

© 2025 – Pkg Stats / Ryan Hefner

claude-code-usage-statusline

v0.5.0

Published

Clean statusline for Claude Code showing session info, git status, context usage, and API rate limits

Readme

claude-code-usage-statusline

Clean, type-safe statusline for Claude Code displaying real-time session info, git status, context usage, and Claude API rate limits.

Features

  • Session Info: Current branch, uncommitted changes (color-coded +/-), working directory
  • Context Usage: Token consumption and percentage of 200K limit
  • Usage Limits: Five-hour & seven-day API usage with visual progress bars (fractional blocks)
  • Customization: Icon labels, separators, path modes, progress bar styles
  • Performance: <500ms typical render time
  • Type Safety: Full TypeScript with strict mode

Prerequisites

Install Bun

This package requires Bun runtime. If you don't have Bun installed:

curl -fsSL https://bun.sh/install | bash

This automatically:

For more details, see bun.sh

Installation

bun add -g claude-code-usage-statusline

Source your shell file, for instance the .zshrc :

source ~/.zshrc

Requirements

  • Runtime: Bun 1.0+
  • Platform: macOS only (uses Keychain for authentication)
  • Dependencies: Git CLI, Claude Code with OAuth token

Configuration

Add to ~/.claude/settings.json:

{
  "statusLine": {
    "type": "command",
    "command": "cc-statusline",
    "padding": 0
  }
}

Authentication

The statusline retrieves your Claude OAuth token from macOS Keychain:

  • Service: Claude Code-credentials
  • Token Type: OAuth token (sk-ant-oat01-...)
  • Setup: Automatically configured when you authenticate Claude Code

If you don't have Claude Code installed, the statusline will still work but won't display API usage limits.

Output Format

Line 1: Session Info

main • +123 -45 ~2 • ~/.claude • Sonnet 4.5

Line 2: Metrics

Context: 62.5k 31% • 5h: 15% ▊░░░░ (3h27m) • 7d: 45% ████▏░

Components:

  • 62.5k - Context tokens used (color-coded additions/deletions)
  • 31% - Context percentage (tokens / 200K)
  • ▊░░░░ - Visual progress bar with fractional blocks
  • 15% - Five-hour usage
  • 45% - Seven-day usage (optional)
  • (3h27m) - Time until rate limit resets

Customization

Interactive Configuration

Launch the interactive config menu:

cc-statusline-config

Navigate through categories:

  • Display Options: Layout, separators, path display, use icons instead of labels
  • Git Settings: Branch, changes, staged/unstaged files
  • Session Info: Token display, decimals, percentages
  • Context Window: Max tokens, autocompact buffer
  • Usage Limits: Progress bars, colors, seven-day limits
  • Import/Export: Share configs between machines

Programmatic Configuration

# List all settings
cc-statusline-config list

# Get specific value
cc-statusline-config get git.showBranch

# Set value
cc-statusline-config set git.showChanges true
cc-statusline-config set separator "→"
cc-statusline-config set context.maxContextTokens 200000

# Reset to defaults
cc-statusline-config reset              # All settings
cc-statusline-config reset git.showChanges  # Single setting

# Import/Export configs
cc-statusline-config export ./my-config.json
cc-statusline-config import ./my-config.json

Configuration File

Settings stored in ~/.config/claude-code-statusline/statusline.config.json (auto-created on first use). Configuration persists across package upgrades (bun add -g). Example configuration in statusline.config.example.json.

Available Settings:

  • oneLine: Display on single line (default: false)
  • showSonnetModel: Show model when Sonnet (default: false)
  • pathDisplayMode: "full" | "truncated" | "basename" (default: "truncated")
  • useIconLabels: Use icons (📚🕔📅) instead of text labels (default: false)
  • separator: Section separator ("|", "•", "·", etc.) (default: "•")
  • git.showBranch: Show branch name (default: true)
  • git.showDirtyIndicator: Show • when dirty (default: true)
  • git.showChanges: Show color-coded +/- line counts (default: false)
  • git.showStaged: Show staged files (default: true)
  • git.showUnstaged: Show unstaged files (default: true)
  • session.infoSeparator: Info separator or null for space (default: null)
  • session.showTokens: Show token count (default: true)
  • session.showMaxTokens: Show max tokens (192k/200k) (default: false)
  • session.showTokenDecimals: Show decimals in tokens (default: false)
  • session.showPercentage: Show context % (default: true)
  • context.maxContextTokens: Context window size (default: 200000)
  • context.autocompactBufferTokens: Autocompact buffer (default: 45000)
  • context.useUsableContextOnly: Include buffer in display (default: false)
  • context.overheadTokens: System overhead tokens (default: 0)
  • limits.showProgressBar: Visual progress bar with fractional blocks (default: true)
  • limits.progressBarLength: Bar length: 5, 10, or 15 chars (default: 5)
  • limits.color: "progressive" | "green" | "yellow" | "red" (default: "progressive")
  • limits.showSevenDay: Show seven-day usage bar (default: false)

Development

# Clone repository
git clone https://github.com/dantereve/claude-code-usage-statusline.git
cd claude-code-usage-statusline

# Install dependencies
bun install

# Run tests
bun test

# Test locally
echo '{"type": "test"}' | bun run src/index.ts

Architecture

src/
├── index.ts              # Main entry point
├── config-cli.ts         # Interactive config CLI
└── lib/
    ├── types.ts          # TypeScript interfaces
    ├── git.ts            # Git operations (color-coded changes)
    ├── context.ts        # Transcript parsing
    ├── usage-limits.ts   # Claude OAuth API
    ├── config.ts         # Config load/save utilities
    └── formatters.ts     # Display utilities (progress bars)

statusline.config.ts                                      # Config types & defaults
~/.config/claude-code-statusline/statusline.config.json  # User config (XDG location)
statusline.config.example.json                           # Example config

Error Handling

All components fail silently to ensure the statusline never crashes Claude Code:

  • Missing transcript → 0 tokens, 0%
  • API failure → No usage limits shown
  • Git errors → "no-git" branch
  • Keychain access denied → No usage limits

Performance

Typical render times:

  • Context calculation: ~10-50ms
  • API call: ~100-300ms (cached)
  • Git operations: ~20-50ms
  • Total: <500ms

License

MIT © Mathias

Contributing

Issues and PRs welcome at github.com/dantereve/claude-code-usage-statusline