Documentation
Published · npm latest v0.9.7
Gemini CLI · experimental, fixture-verified, financial-only
aibill documentation
The complete private workflow.
Use the CLI to inspect the full evidence receipt, understand coverage, draft one bounded action, and compare what happened afterward. npm latest is v0.9.7.
Updated August 27, 2026
01 · First run
Initialize once, inspect anytime
npx aibill init
npx aibill
npx aibill doctor --sourcesInit performs a real 30-day machine-wide Claude Code, Codex, and experimental Gemini CLI financial scan. The project where you run it owns the project-local .ai-spend-agent state directory; init preserves existing connector, audit, and spend state. The private status cache contains Claude Code and Codex aggregates—not prompts, responses, project names, transcript paths, session IDs, or credential references.
Gemini is fixture-verified and financial-only. It can contribute estimated API-equivalent value when supported chat evidence is complete; otherwise the evidence stays missing. Gemini never enters statusline, Glance, Context Health, Apply, plan, runway, or invocation evidence.
Use --plan <id> only when automatic plan detection cannot identify your subscription. A plan label does not prove remaining entitlement or billed cost.
02 · Commands
Task-first command reference
Inspect
npx aibill- Complete local readout. When no supported evidence is found it says so and substitutes nothing; pass --sample to see a labeled demo.
npx aibill --group-by project- Project breakdown; replace project with source, model, client, agent, user, workspace, or apiKey for another dimension.
npx aibill context- Canonical hook-aware Context Health decision.
npx aibill doctor --sources- Reader validation, financial evidence, freshness, and source errors.
Act carefully
npx aibill improve- Guided token-reduction loop: one reversible test from your own evidence, your typed APPROVE recorded before anything changes, then matched-session progress and a quality-gated result. --sample is a labeled demo that writes nothing.
npx aibill apply- Writes a copy-ready inspection, approval, rollback, and matched-verification plan from current trusted evidence.
npx aibill report- Writes local Markdown and HTML reports from the selected evidence window.
npx aibill report-card- Writes a redacted shareable SVG and caption.
npx aibill watch- Records one or more local comparison cycles; one cycle is the cron-friendly default.
The complete, version-matched list is always available from npx aibill --help.
03 · Statusline
Ambient runway without an ambient scanner
npx aibill statusline install
npx aibill statusline refresh
npx aibill statusline uninstallThe optional line is installed only in Claude Code, but its cache can hold separately labeled Claude Code and Codex cohorts. Claude Code asks the runner to render about every 30 seconds; that re-reads the cache and does not rescan transcripts. Use statusline refresh or rerun init when you need fresh evidence.
- Metered mode leads with evidence-labeled dollars.
- Subscription mode leads with transcript-reported runway only; missing limits are not inferred.
- Mixed mode keeps subscribed runway and metered money separate.
~means API-equivalent value. Untildedbilledmoney requires verified provider evidence.- Cache evidence becomes stale after five minutes and is labeled accordingly.
04 · Provider reports
Setup and sync are separate steps
connect registers a local connector stub and prints the exact next command. It does not fetch billing data. Only sync-provider makes the read-only provider API request.
npx aibill connect openai
read -rsp "OpenAI Admin key: " OPENAI_ADMIN_KEY; printf "\n"
export OPENAI_ADMIN_KEY
npx aibill sync-provider --provider openai --auth-reference env:OPENAI_ADMIN_KEY --start-time <unix-seconds>OpenAI and Anthropic connectors have non-empty live verification. Cursor and GitHub Copilot connectors remain fixture-verified beta pending live-account QA. Final invoices can still include credits, discounts, taxes, or later adjustments.
05 · Apply
A plan for an agent, not an autonomous change
npx aibill apply writes a prompt, action plan, policy draft, verification plan, and demo package under the project’s .ai-spend-agent/ directory. In local-transcript mode it freshly rereads the matching evidence. In connected-provider mode it uses receipt-bound state from the latest explicit sync and does not silently contact the provider. It changes no external system.
The prompt asks a coding agent to inspect the cited candidates, show exact changes and rollback, wait for explicit approval, and compare matched future sessions. Sample Apply is explicitly non-executable. Provider buckets or daily aggregates that cannot prove a call-level counterfactual remain reconciliation evidence, not invented savings advice.
The guided npx aibill improve command wraps this loop end to end: it records a named local self-attested approval before printing any agent handoff, reuses one command for the matched experiment, and later calculates the quality-gated before/after result. That percentage belongs to your own matched sessions — it is never a universal saving, provider-bill, or ROI claim.
06 · Continue
Add an interface only when it helps
Install the MCP server when an AI client should query the structured evidence on demand, or build the Glance source preview when you want a compact Mac monitor. Neither replaces the full CLI inspection and Apply workflow.