- Extract 10-recipe loop taxonomy + tighten/non-determinism principles
into new sibling loop-recipes.md (language-agnostic)
- Shrink feedback-loops-{py,r}.md to worked-examples-only; both now
under the 100-line cap (R: 146 -> 95, py: 111 -> 79)
- Phase 1: add four-bullet completion gate (red / tight / deterministic
/ agent-runnable) + "no red-capable command, no Phase 2" guardrail
- Phase 2: rename to "Reproduce + minimise"; add shrink-to-smallest
sub-step
- Phase 5: add "no correct seam is itself the finding" escape valve
pointing to refactoring-r.md instead of writing a lying test
- Phase 6: lead with "what would have prevented this bug?" framing
Adapted from mattpocock/skills diagnosing-bugs.
2.8 KiB
2.8 KiB
Loop recipes — the taxonomy
A bug you can reproduce in 2 seconds with one keystroke is half-fixed. Phase 1's product is the loop. Spend time on it.
Recipes, fastest-acceptable first
- Failing test — one test file, minimal reporter, stop on first failure. The gold standard.
- Curl / HTTP script — for an endpoint bug, the request is the loop.
- CLI invocation with fixture input — when the CLI itself reproduces on a small fixture file.
- Headless browser script — for UI bugs that survive a unit test
(Playwright,
shinytest2). - Replay a captured trace — record one production trace, replay it deterministically.
- Throwaway harness — a 5-line script printing
PASS/FAILwith a non-zero exit on failure. Valid when nothing native exists. - Property / fuzz loop — when the bug only surfaces under randomised inputs, pin the seed and run the family.
- Bisection harness — when "what changed?" is the question, the
loop wraps
git bisect run. - Differential loop — two implementations, same input, assert equal.
- HITL bash script — last resort. A human-in-the-loop step is the escape valve when nothing automated can decide.
Language-flavored worked examples: feedback-loops-r.md / feedback-loops-py.md.
Tighten the loop
- Red on the bug, not a neighbour. The assert names the user's exact symptom.
- Tight — seconds, not minutes. Strip coverage, strip orchestration, strip rebuild. If the loop won't shrink, run a smaller slice.
- One keystroke. A typed-out command bus rewires per-bug context loss;
put it in a
justfilerecipe or shell history.
Kill non-determinism
If the same loop produces two answers in a row, fix the loop before Phase 2. Universal moves:
- Seed every RNG; never rely on global state.
- Pin the environment — timezone (
UTC), locale, hash seed. - Freeze package versions —
renv.lock,uv.lock, or container. - Isolate the filesystem — temp dirs, never the repo tree.
- Quarantine ambient network so a hung outbound call can't masquerade as a logic bug.
When you genuinely cannot build a loop
The bug is real, the loop won't form. Two paths:
- Build a worse loop, knowingly. A 30-second smoke test that passes most of the time you fix the bug is better than no loop. Document the false-positive/negative rate next to the assert.
- Escalate to the human. State out loud: "I can reproduce this symptom but cannot pin it to a deterministic test. The architectural cost of doing so is X. Want me to spend that, or accept a smoke test?" Then wait.
Never silently abandon Phase 1 and start guessing. That is the failure mode this skill exists to prevent.