token-cost: Instructions file for Claude Code

CLAUDE.md

token-cost CLAUDE.md is an instructions file for Claude Code from peiris/token-cost. It costs 982 tokens per session, scanned A, original, MIT.

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 for Claude Code

Written for Claude Code: SessionStart hook event. Also seen: mentions Claude Code.

This is peiris/token-cost's own configuration. It tells Claude Code how to work on token-cost itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything token-cost configures →

Reuse

Borrowing it

Nothing to install: this file belongs to peiris/token-cost. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/peiris/token-cost/main/CLAUDE.md
Clone the repo
git clone --depth 1 https://github.com/peiris/token-cost

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

README.md
[![agentmods](https://agentmods.dev/badge/instructions/peiris/token-cost/claude-md/github.svg)](https://agentmods.dev/instructions/peiris/token-cost/claude-md)
Your own site
<a href="https://agentmods.dev/instructions/peiris/token-cost/claude-md"><img src="https://agentmods.dev/badge/instructions/peiris/token-cost/claude-md/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for token-cost CLAUDE.md

Your own site · 80×15
<a href="https://agentmods.dev/instructions/peiris/token-cost/claude-md"><img src="https://agentmods.dev/badge/instructions/peiris/token-cost/claude-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
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. 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.00982 $0.00982
Opus 5.5 $0.00393 $0.00393
Sonnet 5.5 $0.00196 $0.00196
Haiku 4.5 $0.00098 $0.00098

Measured 1mo ago against content hash 14e7bdbc5d73, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 1mo 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. 1mo 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 2mo ago), licensed MIT. It adds 982 tokens to every session, about $0.0039 per session on Opus 5.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 instructions, from other repositories