agentleFS
89jobrien89jobrien/godmode/skills/token-cost-optimizer/SKILL.md

token-cost-optimizer

Skill1 starsChanged 56 days agoMITView on GitHub

Use when analyzing Claude or agent token usage, ccusage reports, output-to-input token ratios, model spend, or ways to lower AI coding costs. Symptoms - the user asks "why is Claude expensive", "analyze token usage", "reduce token usage", "optimize costs", "make agents less verbose", "lower output/input ratio", or shares `ccusage` output. Produces concise technical strategies, model-routing rules, and copy-paste cost-control policies.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

27 rules. About 0 are common, 26 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈26

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this when the user wants to understand or reduce LLM/agent costs.

    line 10
  2. Distinctive:

    Do not assume input tokens are the problem just because token totals are large.

    line 12
  3. Distinctive:

    Prefer already-attached command output when available.

    line 17
  4. Very specific:

    If more data is needed and ccusage is available, run read-only reports.

    line 18
  5. Distinctive:

    Use JSON output for aggregates and rendered output for quick inspection.

    line 19
  6. Distinctive:

    Use tighter response formats and review filters.

    line 42
  7. Distinctive:

    Keep the response concise.

    line 46
  8. Distinctive:

    Avoid broad generic advice when a measured driver is available.

    line 48
  9. Distinctive:

    Do not paste full command output back to the user.

    line 49
  10. Distinctive:

    Default final answers to 150 words unless detail is requested.

    line 55
  11. Distinctive:

    Do not paste full files, full diffs, or full logs unless explicitly requested.

    line 57
  12. Distinctive:

    Prefer file paths, symbols, and short conceptual summaries over copied code.

    line 58
  13. Distinctive:

    Keep progress updates brief and save detailed findings for final conclusions.

    line 59
  14. Distinctive:

    Use Haiku for triage, summarization, log clustering, issue extraction, and simple classification.

    line 63
  15. Distinctive:

    Use Sonnet for normal coding, debugging, test repair, and code review.

    line 64
  16. Distinctive:

    Use Opus only for ambiguous root cause analysis, architectural tradeoffs, security-sensitive review, or after cheaper models fail.

    line 65
  17. Distinctive:

    If a session becomes Opus-heavy, stop and confirm the escalation is still worth the spend.

    line 66
  18. Distinctive:

    Avoid repeatedly re-explaining the same root cause after it is established.

    line 73
  19. Distinctive:

    Use parallel agents only for independent tasks.

    line 77
  20. Distinctive:

    Avoid broad "research everything" prompts that cause duplicated summaries.

    line 79
  21. Distinctive:

    Start a fresh session after unrelated tasks to avoid carrying excess context.

    line 83
  22. Distinctive:

    Prefer targeted file reads/searches over pasting large context into prompts.

    line 84
  23. Distinctive:

    Keep stable rules short; long always-on rules increase cache creation and can make every turn heavier.

    line 85
  24. Distinctive:

    Use this as a standing cost-control rule:

    line 89
  25. Distinctive:

    Use this for review tasks:

    line 95
  26. Distinctive:

    Use this for debugging:

    line 101
  27. Distinctive:

    When presenting analysis, use this structure:

    line 109

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Token Cost Optimizer

When to Use

Use this when the user wants to understand or reduce LLM/agent costs. Focus on measured drivers before giving advice: model mix, output volume, cache creation, session length, subagent fan-out, and repeated verbose reporting. Do not assume input tokens are the problem just because token totals are large; generated output and expensive model choice are often the largest controllable costs.

Workflow

  1. Gather usage data.
    • Prefer already-attached command output when available.
    • If more data is needed and ccusage is available, run read-only reports.
    • Use JSON output for aggregates and rendered output for quick inspection.
