pi-spend

pi-spend is a skill for Claude Code from flurdy/agent-skills. It costs 40 tokens per session (1,392 once invoked), scanned A, original, MIT.

A read-only report of Pi model spending based on the machine's recorded session data. It separates usage charged by provider or model from models covered by a flat subscription.

In plain words
What is it for?
Use it to check costs for today, this week, this month, or all recorded history, grouped by provider and model, with optional JSON output.
Why use it?
It shows recent and historical metered usage without changing billing data or contacting provider billing systems. Results can be limited to selected time periods or metered models.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: model in frontmatter; mentions subagents; mentions Claude Code.

Good fit Use it to check costs for today, this week, this month, or all recorded history, grouped by provider and model, with optional JSON output.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/flurdy/agent-skills/pi-spend
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add flurdy/agent-skills --skill pi-spend
Clone the repo
git clone --depth 1 https://github.com/flurdy/agent-skills

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for pi-spend

README.md
[![agentmods](https://agentmods.dev/badge/skills/flurdy/agent-skills/pi-spend.svg)](https://agentmods.dev/skills/flurdy/agent-skills/pi-spend)
Your own site
<a href="https://agentmods.dev/skills/flurdy/agent-skills/pi-spend"><img src="https://agentmods.dev/badge/skills/flurdy/agent-skills/pi-spend.svg" alt="Measured on agentmods" height="20"></a>
Per session 40 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,392 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00040 $0.01392
Opus 5 $0.00020 $0.00696
Sonnet 5 $0.00008 $0.00278
Haiku 4.5 $0.00004 $0.00139

Measured today against content hash 5570f2c9c122, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

pi-spend scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured today.

The scan reads SKILL.md. This mod also ships 2 executable files (scripts/pi_spend.py, tests/test_pi_spend.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/pi-spend/SKILL.md · 136 lines

How it starts

The opening of the file, as written. The whole thing — 136 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Pi Spend

Answer "what have my metered models cost me lately" from Pi's own session telemetry. Periods are today, the current week (Monday start), the current calendar month, and all recorded history, all in the machine's local timezone.

Usage

/pi-spend                       # all four periods, every provider and model
/pi-spend --metered-only        # show only responses classified as metered
/pi-spend --period today        # single period; repeatable
/pi-spend --json                # normalized schema v2 JSON
/pi-spend --billing-policy PATH # use another effective-dated local policy
/pi-spend --router-config PATH   # explicit legacy current-policy projection

Resolve scripts/pi_spend.py relative to this SKILL.md and run it with the user's arguments:

/path/to/pi-spend/scripts/pi_spend.py --metered-only

Do not substitute ad-hoc transcript greps or provider billing calls for the collector.

Output contract

Paste the collector's complete stdout verbatim in a fenced code block, even when the tool card already shows it. Do not summarize, reformat, or truncate the table. Use a json fence for --json and a plain-text fence otherwise.

Analysis contract

After the verbatim block, add two to four bullets, at most 120 words:

  • name the largest metered rows for the requested period and what drove them, distinguishing cache-read volume from fresh input;
  • state the metered total separately from the subscription total, and never add them into one "spend" figure;
  • call out the unknown billing class when present, since it means no valid interval covers that exact provider/model response rather than that the model is free;
  • call out legacy-current-router-policy as a current-policy projection that may relabel history; and
  • mention responses that recorded no cost only when the collector reports some.

Never describe the output as an invoice, an account balance, or remaining credits.

Sources and authority

  • Pi sessions: ~/.pi/agent/sessions/**/*.jsonl. Assistant messages carry provider, model, usage, and a per-response usage.cost breakdown. Responses are deduplicated by responseId, so nested subagent run transcripts are counted once.
  • Billing class: ~/.pi/agent/pi-spend-billing-policy.json, using exact provider/model entries and the interval covering each response timestamp. Missing or invalid coverage reports as unknown; the collector does not guess from provider or model names.

Read the full file on GitHub · 136 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. today Changed · +51 lines 5570f2c9c122
  2. 8d ago First seen · 85 lines · 40 tokens per session scan A b12e064d0492

Subscribe to this mod's changes

pi-spend is a skill published in the GitHub repository flurdy/agent-skills (9 stars, last pushed yesterday), licensed MIT. It adds 40 tokens to every session and 1,392 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories