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

@danielgap/pi-claude-usage

v0.2.3

Published

Claude subscription usage meter for pi-claude-bridge: registers the claude-bridge provider as a Gentle Shell usage source so the native usage bar and /gentle:usage panel show the 5-hour and weekly Claude windows.

Readme

pi-claude-usage

npm license Pi package

Claude subscription usage for pi-claude-bridge sessions, shown in the Gentle Shell usage bar and /gentle:usage panel. Designed for Gentle Shell: with the shell loaded it registers claude-bridge on its official third-party usage-source event and feeds its native usage surfaces, just like built-in Codex sources. Without Gentle Shell it still provides a standalone status-bar segment, a /claude:usage subscriptions panel, and automatic refresh while claude-bridge is the active provider.

Why

Gentle Shell already meters the native anthropic provider by reading the anthropic-ratelimit-unified-* headers of every response. That provider bills per API call. To spend a Claude subscription (Pro, Max, Team) from Pi you go through pi-claude-bridge, which runs Claude Code via the Agent SDK. Claude Code makes the HTTP calls, Pi never sees those headers, and the claude-bridge provider shows no usage.

This package fills that gap. It registers claude-bridge on Gentle Shell's third-party usage-source contract (gentle-pi:usage-source/v1). When the shell refreshes usage, the source reads Claude Code's OAuth token and asks the same usage endpoint Claude Code's /usage view uses.

You get the 5-hour and weekly windows next to your other subscriptions. That includes the case where Claude only serves the subagent routes of a mixed profile, for example a zai main session with Claude reviewers.

What it shows

| Limit | Windows | When | | --- | --- | --- | | claude | 5h, week | Whichever windows the endpoint reports (a new account may report only 5h). | | opus, sonnet | week | Only when your plan reports per-model weekly caps. |

The plan label comes from Claude Code's subscriptionType (pro, max, team, ...).

Standalone (no Gentle Shell)

Without the shell the package works on its own whenever claude-bridge is the active provider:

  • A status-bar segment (claude 5h ▰▰▰▱▱▱▱▱ 43% · week 12%) through pi's public ctx.ui.setStatus contract.
  • /claude:usage opens the same framed ✿ Subscriptions panel the shell's /gentle:usage opens (r refreshes, esc closes). /claude:usage off hides the standalone segment; /claude:usage on restores it.
  • Refreshes on session start and after agent runs, at most once every 5 minutes.

If gentle-shell acknowledges the usage-source registration (gentle-pi:usage-source-ack/v1), the standalone segment retires for the rest of the session, so the shell's own placement and visibility settings always win.

Install

Install it as a Pi package from npm:

pi install npm:@danielgap/pi-claude-usage

Then run /reload in Pi (or restart it). This adds the package to the packages array in ~/.pi/agent/settings.json:

"packages": [
  "/path/to/gentle-shell",
  "npm:pi-claude-bridge",
  "npm:@danielgap/pi-claude-usage"
]

You can also install straight from git, no npm involved:

pi install git:github.com/danielgap/pi-claude-usage

Requirements:

  • pi-claude-bridge installed and its claude-bridge provider configured — the meter only fetches while it is the active provider.
  • Claude Code logged in with a subscription (claude → /login).
  • Gentle Shell is optional: with it you get the native usage bar and panel integration, without it the standalone segment and the /claude:usage panel.

Security model

  • Read-only credentials. The token is read from $CLAUDE_CONFIG_DIR/.credentials.json (default ~/.claude/.credentials.json). It is never refreshed, written, logged, or rendered. If it has expired, the meter reports no usage until Claude Code refreshes it.
  • Fixed origin. The token goes only to https://api.anthropic.com/api/oauth/usage. Redirects are refused, so it cannot be replayed to another host, and responses are not cached.
  • No model call. The request only reads quota; it sends no prompt and runs no model.

Limitations

  • Undocumented endpoint. Anthropic may change it at any time. Unknown shapes degrade to "no usage", never to an error.
  • macOS. Claude Code stores its credentials in the Keychain there, so the file is missing and the meter stays empty.
  • Refresh cadence. With Gentle Shell the shell owns it: on session start and when you press r in /gentle:usage (forced), and after agent runs at most once every 5 minutes. Standalone mode follows the same cadence itself.

This extension was built with Gentle AI.

Releasing

Releases publish automatically from version tags through .github/workflows/publish.yml:

  1. Bump package.json to the next version, commit, and push to main.

  2. Tag the release on the freshly fetched origin/main commit — the workflow verifies the tag is annotated, matches package.json's version, and points to a commit reachable from main:

    git fetch origin main --tags
    git tag -a vX.Y.Z "$(git rev-parse 'origin/main^{commit}')" -m "@danielgap/pi-claude-usage vX.Y.Z"
    git push origin refs/tags/vX.Y.Z
  3. CI installs, tests, typechecks, packs, publishes to npm with provenance, creates the GitHub Release if it is missing, and verifies the registry. A brand-new package version can take a few minutes to appear in the registry after a successful publish, so the Verify npm step retries for up to 3 minutes before failing.

First-time setup: an NPM_TOKEN secret with publish rights is required under Settings → Secrets and variables → Actions. A run that failed for publication-only reasons can be retried without moving its tag (gh workflow run publish.yml -f tag=vX.Y.Z).

Development

pnpm install
npm test          # offline, fetch and file reads are injected
npm run typecheck

License

MIT