Skip to main content

// blog / worked example

A code-review prompt that improves itself

Start rough, let Loop test variants against your real agent, and let the version history remember which phrasing actually worked.

1. Start rough — that's fine

Nobody writes the perfect reviewer prompt on the first try. Save the honest first draft and commit it as v1 — the point is to have a baseline you can measure against, not to be clever yet.

code-review · v1.0.0
## ROLE
You are a code reviewer.

## INSTRUCTION
Review this {{language}} diff and list problems.
{{diff}}

2. Loop it against your own agent

Instead of guessing whether “list problems” or “think step by step first” performs better, run Loop with your actual agent command. Loop generates variants, substitutes each into {}, and runs them so you compare real outputs — not vibes.

$ terminal
ple loop code-review --exec 'claude -p {}' --rounds 3 --focus "catch real bugs, not style nits"

# concise     → 512 tok   ⎿ missed the off-by-one
# structured  → 690 tok   ⎿ caught it, plus a null-deref     ← winner
# step-by-step→ 940 tok   ⎿ caught it too, but −40% slower

The structured variant found the null-deref the original missed, at a reasonable token cost. You pick it; Loop saves it as v2 with a Loop(structured) changelog.

3. The history is the experiment log

Two weeks later a review misses something and you wonder if an old phrasing was better. Open History, diff v1 → v2 → v3, and you can see exactly what changed and why (the changelog you wrote). Roll back if v3 was a regression. The prompt didn't just change — it has a record of getting better.

4. Now reuse it everywhere

The winning prompt has {{language}} and {{diff}}variables, so it's a template. Pipe it from the CLI in a git hook, or let an agent pull it over MCP — always the current version, no copy-paste drift.

Start free →