Files
simplify-code/references/OPTIMIZATION.md
T
Giancarmine SalucciandClaude Opus 4.8 81b33fff26 refactor: report-only skill — actionable findings, no apply/modes
The skill no longer modifies code. It emits exactly two artifacts under simplify/:
findings.json (machine-actionable ledger) + a ranked report. Every finding now REQUIRES
title/action/verify (locked in ledger.schema.json) so each is independently executable by
the calling agent. Removed: apply/report modes, Track A autofix execution, baseline gate,
verify-each-change loop, the include-tests switch (tests excluded by default). Reframed
SKILL.md, README, PATTERNS (deterministic/judgment), DETECTION, OPTIMIZATION (judge-only
model tiering), PORTABILITY, SVELTE, CONSOLIDATION accordingly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 02:53:19 +02:00

3.0 KiB
Raw Blame History

Token & model optimization

Make the model do the least possible work, and only the hard part. These are layered; apply as many as your runtime supports. All are optional accelerators — the skill is correct without any of them.

1. Push work out of the model

  • Detection is the bundled binaries — zero model tokens.
  • Mechanical findings just record a deterministic autofix command in their action — the model never reads their code.
  • Goal: the model only judges difficulty: semantic | hard cross-file candidates.

2. Span-scoped reads

Never read a whole file. From the ledger you already have file + start_line/end_line; read only that range plus a few context lines (~95% fewer read tokens on large files). The codebase enters context only as flagged spans.

3. Cheap-model steps

Use a small/fast model (Haiku / GPT-5-mini / Gemini Flash) for:

  • ledger assembly (Step 3) — mechanical JSON→JSON join with the manifest;
  • classification / triage — mechanical vs semantic, confidence;
  • verification reading — interpreting build/test output (pass/fail + which finding).

4. Model tiering for the JUDGE (capability-detected)

The model is used only to judge cross-file candidates (Pass B), never to edit.

  • Cluster + judge on a cheap model.
  • hard / multi-file / low-confidence → escalate to a frontier model only then. Confidence-based cascading typically cuts cost ~5085% at ~95% quality.
  • How to route, by runtime:
    • Claude Code — sub-agents with a per-agent model: override.
    • pi — provider-agnostic; pick the model per sub-agent/step.
    • Copilot / others without per-step model choice — run on the invoked model and use confidence to decide which findings to include vs leave out (low-confidence clusters simply aren't reported).

5. Optional sub-agent fan-out

On runtimes with sub-agents (Claude Code, pi), run one judge per cluster in parallel isolated contexts; each returns a compact JSON verdict to the parent. Keeps the orchestrator context clean. Falls back to a sequential judge loop everywhere else.

6. Cache-friendly prefix

Keep static context (the pattern catalog, the manifest, the ledger summary) front-loaded and stable so the runtime's prompt cache hits; append per-finding dynamic context (the span) after it. Don't reorder the stable prefix between findings.

7. Resumability = the cheapest rerun

findings.json status is the source of truth. On rerun, load it and process only pending items — an interrupted or repeated run skips finished work (~8090% saving). Don't re-scan-and-overwrite a ledger that still has pending work.

Rough budget intuition

detect = free (binaries). assembly = cheap model, one pass over compact JSON. judging = one cheap-model verdict per cross-file cluster (mechanical/structural findings need no judging — free). So cost scales with the number of cross-file clusters to judge, not with repo size. The skill performs no edits, so there is no apply/verify token cost.