agentleFS
Luis85Luis85/agentic-workflow/.claude/skills/token-budget-review/SKILL.md

token-budget-review

Skill0 starsChanged 6 months agoMITView on GitHub

Audit project token usage by area (always-loaded, skills, examples, docs, worktrees, templates, ops bots), surface offenders, emit area-grouped cleanup plan. Trigger /token-review.

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run quarterly, before a release, or when an agent reports unexplained slowdowns.

    line 10
  2. Very specific:

    Run the queries in MEASURE.md end-to-end.

    line 27
  3. Very specific:

    Use PLAN-TEMPLATE.md to scaffold docs/superpowers/plans/<date>-token-budget-cleanup.md.

    line 54

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 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 Budget Review

Audit how much of the prompt budget the repo burns on every Claude Code session, surface offenders by area, and emit a cleanup plan one PR per area.

Run quarterly, before a release, or when an agent reports unexplained slowdowns.

When to invoke

  • Slash: /token-review (or /token-review <slug> to scope to a sub-tree).
  • Natural language: "review token usage", "audit token budget", "the prompt feels heavy", "where is our context going".
  • Automated: as a scheduled /loop or /schedule agent, monthly.

Outputs

  • /tmp/token-audit-<YYYY-MM-DD>.txt — raw measurements (intermediate; not committed).
  • docs/superpowers/plans/<YYYY-MM-DD>-token-budget-cleanup.md — area-grouped implementation plan with one chunk per area, plus a Chunk 0 mechanical compress and a final guardrail chunk.

Phases

Phase 1 — Measure

Run the queries in MEASURE.md end-to-end. Capture output to /tmp/token-audit-<date>.txt. Do not skip queries — each surfaces a different category of waste.

The measurement set covers:

  1. Always-loaded chain — CLAUDE.md + AGENTS.md + memory/constitution.md + .claude/memory/MEMORY.md (loaded every session).
  2. Skill catalog — frontmatter description: field of every .claude/skills/*/SKILL.md (rendered into the system prompt).
  3. Skill bodies — full text of every SKILL.md (loaded on invocation).
  4. Agent prompts — .claude/agents/*.md (loaded on subagent dispatch).
  5. Examples sub-tree — examples/**/*.md (silent token bomb if agents read for "reference").
  6. Worktree pollution — .worktrees/**/*.md (full repo copies; inflates Glob/Grep).
  7. Docs heavyweights — README.md, docs/sink.md, top ADRs.
  8. Templates — templates/**/*.md.
  9. Operational bot prompts — agents/operational/*/PROMPT.md.

Phase 2 — Surface offenders

For each area, identify:

  • Top 3-5 files by size.
  • Files exceeding the cap defined in docs/token-budget.md (when present).
  • Duplication / cross-file overlap (e.g. CLAUDE.md ↔ AGENTS.md).
  • Forward-deferred references that could be lazy-loaded.

Rank areas by per-session impact (how often the artifacts are loaded). The always-loaded chain and skill catalog dominate.

Phase 3 — Emit plan

Use PLAN-TEMPLATE.md to scaffold docs/superpowers/plans/<date>-token-budget-cleanup.md. The template includes:

  • Header with goal, architecture, branch convention.
  • Audit summary table (one row per area).
  • One chunk per area, each one PR.
  • Chunk 0 = mechanical /caveman:compress pass on the heaviest natural-language files.
  • Final chunk = verify-gate guardrail (so the savings can't regress).
  • An optional repeatable-skill chunk that re-runs this very audit.

Each chunk lists: files, branch name, ordered checkbox steps, commit + PR commands.

Phase 4 — Hand off

Recommend running the plan with superpowers:subagent-driven-development (Claude Code) or superpowers:executing-plans (other harnesses). Each chunk = one PR cut from the integration branch (or stacked off the umbrella per the plan). Order chunks by ROI (always-loaded first, guardrail last).

What this skill does NOT do

  • It does not apply changes itself. The skill measures and plans; execution is delegated.
  • It does not prune .worktrees/<slug>/ automatically — that's destructive (Article IX). Surface candidates; let the human decide.
  • It does not modify ADRs in place — ADR bodies are immutable; suggest superseding instead.

See also

  • docs/superpowers/plans/ — past cleanup plans.
  • docs/token-budget.md — the budget policy + verify-gate hook (added in a follow-up).
  • MEASURE.md — measurement queries.
  • PLAN-TEMPLATE.md — output template.

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.