---
name: eval-loop
description: >-
Turn a learning or a repeated workflow into a skill that is proven to help: write the SKILL.md,
write 3-6 eval cases (should fire, should not fire, does the job), run them with and without the
skill, change one thing, re-run. The same loop tests a prompt, a subagent brief or a CLAUDE.md /
AGENTS.md rule. Use for "save this as a skill", "write evals for my skill", "does my skill trigger",
"is the skill actually helping", "test this rule / brief / prompt", or before sharing a skill.
---
# Eval loop
A skill nobody measured is a guess: it may never fire, fire on the wrong requests, or fire and change
nothing. This loop makes each skill earn its always-loaded description with numbers.
```
capture -> draft SKILL.md -> write cases -> run with and without -> read result -> change ONE thing -> re-run
```
Steps 1-3 work in any harness. Running and reading (steps 4-5) use `claude plugin eval`, which is
Claude Code only; on another host, run the same cases by hand in fresh sessions with and without the
skill installed and tally the graders yourself.
## 1. Capture
Write down, in 3-5 lines, before drafting anything:
- **The job:** what the agent does differently with the skill (a procedure, a fix, a convention).
- **Real requests** that should fire it: 2-3 phrasings a user actually typed, copied from the session.
- **Near misses** that must not fire it: requests that share words but need something else.
- **Done looks like:** a file, an answer containing X, a command run, a tool never called.
Done when each of the four has at least one concrete line. If "done looks like" stays vague, the
learning is not ready to be a skill yet: keep it as a note.
## 2. Draft the skill
Folder `<name>/SKILL.md`, name lowercase and hyphenated. The description is the trigger: what it does
in one sentence, then "Use for/when" with the real requests from step 1, one phrase per distinct case.
The body: numbered steps, each ending on something checkable. Style detail: `agent-writing` (short)
or `writing-for-agents` (full reference), if installed.
Done when the description names every "real request" branch from step 1 and none of the near misses.
## 3. Write 3-6 eval cases
Each case is a fresh session given one prompt; graders score what happened. Use this mix:
| Case | Prompt | Grader |
| --- | --- | --- |
| should fire (1-2) | a real request from step 1, reworded | the skill was invoked |
| should not fire (1-2) | a near miss from step 1 | the skill was never invoked |
| outcome (1-2) | a small real task, with files set up for it | deterministic checks on the result |
Rules for cases:
- **Deterministic graders first**: a regex on the answer or a file, a tool called or never called, a
file created. Use a model judge only for what code can't check, and keep its criteria to one
observable sentence. To calibrate a judge against your own labels, use `eval-judge`.
- **The outcome case must be one the agent fails without the skill.** If the baseline passes it too,
the case measures nothing: make it test what only the skill teaches.
- Prompts read like a user, never like a test: no "use the X skill", no hints of the answer.
- Keep tools minimal. A shell tool may be refused on machines that can't sandbox it; grant it only
when the task needs one.
Claude Code file format, wrapper folder and grader templates: read [`ref/claude-code-format.md`](ref/claude-code-format.md).
Done when every case has at least one scored grader, and at least one case is expected to fail
without the skill.
## 4. Run with and without
Claude Code only. Agree the spend cap with the user before the first run. Run from the folder that
holds the plugin wrapper:
```bash
claude plugin eval <plugin-dir> --ablation with-without --runs 3 --max-cost-usd <cap> --no-publish
```
- `--ablation with-without` adds a baseline arm without the plugin; the report gives the delta.
- `--runs 3` minimum: one run is an anecdote. Use 5 when two versions are within one run of each other.
- `--max-cost-usd` stops the suite at the cap. `--no-publish` keeps results local.
- Add `--scaffold` when any case has a `scaffold_script`, or its workspace stays empty.
- To re-run one case, see `claude plugin eval --help` for the case filter.
Results land in `<plugin-dir>/evals/results/<timestamp>/` as `aggregate-result.json` and `report.html`.
## 5. Read the result
Open `aggregate-result.json`:
- `aggregates.overallPassRate`, `aggregates.meanDelta`: the headline. A delta near 0 means the skill
changes nothing measurable.
- Per case, `cases[].aggregates`: `passRate` (with), `passRateWithout`, `delta`.
- Per run, `cases[].arms.with[]` / `arms.without[]`: `passed`, `error`, `graders[].explanation`,
`tracePath` (the full session; read it for any surprising run).
- A run with `error` set did not test the skill. Fix the setup (a refused tool, a timeout, a missing
scaffold) before reading any score.
- Trigger indicators show as `withOnly: true, scored: false` under ablation: read them as "did it fire"
in the with arm, not as part of the score.
Write one line per case: pass rate with / without, and the failing grader's explanation.
## 6. Change one thing, re-run
Pick the single worst case and change one thing:
| Symptom | Change |
| --- | --- |
| should-fire case: skill never invoked | the description: add the user's own phrasing, lead with it |
| should-not-fire case: skill invoked | the description: narrow the branch it matched, name the boundary |
| fires, outcome still fails | the body step the trace shows was skipped or misread |
| passes without the skill too | the case (it tests nothing), or the skill (it teaches nothing new) |
| flips between runs | more runs first; then sharpen the vaguest step |
One change per run, so the next delta belongs to that change. Re-run the same command. Keep the
change if the case improves and no other case drops; otherwise revert it. Stop when every case passes
in at least 2 of 3 runs and the mean delta is positive, or after 3 rounds; then report what still fails.
## Instructions that are not skills
Prompts, subagent briefs and CLAUDE.md / AGENTS.md rules go through the same loop. The plugin under
test is just a folder holding the cases (a plugin wrapper with no skill in it); the instruction rides
in each case's `append_system_prompt`, which both ablation arms receive, so the comparison is between
cases, not arms:
- **Variants as cases.** For each task prompt, make one case per wording: `<task>-old`, `<task>-new`,
and `<task>-none` (no instruction, the baseline). Same prompt body, same graders; only
`append_system_prompt` differs. Compare their `passRate` values; ignore the without arm.
- **A rule:** "applies" tasks check the agent follows it (a regex on the answer, a tool called or never
called); "doesn't apply" tasks check it doesn't leak into unrelated work.
- **A brief:** one task per kind of job the brief must handle; graders check the report shape and the
DONE criteria the brief asks for (a file written, a heading present, a command run).
The change-one-thing rule holds: `-new` differs from `-old` by one edit. Done when `-new` beats `-old`
on the same tasks, or the old wording stays.
## Report
```
Skill: <name> Cases: <n> (fire <n>, no-fire <n>, outcome <n>) Runs: <n> per arm
Pass rate: with <x%>, without <y%>, mean delta <d> Cost: <$>
Rounds: <n>; changes kept: <one line each>
Still failing: <case: grader explanation>
Command: <the exact eval command>
```
## Rules
- Change one thing per round; the delta must belong to it.
- Never edit a case to make it pass; edit it only when it tests the wrong thing, and say so.
- Agree a spend cap before any run. Never use a paid API key without the user's okay for this task.