agentleFS
Allan-NavaAllan-Nava/qrspi/skills/token-efficiency/SKILL.md

token-efficiency

Skill2 starsChanged 51 days agoMITView on GitHub

Diagnose and cut token consumption in agentic coding workflows — context rot, the 40% rule, intentional compaction, subagents as context firewalls, effort and model selection, prompt-caching invalidation, tool-output hygiene, KPIs. Use when asked why an agent is expensive or slow, when a session is drifting or re-exploring files it already read, when caching is not hitting (cache_read_input_tokens 0 on an unchanged prefix), when MCP tool schemas eat the window in /context, when choosing effort or model per phase, when a CLAUDE.md or prompt needs slimming, or when measuring tokens per completed task.

13 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use tdd.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • GoogleSkill

    tdd

    Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

1 rule. 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 13 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If you track only three, track the first three.

    line 43

“Common” is measured: kept by at least 6 in 10 of the 13 edited versions of this file we could read. “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 efficiency for coding agents

Verified against the Claude API, reference model claude-opus-5. Every reference closes with In Claude Code — the same lever as exercised from the CLI, for readers who never call the API directly.

The mental model

With a 1M window, "does it fit?" is almost always yes. The right question is how much of that context is signal?

Quality degrades long before the window fills. The informal name is context rot: instructions given 200k tokens ago get ignored, the agent re-explores files it already read, mid-session decisions get contradicted, the loop fills with redundant tool calls. The heuristic: keep utilisation under ~40%, then stop and compact.

So the metric is not tokens spent but signal density = useful / total tokens in context. Cost falls as a consequence. An agent at 20% context costs less, errs less and finishes sooner; one at 70% costs more and produces work you redo — and rework is the largest, least measured cost line.

The levers, in order

Order matters. Caching on a workflow that does not compact saves 10%; intentional compaction saves 90%. Do not invert them. Before any of them: measure — references/measuring.md (baseline, usage fields, instrumentation).

#LeverTypical gainReference
1Intentional compaction — artifacts on disk between phases10-20×references/compaction.md
2Subagents as context firewalls, programmatic tool calling5-10× on researchreferences/subagents.md
3Effort calibrated per phase, model choice, task budgets2-3× on output tokensreferences/effort.md
4Prompt caching — the invariant, invalidation, gotchas~10× on repeated prefixesreferences/caching.md (+ caching-api.md for your own loop)
5Tool definitions and output, context editing, memory10-30k per avoided readreferences/tool-hygiene.md

The five KPIs

If you track only three, track the first three.

#KPIFormulaTarget
1Context utilisationpeak total_input / window, per phase< 40%
2Compression ratiotokens burned in phase / artifact tokens> 15×
3Tokens per completed tasksum across phases, per closed tasktrend ↓
4Cache hit ratiocache_read / (cache_read + input_tokens)> 70% in Implement
5Rework ratephases re-run / total phases< 15%
  • KPI 5 is the canary. High rework almost always means a badly written upstream artifact, not the model or the effort. Read the artifact before raising effort.
  • KPI 4 is read per phase, never aggregated. Research is naturally low (content is always new); in Implement, under 70% means you have an invalidator.
  • KPI 2 under 10× means the artifact carries material that should have stayed in the previous phase.

Beyond the five, load only what the question needs: references/anti-patterns.md (the table) and references/playbook.md (4-week rollout, prices, beta headers). Lever #1 as a workflow is the qrspi skill; the craft of the artifact it depends on is handoff.

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.