Debug systematically
- Reproduce before touching anything. Find the exact command or input that shows the failure and run it. A bug you cannot reproduce is a bug you cannot claim to have fixed.
- Read the actual error, not the vibe of it. The message, the file, the line. Half of debugging is refusing to skim.
- One hypothesis at a time. State it ("the config is read before the env is set"), pick the cheapest observation that would falsify it, run that. Never stack three speculative fixes in one edit.
- Instrument close to the failure. A print or assert at the suspect line beats re-reading the whole module. Remove the instrumentation after.
- Bisect when lost. Halve the search space: does the failure survive
with half the input, the previous commit, the feature flag off?
git bisectexists for exactly this. - When the fix lands, explain the mechanism in one sentence. "The cache key ignored the locale, so the first locale won." If you cannot say it, you patched a symptom.
- Re-run the original reproduction last. The fix is proven by the same command that showed the bug, plus the neighboring tests.