juanibiapina

Pi Usage — AI skill for Claude Code

AI community

Pi extension that fetches subscription usage for AI providers.

How to install Pi Usage

This entry records only its repository, not the path inside it, so there is no exact command to give. Open juanibiapina/pi-usage and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Pi Usage does

Pi extension that fetches subscription usage for AI providers. Simplified fork of @marckrenn/pi-sub-core.

Alternatives in AI

  • onWatch — Open-source Go CLI that tracks AI API quota usage across 7 providers (Synthetic, Z.ai, Anthropic, Codex, GitHu 397 ★
  • Mirofish CLI — Multi-agent AI prediction engine - digital sandbox for scenario simulation (fork of 666ghj/MiroFish) 307 ★
  • Facadecode — One IDE for you and your AI team 131 ★

README

pi-usage

Pi extension that fetches subscription usage for Anthropic, Copilot, Gemini, Antigravity, Codex, Kiro, z.ai, and xAI/Grok.

Behavior

Usage resolves when Pi starts a session, selects a model, or completes a turn. The extension has no recurring refresh timer.

All Pi processes owned by the same OS account on one machine share provider state, regardless of project or `PI_CODING_AGENT_DIR`. State uses the OS user cache directory:

  • Linux: ${XDG_CACHE_HOME:-$HOME/.cache}/pi-usage
  • macOS: $HOME/Library/Caches/pi-usage
  • Windows: %LOCALAPPDATA%\\pi-usage

Each provider has an independent freshness window, lease, last-good snapshot, and retry deadline. The initial freshness window remains 60 seconds.

For every resolution:

  1. Fresh cached usage returns without an endpoint call.
  2. Stale usage triggers one endpoint call when retry policy permits it.
  3. Concurrent local callers wait and receive the lease owner's result.
  4. Retry-After becomes an absolute deadline shared by every local Pi process.
  5. A failed refresh preserves last-good usage and marks it stale.
  6. A provider without last-good data returns unavailable.

Cached data inside the freshness window is fresh. Stale means refresh was due but could not complete.

Coordination is per OS account and machine. Different machines do not share state.

Events

Event Payload Description
usage-core:ready { state: UsageCoreState } Initial resolved state for the selected provider
usage-core:update-current { state: UsageCoreState } Result of each lifecycle-triggered resolution

`UsageCoreState` retains the existing `provider` and `usage` fields and adds:

  • availability: available or unavailable;
  • freshness: fresh or stale when usage is available;
  • source: cache or endpoint;
  • fetchedAt and observedAt timestamps;
  • optional retryAt, staleReason, and error fields.

Consumers should keep stale usage visible unless their interfac