ccusage monthly --json --offline
ccusage weekly --json --offline
ccusage daily --breakdown --offline
ccusage session --breakdown --offline
ccusage daily --instances --breakdown --offline
ccusage blocks --offline
  1. Identify cost drivers.
    • Total cost and trend by month/week/day.
    • Output/input ratio using direct input and output tokens.
    • Per-model cost share, especially Opus and Sonnet.
    • High-cost days, sessions, blocks, or projects.
    • Cache creation versus cache reads; high cache creation can signal repeated context rebuilds.
    • Multipliers from parallel agents, long reviews, broad planning, or verbose final summaries.
  2. Recommend controls in priority order.
    • Reduce generated output first.
    • Route simple work to cheaper models.
    • Make Opus explicit/escalation-only.
    • Use tighter response formats and review filters.
    • Limit subagent fan-out and long-running sessions.
    • Audit the specific sessions/projects causing spikes.
  3. Keep the response concise.
    • Give numbers first, then actions.
    • Avoid broad generic advice when a measured driver is available.
    • Do not paste full command output back to the user.

Cost Controls

Output budget

  • Default final answers to 150 words unless detail is requested.
  • For code changes, report only Changed, Validated, and Risks.
  • Do not paste full files, full diffs, or full logs unless explicitly requested.
  • Prefer file paths, symbols, and short conceptual summaries over copied code.
  • Keep progress updates brief and save detailed findings for final conclusions.

Model routing

  • Use Haiku for triage, summarization, log clustering, issue extraction, and simple classification.
  • Use Sonnet for normal coding, debugging, test repair, and code review.
  • Use Opus only for ambiguous root cause analysis, architectural tradeoffs, security-sensitive review, or after cheaper models fail.
  • If a session becomes Opus-heavy, stop and confirm the escalation is still worth the spend.

Review and debugging limits

  • For code review, report only actionable correctness, security, data-loss, race-condition, and broken-test findings.
  • Suppress compliments and low-value style nits.
  • For logs, extract failing test names, file paths, line numbers, and the first causal error.
  • Avoid repeatedly re-explaining the same root cause after it is established.

Subagent controls

  • Use parallel agents only for independent tasks.
  • Give each subagent a strict return format: answer, evidence, confidence, max five bullets.
  • Avoid broad "research everything" prompts that cause duplicated summaries.

Session hygiene

  • Start a fresh session after unrelated tasks to avoid carrying excess context.
  • Prefer targeted file reads/searches over pasting large context into prompts.
  • Keep stable rules short; long always-on rules increase cache creation and can make every turn heavier.

Copy-Paste Policy

Use this as a standing cost-control rule:

Default to concise responses. Keep final answers under 150 words unless I ask for detail. Do not paste full files, full diffs, or full logs unless requested. For implementation work, report only Changed, Validated, and Risks. Use cheaper models for triage and summarization. Treat Opus as escalation-only for hard root-cause, architecture, or security-sensitive work.

Use this for review tasks:

Review only for correctness, security, data loss, race conditions, broken tests, and maintainability issues that can cause real bugs. Suppress compliments, style nits, and restatements of the diff. One concise paragraph per finding.

Use this for debugging:

Extract only the failing command, failing test or operation, file paths, line numbers, and first causal error. State the likely root cause only after evidence is collected. Do not include full logs unless I ask.

Report Shape

When presenting analysis, use this structure:

  • Trend: cost and token direction over time.
  • Drivers: model mix, output/input ratio, high-cost sessions, cache behavior.
  • Actions: the smallest set of controls likely to reduce spend.
  • Next audit: one or two commands to identify the next bottleneck.

Common Misreads

  • High total token count may be cache reads, not direct expensive generation.
  • A low input token count with high cost usually points to output volume or expensive model choice.
  • Monthly cost can look lower early in a month; compare run rate, not just absolute spend.
  • Broad review, planning, and subagent workflows can cost more than implementation.
  • Adding more input does not fix a high output/input ratio; reduce unnecessary output instead.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.