Diagnose Loop
Find the cause before changing source code. Use the fast path for obvious repeatable failures and the full loop only when uncertainty or risk earns it.
Rule
Before changing source for a failure, read the exact failure evidence and name the reproducer or strongest observation.
Do not patch from memory, guesses, nearby failures, or broad-suite noise. The loop must match the user's symptom or be explicitly named as partial.
First visible move:
Symptom:
Reproducer or observation:
Matches user symptom: yes|no|partial
Fast path or full loop:
Next check:
Reproducer means the command, test, CI job, captured log, fixture, or manual step that shows the failure. If no reproducer exists, use the strongest observation and name what evidence is missing.
Fast Path
Use for repeatable low-risk failures: syntax errors, missing imports, local type errors, obvious assertions, fixture failures, and simple loop or condition mistakes.
- Read the full failure output, stack trace, log, or report.
- Run the direct failing check when available.
- Make the smallest fix that explains that failure.
- Rerun the same check after the final edit.
- Stop unless the fix touches shared behavior, public or caller contract, data/state, security, concurrency, dependency/config behavior, generated output, or the check still fails.
Do not write hypothesis lists, add debug logging, or run broad suites for a fast-path failure unless the focused loop fails or risk grows.
Full Loop
Use when the cause is unclear, the failure is flaky, expensive, risky, mismatched to the reported symptom, or the fast path fails.
- Build the cheapest useful loop: failing test, command, CI log, focused fixture, replay, captured request, or exact manual step.
- Sharpen loops that are broad, slow, flaky, nondeterministic, or observe a nearby setup error instead of the reported symptom.
- Minimize the case: input, fixture, state/data, config, dependency range, environment, command, and caller-facing entry point.
- Rank 2-5 falsifiable hypotheses only when the cause is still unclear.
- Test one variable at a time; negative results count.
- Add temporary debug output only when it distinguishes hypotheses or component boundaries, and remove it before the final diff.
- Do not combine speculative source, test, config, dependency, or fixture changes in one attempt.
Flakes
Flaky means the same command, test, fixture, or workflow sometimes passes and sometimes fails.
- Record the command, attempts, failures, environment, seed/time/concurrency inputs, and CI run when relevant.
- Start with a small repeat count, such as 3-5 runs, or use existing CI history.
- Prefer making the trigger repeatable over proving stability by volume: pin time or randomness, isolate shared state, wait for conditions instead of sleeps, or control concurrency.
- After the fix, rerun the focused flaky check enough to check the old failure mode.
- Do not claim a flake is fixed from one passing run.
Fix And Check
Fix the cause with the smallest source change that explains the observed failure.
Keep or add a regression check when the fix changes behavior or covers a recurring bug. If the correct behavior check needs design or broader implementation, use tdd-slice.
After the final edit, rerun the reproducer or strongest observation. Use verify-before-done to calibrate final fixed, covered, passing, or ready claims.
Stop Or Ask
Stop or ask when:
- no useful reproducer, log-only observation, captured trace, fixture, access, or manual step exists after reasonable attempts
- the loop observes a different setup error, nearby failure, or broad-suite symptom and cannot be sharpened
- behavior, public or caller contract, data/state, security, dependency/config behavior, generated output, or live system state would change without an approved target
- three source-fix attempts fail or negative results contradict the current hypothesis
- the only possible regression check is shallow, private, or over-mocked and the risk is not low
- the suspected cause is external but no minimal case distinguishes external failure from repo behavior
Handoff
Use tdd-slice for approved behavior checks, codebase-cleanup when structure blocks a durable fix or test, workspace-safety before overlapping dirty-path or Git risk, github-tracking when the bug should become durable issue/PR state, and verify-before-done for final fixed/covered/passing claims.
Report
For small fixes:
Symptom:
Reproducer:
Cause:
Fix:
Rerun result:
Remaining risk:
For full investigations, also include hypotheses tested and any test-surface gap.
1---2name: diagnose-loop3description: Use when tests, commands, builds, CI jobs, or workflows fail; behavior is wrong; output or performance regresses; flakes or crashes appear; or an error is not yet understood.4---56# Diagnose Loop78Find the cause before changing source code. Use the fast path for obvious repeatable failures and the full loop only when uncertainty or risk earns it.910## Rule1112Before changing source for a failure, read the exact failure evidence and name the reproducer or strongest observation.1314Do not patch from memory, guesses, nearby failures, or broad-suite noise. The loop must match the user's symptom or be explicitly named as partial.1516First visible move:1718```text19Symptom:20Reproducer or observation:21Matches user symptom: yes|no|partial22Fast path or full loop:23Next check:24```2526Reproducer means the command, test, CI job, captured log, fixture, or manual step that shows the failure. If no reproducer exists, use the strongest observation and name what evidence is missing.2728## Fast Path2930Use for repeatable low-risk failures: syntax errors, missing imports, local type errors, obvious assertions, fixture failures, and simple loop or condition mistakes.31321. Read the full failure output, stack trace, log, or report.332. Run the direct failing check when available.343. Make the smallest fix that explains that failure.354. Rerun the same check after the final edit.365. Stop unless the fix touches shared behavior, public or caller contract, data/state, security, concurrency, dependency/config behavior, generated output, or the check still fails.3738Do not write hypothesis lists, add debug logging, or run broad suites for a fast-path failure unless the focused loop fails or risk grows.3940## Full Loop4142Use when the cause is unclear, the failure is flaky, expensive, risky, mismatched to the reported symptom, or the fast path fails.4344- Build the cheapest useful loop: failing test, command, CI log, focused fixture, replay, captured request, or exact manual step.45- Sharpen loops that are broad, slow, flaky, nondeterministic, or observe a nearby setup error instead of the reported symptom.46- Minimize the case: input, fixture, state/data, config, dependency range, environment, command, and caller-facing entry point.47- Rank 2-5 falsifiable hypotheses only when the cause is still unclear.48- Test one variable at a time; negative results count.49- Add temporary debug output only when it distinguishes hypotheses or component boundaries, and remove it before the final diff.50- Do not combine speculative source, test, config, dependency, or fixture changes in one attempt.5152## Flakes5354Flaky means the same command, test, fixture, or workflow sometimes passes and sometimes fails.5556- Record the command, attempts, failures, environment, seed/time/concurrency inputs, and CI run when relevant.57- Start with a small repeat count, such as 3-5 runs, or use existing CI history.58- Prefer making the trigger repeatable over proving stability by volume: pin time or randomness, isolate shared state, wait for conditions instead of sleeps, or control concurrency.59- After the fix, rerun the focused flaky check enough to check the old failure mode.60- Do not claim a flake is fixed from one passing run.6162## Fix And Check6364Fix the cause with the smallest source change that explains the observed failure.6566Keep or add a regression check when the fix changes behavior or covers a recurring bug. If the correct behavior check needs design or broader implementation, use `tdd-slice`.6768After the final edit, rerun the reproducer or strongest observation. Use `verify-before-done` to calibrate final fixed, covered, passing, or ready claims.6970## Stop Or Ask7172Stop or ask when:7374- no useful reproducer, log-only observation, captured trace, fixture, access, or manual step exists after reasonable attempts75- the loop observes a different setup error, nearby failure, or broad-suite symptom and cannot be sharpened76- behavior, public or caller contract, data/state, security, dependency/config behavior, generated output, or live system state would change without an approved target77- three source-fix attempts fail or negative results contradict the current hypothesis78- the only possible regression check is shallow, private, or over-mocked and the risk is not low79- the suspected cause is external but no minimal case distinguishes external failure from repo behavior8081## Handoff8283Use `tdd-slice` for approved behavior checks, `codebase-cleanup` when structure blocks a durable fix or test, `workspace-safety` before overlapping dirty-path or Git risk, `github-tracking` when the bug should become durable issue/PR state, and `verify-before-done` for final fixed/covered/passing claims.8485## Report8687For small fixes:8889```text90Symptom:91Reproducer:92Cause:93Fix:94Rerun result:95Remaining risk:96```9798For full investigations, also include hypotheses tested and any test-surface gap.