Tuning skills, subagents, and their context layout
This skill is about making skills and subagents cheaper per use and more correct, and
about not getting fooled by plausible-but-wrong intuitions while doing it. The guidance here is
empirically grounded — the headline verdicts below came from A/B tests, and a few of them
overturned the "obvious" design. When you apply this skill, you measure before you presume.
The one mental model: hot vs cold
Every piece of context lives in one of two states. Internalize this — every decision flows from it.
| state |
where it lives |
cost |
| HOT |
CLAUDE.md, an agent's .md body, a skills:-preloaded SKILL.md, the system prompt |
in context every turn / every invocation — paid N times |
| COLD |
references/*, a blueprint doc, any file reached by Read/Grep |
paid only when read — a tool call away |
The whole game is putting the right things in the right state. Hot is a standing tax; cold is
pay-per-use. Optimizing is mostly moving rarely-needed detail from hot to cold, and keeping
hot to {what's needed almost every time + what must never be skipped}.
Hard-won verdicts (measured, often counter-intuitive)
Lead with these. Several contradict the natural guess — that's exactly why they're worth stating.
A grep/anchor index over a small, well-structured doc gives ~no retrieval benefit.
Markdown headers are already grep targets; an agent greps ## 7. or a keyword on its own.
Adding <!-- tag --> anchors + a token index measured worse (more lines read, same tool
calls) on docs in the hundreds of lines. Don't add index machinery by reflex. → references/file-indexes.md
An index inside HOT content is pointless. If the whole file is already in context, there
is nothing to "grep to" — the agent has every line. Anchors in a hot file are dead weight.
The real token win is the TRIM, not the index. Moving mid-depth prose out of an
always-loaded file (CLAUDE.md / agent body) into a cold reference is what actually saves
tokens. The index that often accompanies it is usually ceremony. → references/hot-vs-cold.md
Cold references are read reluctantly. On a neutral prompt, a subagent will answer from
its hot context + training and not open a relevant cold reference — even one engineered to
be needed. It reads when: the fact is clearly project-specific or version-sensitive (a
ground truth it knows it lacks), when it senses it can't recall a precise value, or when
the prompt induces it. → references/ab-test-harness.md
The silent-skip failure is the dangerous one. If a critical fact lives only in a cold
reference and the model's training is stale/wrong, the agent never looks and answers
confidently wrong — silently. Fixing this is a rules problem, and the fix is layered and
measurable. → references/subagent-verification-rules.md
Provenance forcing is the cheapest robust fix. Requiring an agent to state where a
specific claim came from converts a silent confident-wrong answer into a visibly-flagged
estimate, even when it still doesn't read the reference. It fired reliably across tests where
the read-trigger only fired sometimes. → references/subagent-verification-rules.md
Measure, don't presume — and clean up after yourself. The A/B harness below is how every
verdict above was earned. Agent memory contaminates repeat tests; clean it between runs. →
references/ab-test-harness.md, references/memory-hygiene.md
When to reach for what
| The user wants to… |
Do this |
Reference |
| Decide CLAUDE.md vs reference; cut a long hot file |
Hot/cold triage + trim |
references/hot-vs-cold.md |
| Add/judge a grep index, anchors, table-of-contents |
Apply the index cost test (usually: don't) |
references/file-indexes.md |
| Know if a prompt/rule/skill change actually helped |
Run the A/B harness with transcript instrumentation |
references/ab-test-harness.md |
| Fix a subagent that won't read its docs / answers stale |
Add the verification + provenance rules |
references/subagent-verification-rules.md |
| Run tests on subagents without poisoning future runs |
Clean agent-memory / reflection_store / index |
references/memory-hygiene.md |
Core workflow
Whatever the specific ask, the shape is the same: characterize → hypothesize → A/B → keep what wins.
Characterize. Read the target (skill, agent .md, CLAUDE.md, the doc). For every chunk,
ask: hot or cold? Used almost-every-time or occasionally? Load-bearing (must-never-skip) or
optional depth? This classification is most of the analysis.
Hypothesize a change, and predict its effect in hot/cold terms. "Move §X to a reference"
→ saves hot tokens. "Add an anchor index" → predict ~no retrieval gain on a small doc (verdict
1); say so. "Add a verify rule" → predict it fires for project/version-specific facts.
A/B test it when the effect is non-obvious or the user wants proof. Same prompt, change
only the one variable (the rule, the skill, the doc layout) → clean causal attribution.
Instrument via the transcript, not self-report: count tool calls, lines read (input
proxy), correctness, and provenance honesty (claimed source vs actual tool call). Full
protocol in references/ab-test-harness.md.
Keep what wins, revert what doesn't, and say what you measured. Don't ship ceremony. If
the index didn't help, drop it; if the trim saved tokens, keep it; if a rule fired only
partially, report the limit honestly rather than overclaiming.
Clean up. If you ran subagent tests, scrub the memory they generated
(references/memory-hygiene.md) so it can't contaminate later work.
Anti-patterns this skill exists to stop
- Index-by-reflex. Adding anchors/TOC/grep-tokens to every doc "for navigability." Measure
first; on small docs it's cost without benefit (verdict 1).
- Hoarding hot. Letting CLAUDE.md / an agent body accrete mid-depth prose that's needed 5% of
the time. That prose is a per-turn tax. Push it cold.
- Burying must-apply rules cold. A non-negotiable, divergent-from-default, or version-pinned
fact placed only in a reference will be silently skipped (verdict 5). Critical → hot, or guard
it with a verify/provenance rule.
- Presuming instead of measuring. "This is obviously better" is how the grep-index almost
shipped as dogma. Run the A/B; let the transcript decide.
- Leaving test memory behind. Subagent runs write
agent-memory + reflection_store +
index entries that re-inject into later runs. Always clean.
1---2name: tune-skills-and-agents3description: Analyze, test, and improve skills, subagents, and their context layout — what lives HOT vs COLD, whether a grep/file index earns its cost, why a subagent won't read its references, cutting per-turn token bloat, and A/B testing a prompt or rule change.4---56# Tuning skills, subagents, and their context layout78This skill is about making skills and subagents **cheaper per use** and **more correct**, and9about not getting fooled by plausible-but-wrong intuitions while doing it. The guidance here is10**empirically grounded** — the headline verdicts below came from A/B tests, and a few of them11overturned the "obvious" design. When you apply this skill, you measure before you presume.1213## The one mental model: hot vs cold1415Every piece of context lives in one of two states. Internalize this — every decision flows from it.1617| state | where it lives | cost |18| --- | --- | --- |19| **HOT** | CLAUDE.md, an agent's `.md` body, a `skills:`-preloaded SKILL.md, the system prompt | in context **every turn / every invocation** — paid N times |20| **COLD** | `references/*`, a blueprint doc, any file reached by Read/Grep | paid **only when read** — a tool call away |2122The whole game is putting the right things in the right state. Hot is a standing tax; cold is23pay-per-use. Optimizing is mostly **moving rarely-needed detail from hot to cold**, and keeping24hot to {what's needed almost every time + what must never be skipped}.2526## Hard-won verdicts (measured, often counter-intuitive)2728Lead with these. Several contradict the natural guess — that's exactly why they're worth stating.29301. **A grep/anchor index over a *small, well-structured* doc gives ~no retrieval benefit.**31 Markdown headers are *already* grep targets; an agent greps `## 7.` or a keyword on its own.32 Adding `<!-- tag -->` anchors + a token index measured *worse* (more lines read, same tool33 calls) on docs in the hundreds of lines. Don't add index machinery by reflex. → `references/file-indexes.md`34352. **An index inside HOT content is pointless.** If the whole file is already in context, there36 is nothing to "grep to" — the agent has every line. Anchors in a hot file are dead weight.37383. **The real token win is the TRIM, not the index.** Moving mid-depth prose out of an39 always-loaded file (CLAUDE.md / agent body) into a cold reference is what actually saves40 tokens. The index that often accompanies it is usually ceremony. → `references/hot-vs-cold.md`41424. **Cold references are read *reluctantly*.** On a neutral prompt, a subagent will answer from43 its hot context + training and *not* open a relevant cold reference — even one engineered to44 be needed. It reads when: the fact is clearly **project-specific or version-sensitive** (a45 ground truth it knows it lacks), when it **senses it can't recall a precise value**, or when46 the prompt induces it. → `references/ab-test-harness.md`47485. **The silent-skip failure is the dangerous one.** If a critical fact lives *only* in a cold49 reference and the model's training is stale/wrong, the agent never looks and answers50 confidently wrong — silently. Fixing this is a rules problem, and the fix is layered and51 measurable. → `references/subagent-verification-rules.md`52536. **Provenance forcing is the cheapest robust fix.** Requiring an agent to state *where* a54 specific claim came from converts a silent confident-wrong answer into a visibly-flagged55 estimate, even when it still doesn't read the reference. It fired reliably across tests where56 the read-trigger only fired sometimes. → `references/subagent-verification-rules.md`57587. **Measure, don't presume — and clean up after yourself.** The A/B harness below is how every59 verdict above was earned. Agent memory contaminates repeat tests; clean it between runs. →60 `references/ab-test-harness.md`, `references/memory-hygiene.md`6162## When to reach for what6364| The user wants to… | Do this | Reference |65| --- | --- | --- |66| Decide CLAUDE.md vs reference; cut a long hot file | Hot/cold triage + trim | `references/hot-vs-cold.md` |67| Add/judge a grep index, anchors, table-of-contents | Apply the index cost test (usually: don't) | `references/file-indexes.md` |68| Know if a prompt/rule/skill change actually helped | Run the A/B harness with transcript instrumentation | `references/ab-test-harness.md` |69| Fix a subagent that won't read its docs / answers stale | Add the verification + provenance rules | `references/subagent-verification-rules.md` |70| Run tests on subagents without poisoning future runs | Clean agent-memory / reflection_store / index | `references/memory-hygiene.md` |7172## Core workflow7374Whatever the specific ask, the shape is the same: **characterize → hypothesize → A/B → keep what wins.**75761. **Characterize.** Read the target (skill, agent `.md`, CLAUDE.md, the doc). For every chunk,77 ask: hot or cold? Used almost-every-time or occasionally? Load-bearing (must-never-skip) or78 optional depth? This classification *is* most of the analysis.79802. **Hypothesize a change**, and predict its effect in hot/cold terms. "Move §X to a reference"81 → saves hot tokens. "Add an anchor index" → predict ~no retrieval gain on a small doc (verdict82 1); say so. "Add a verify rule" → predict it fires for project/version-specific facts.83843. **A/B test it** when the effect is non-obvious or the user wants proof. Same prompt, change85 only the one variable (the rule, the skill, the doc layout) → clean causal attribution.86 Instrument via the **transcript**, not self-report: count tool calls, lines read (input87 proxy), correctness, and provenance honesty (claimed source vs actual tool call). Full88 protocol in `references/ab-test-harness.md`.89904. **Keep what wins, revert what doesn't, and say what you measured.** Don't ship ceremony. If91 the index didn't help, drop it; if the trim saved tokens, keep it; if a rule fired only92 partially, report the limit honestly rather than overclaiming.93945. **Clean up.** If you ran subagent tests, scrub the memory they generated95 (`references/memory-hygiene.md`) so it can't contaminate later work.9697## Anti-patterns this skill exists to stop9899- **Index-by-reflex.** Adding anchors/TOC/grep-tokens to every doc "for navigability." Measure100 first; on small docs it's cost without benefit (verdict 1).101- **Hoarding hot.** Letting CLAUDE.md / an agent body accrete mid-depth prose that's needed 5% of102 the time. That prose is a per-turn tax. Push it cold.103- **Burying must-apply rules cold.** A non-negotiable, divergent-from-default, or version-pinned104 fact placed only in a reference will be silently skipped (verdict 5). Critical → hot, or guard105 it with a verify/provenance rule.106- **Presuming instead of measuring.** "This is obviously better" is how the grep-index almost107 shipped as dogma. Run the A/B; let the transcript decide.108- **Leaving test memory behind.** Subagent runs write `agent-memory` + `reflection_store` +109 index entries that re-inject into later runs. Always clean.