token-cost-audit

token-cost-audit is a command for Claude Code from sigistry/marketplace. It costs 20 tokens per session (772 once invoked), scanned A, original, MIT.

A command that reviews large language model (LLM) calls for unnecessary token use and spending. Tokens are the small text units models read and generate, and providers often charge by their number.

In plain words
What is it for?
Use it to map model call sites, measure likely savings, and apply safe changes to prompts, context assembly, caching, model choices, and loops.
Why use it?
It identifies repeated prompts, oversized context, missing caching, and other avoidable work that increases response cost and can reduce efficiency.

Command for Claude Code

Written for Claude Code: argument-hint in frontmatter. Also seen: model in frontmatter.

Part of the llm-app-hardener plugin — 4 skills, 4 commands, 2 agents shipped together

Good fit Use it to map model call sites, measure likely savings, and apply safe changes to prompts, context assembly, caching, model choices, and loops.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/sigistry/marketplace/token-cost-audit
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.

Clone the repo
git clone --depth 1 https://github.com/sigistry/marketplace

Made for: Claude Code.

Or install llm-app-hardener, the plugin that ships this one along with the rest of its 4 skills, 4 commands, 2 agents.

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-audit

README.md
[![agentmods](https://agentmods.dev/badge/commands/sigistry/marketplace/token-cost-audit/github.svg)](https://agentmods.dev/commands/sigistry/marketplace/token-cost-audit)
Your own site
<a href="https://agentmods.dev/commands/sigistry/marketplace/token-cost-audit"><img src="https://agentmods.dev/badge/commands/sigistry/marketplace/token-cost-audit/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-audit

Your own site · 80×15
<a href="https://agentmods.dev/commands/sigistry/marketplace/token-cost-audit"><img src="https://agentmods.dev/badge/commands/sigistry/marketplace/token-cost-audit.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 20 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 772 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.00020 $0.00772
Opus 5 $0.00010 $0.00386
Sonnet 5 $0.00004 $0.00154
Haiku 4.5 $0.00002 $0.00077

Measured 7d ago against content hash 3f4ab829741a, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

token-cost-audit 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 7d 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.

plugins/llm-app-hardener/commands/token-cost-audit.md · 41 lines

How it starts

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

Audit the LLM call sites at $ARGUMENTS (default: the current diff, or the app's model-calling modules) for token and cost waste, quantify the potential reduction, and dispatch the token-cost-optimizer agent to apply the safe wins. Large cost cuts (frequently 60–85%) are routinely on the table in LLM apps but hide behind tedious manual auditing, this command does that auditing directly on your call sites and prompt assembly.

Process

Step 1: Detect the provider(s) and map the call sites

Identify each SDK in use (Anthropic, OpenAI, Gemini/Vertex, LangChain, LlamaIndex, Vercel AI SDK) and enumerate the call sites, the system prompts they send, and how per-turn context is assembled. Note the model tier each call uses and whether calls run in a loop.

Step 2: Classify the waste

Score each site against this catalog:

Issue Signal Fix
Oversized / duplicated system prompt Multi-KB system string, or the same preamble rebuilt per request Extract once; trim dead instructions
No prompt caching Stable prefix re-sent uncached every call Enable prompt caching on the stable prefix
Cache-busting prefix now()/UUID/unsorted JSON early in the prompt Move volatile content after the cache breakpoint
Redundant context re-sent Full history/RAG docs resent each turn unchanged Cache, trim, or window the context
Over-powered model tier Frontier model on classification/extraction/routing Route easy tasks to a cheaper tier
Missing max_tokens No output cap on a bounded task Set a sensible cap
Unbatched calls Independent calls in a serial loop Batch, or use the batch endpoint

Step 3: Quantify

For each finding, estimate the token/cost reduction from what is visible in code: prompt size (count the tokens in the static string), call frequency, cache hit-rate opportunity (reads cost a small fraction of base input; a stable multi-KB prefix reused across calls is the highest-leverage win), and tier price deltas (cheaper tiers are typically several times less per token). State assumptions; mark anything needing a production token count as estimated.

Read the full file on GitHub · 41 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. 7d ago First seen · 41 lines · 20 tokens per session scan A 3f4ab829741a

Subscribe to this mod's changes

token-cost-audit is a command published in the GitHub repository sigistry/marketplace (3 stars, last pushed today), licensed MIT. It adds 20 tokens to every session and 772 once invoked, about $0.0001 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-09-03.