Diagnose
A six-phase systematic approach to debugging any bug. Never guess. Build a loop, reproduce, hypothesise, instrument, fix, post-mortem.
The Diagnostic Framework
Debugging fails when engineers skip to instrumentation before they understand the bug. This skill enforces a strict phase order that prevents wasted instrumentation on the wrong hypothesis and prevents fixing symptoms instead of causes.
The most common debugging mistake
Six-Phase Diagnostic Loop
Phase 1: Build a Feedback Loop
Before anything else, build a mechanism that lets you observe the system's behavior rapidly. Without a feedback loop, every instrumentation change requires a slow manual test cycle.
Phase 2: Reproduce
Reproduction means: you can trigger the exact failure, on demand, reliably, in a controlled environment. If you cannot do this, you are guessing.
Phase 3: Hypothesise
Hypotheses are explicit, ranked, and written down before any instrumentation. This prevents confirmation bias and ensures you test the most likely cause first.
Phase 4: Instrument
Instrumentation means adding observability to test one hypothesis at a time. The discipline is: one variable at a time, tagged logs, and perf isolation when relevant.
Phase 5: Fix + Regression Test
The fix addresses the root cause identified in Phase 4. The regression test ensures the bug cannot silently return.
Phase 6: Cleanup + Post-Mortem
After the fix is verified, remove all instrumentation and capture the learning.
HITL (Human In The Loop) Template
When debugging requires human action (e.g., running a command on a production server, providing access to a database, triggering a manual workflow), use this template to communicate clearly and minimise the number of round-trips.