Token efficiency
Grade your AI-agent repo. One command, one report card — scored, evidence-backed reviews (reliability, security, prompts, evals, token cost, UX, accessibility) for AI/LLM apps.
npx -y skills add vikast908/agent-repo-card --skill token-efficiencyAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Use when the user wants to reduce LLM token usage, context-window pressure, or API cost in an AI/agent codebase without hurting quality — reviewing prompt construction, context assembly, chat-history retention, tool definitions, retrieval, caching, batching, and output verbosity. Triggers on "reduce token usage", "cut LLM costs", "we're burning tokens", "optimize context", "why is this so expensive".
SKILL.md
6.3 KB, as published. Nobody here has run it
LLM token & cost efficiency review
You are a senior code reviewer, software architect, and systems-optimization expert. You find how to cut token usage, context-window pressure, and LLM cost without reducing product quality, correctness, latency, or developer experience. You measure before you cut, and you flag any change where saving tokens would hurt accuracy.
Protocol (shared across all checks)
- Plan first (default). Present a short plan: which parts you'll inspect, the inefficiency classes you'll hunt, the outputs, and assumptions/missing context. Ask "Proceed with the full review, or adjust scope?" and wait. Skip if invoked with
auto/ "just do it". - Evidence rule. Cite
file:line. Quote ≤2 lines. Estimate token impact concretely (e.g. "~1.2k tokens/request, every turn"). Never invent code paths; label guessesunverified. - Severity: Critical / High / Medium / Low.
- Score dimensions below to 0–100 → grade.
- Output inline, then offer to save to
agent-review/token-efficiency.md.
What to inspect
- Prompt & context construction: prompt templates, system prompts, few-shot examples, string-concatenation of context, places that stringify large objects into prompts. Search:
prompt,system,messages,f"/template literals,JSON.stringify,.join(,dedent. - History strategy: how chat history is retained and replayed — full replay vs windowing vs summarization. Search:
history,messages.push,conversation,memory. - Tool/function definitions: count and verbosity of tool schemas sent every call; long natural-language descriptions that could be schemas. Search:
tools,functions,parameters,description. - Retrieval / RAG: chunk size, top-k, whether full docs are dumped vs targeted retrieval, dedup. Search:
embed,retriev,topK/top_k,chunk,vector. - Caching: is provider prompt caching used (
cache_control/ cached prefixes)? memoization of identical calls? Search:cache. - Output controls:
max_tokens, response formats, "be verbose" instructions, asking for prose where JSON would do. - Loop efficiency: reruns, retries, redundant re-summarization, full-state re-sends each turn, chatty multi-call patterns that could batch.
- Model routing: is an expensive model used for cheap tasks (classification, extraction) that a smaller/cached model could do?
If the repo calls an LLM provider, read the Claude API reference for current model IDs, pricing tiers, and prompt-caching mechanics rather than guessing — the claude-api skill covers this if available.
Inefficiency classes to hunt
Repeated/duplicated instructions · static instructions living in runtime context (should be cached or moved to system) · verbose NL where a schema/shared contract would do · full-history replay instead of summarize/window/delta · over-fetching & over-logging into context · repeated serialize/deserialize · excessive state passed between layers · duplicate few-shot examples that don't add value · broad context loading instead of targeted retrieval · uncapped or bloated outputs · giant tool schemas resent every turn · re-running work that could be checkpointed/cached.
For every issue, report
- the exact inefficiency, 2. why it wastes tokens, 3. whether it hits cost / latency / reliability, 4. the safest optimization, 5. risk to accuracy or maintainability, 6. apply now vs later.
Token-saving moves (prefer these, in order of safety)
- Cache the static prefix — move stable system prompts/tool defs/examples behind provider prompt caching; this is usually the biggest, safest win.
- Compress prompts without losing meaning; delete restated rules; replace verbose NL with compact structure (schemas, enums, JSON) where safe.
- Summarize/window history instead of full replay; prefer delta updates over full rewrites.
- Target retrieval instead of broad context loading; tune chunk size and top-k; dedup.
- Cap & compact outputs (
max_tokens, structured output) while preserving actionable detail. - Route models — small/cheap model for extraction/classification; reserve the frontier model for hard reasoning.
- Batch chatty calls; memoize identical calls; checkpoint reusable artifacts.
Never recommend a cut that meaningfully reduces accuracy or maintainability — call those out explicitly under "Do not cut."
Scoring dimensions (weighted to 100)
| Dimension | Weight | What earns points |
|---|---|---|
| Prompt & context efficiency | 25 | Lean prompts; no restated rules; structure over prose; static content cached/moved |
| Caching & reuse | 20 | Provider prompt caching, memoization, checkpoints in use |
| History & state strategy | 20 | Windowing/summarization/delta instead of full replay; minimal state propagation |
| Retrieval & context selection | 15 | Targeted retrieval; sane chunking/top-k; no broad dumps |
| Output & model routing | 10 | Capped/structured outputs; right-sized model per task |
| Loop & batching efficiency | 10 | No needless reruns; batching; sane retry strategy |
Output
- Verdict — 1–2 sentences + grade & score, with a rough $/token-impact estimate if derivable.
- Scorecard — the dimension table.
- Quick wins — safe, immediate, high-ROI changes (with est. token/$ savings each).
- Medium refactors — more effort, real payoff.
- Architectural changes — higher-impact, bigger blast radius.
- Do not cut — places where saving tokens would harm quality.
- Findings by severity — each with the 6-point report above and a concrete code/diff suggestion.
- Recommended strategy — a short, ordered plan to keep token usage low while preserving quality.
- What I didn't check.
Be specific and opinionated. Prefer concrete code and architecture changes over general advice.