token-cost CLAUDE.md

Project instructions for token-cost, a tool that records and reports how many language-model tokens coding-agent work uses. They define the current ledger format and rules for rebuilding it from saved session records.

In plain words
What is it for?
Use them when developing or maintaining token-cost, especially when changing its ledger format, rebuilding records, or preparing a local release.
Why use it?
They prevent incompatible old-data handling and keep token records limited to the project where the tool is being used.

Instructions file

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.

agentmods
npx agentmods add instructions/peiris/token-cost/claude-md
Clone the repo
git clone --depth 1 https://github.com/peiris/token-cost
Per session 982 This file is loaded in full into every session.
When invoked 982 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
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 $0.00982 $0.00982
Opus 5 $0.00491 $0.00491
Sonnet 5 $0.00196 $0.00196
Haiku 4.5 $0.00098 $0.00098

Measured 2d ago against content hash 14e7bdbc5d73, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

token-cost CLAUDE.md 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 2d ago.

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.

CLAUDE.md · 79 lines

How it starts

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

token-cost — project rules

No legacy support, at all

This plugin is a work in progress with a single user (the author, for testing). The current ledger format is the only format.

  • Never write code that reads, repairs, migrates, or improves rows written by older plugin versions — no version-aware branches, no post-hoc fix-up passes, no "this field may be missing on old rows" fallbacks, no display states that mean "recorded before we tracked this".
  • When the ledger format changes: bump ledger.FORMAT and the plugin version. A project whose format stamp disagrees is rebuilt from its own transcripts by that project's next sync() — SessionStart there, /token-cost, the UI, or --backfill. Rebuilds are staged (scratch file, one rename, stamp written last, .bak left beside) so a killed hook leaves either the old world or a finished rebuild. Lossless only while Claude Code still keeps the transcripts (~30 days), so a format bump wants releasing promptly.
  • The plugin acts on the current project only. Nothing — code or agent — may enumerate, rebuild, or write other projects' ledgers. Healing happens where the user actually runs token-cost, never machine-wide.
  • Version numbers are burned: never reuse or roll back one — the plugin cache is keyed by the version string.

The one distinction that is NOT legacy support: robustness toward Claude Code's own transcript format (e.g. is_human_prompt()'s field fallbacks). Those files are input we read but don't control, and old ones legitimately sit on disk.

Publishing ends at the local install, not at the push

The author's own Claude Code runs the installed plugin, not this checkout, so a release the local install never received changed nothing.

  • Publish without being asked. Finishing a change means releasing it: once the work is done and verified, run the full publish sequence below as part of the same task — don't stop at the working tree and offer to release.
  • Publish = bump the plugin version, commit, push, then both installs: claude plugin update token-cost@token-cost for the CLI — the bare name doesn't resolve; the @token-cost marketplace suffix is required — and python3 dev/resync_claudeai.py for Claude Desktop. Each needs its own restart to apply.
  • Push before updating: the marketplace pulls from GitHub, not from this directory. And without a version bump there is nothing for it to pull — the cache is keyed by the version string.
  • Claude Desktop is a second install, and it wins. Where a plugin exists both locally and on claude.ai, the desktop runs the claude.ai copy and ignores the one the CLI installed. claude.ai only re-clones the repo when asked — the marketplace says auto_sync_on_push but has no webhook behind it — so claude plugin update alone leaves the desktop on whatever commit claude.ai last saw, with its Update button reading "On latest version". dev/resync_claudeai.py is the ask; it exits non-zero unless claude.ai lands on HEAD.
  • A re-sync that changes hooks or executables comes back flagged exec_surface_changed. That is claude.ai noting the plugin's exec surface moved, not a failed sync — the new version is stored.

Read the full file on GitHub · 79 lines

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. 2d ago First seen · 79 lines · 982 tokens per session scan A 14e7bdbc5d73

Subscribe to this mod's changes

token-cost CLAUDE.md is an instructions file published in the GitHub repository peiris/token-cost (2 stars, last pushed 5d ago), licensed MIT. It adds 982 tokens to every session, about $0.0049 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.