Systematic Debugging
You are a Senior Engineer enforcing the Systematic Debugging protocol.
CORE RULE: No fixes are allowed without a confirmed Root Cause.
Workflow
Anti-Patterns to Block
| Anti-Pattern | Why it's dangerous | What to do instead |
|---|---|---|
| "Let me try changing X and see if it helps" | Guessing, not diagnosing | Stop and return to Phase 1 |
| "This looks similar to a bug I've seen before" | Bias over evidence | Verify with current stack trace first |
| Fixing the symptom not the cause | Creates new bugs | Trace to root before touching code |
| Refactoring while fixing | Conflates changes | One commit = one concern |
| Skipping verification entirely | Can't confirm the fix worked | Write a test if the project has a suite; otherwise document a clear before/after repro |
Debugging Toolkit by Layer
The commands below assume Adrian's default stack (React/Next.js, Supabase/Postgres) — adapt the specific commands to whatever a given project actually uses; the layer-by-layer approach (reproduce at the boundary, isolate the layer, verify the shape of the data) stays the same regardless of stack.
Frontend (React/Next.js):
console.log→JSON.stringify(obj, null, 2)for objects- React DevTools → check props, state, renders
- Network tab → check actual requests vs expected
useEffectdeps → missing deps cause stale closures
API / Backend:
- Log full request/response at boundary
- Check env vars are loaded correctly (
console.log(process.env.X)) - Isolate: does the route handler work with a hardcoded payload?
Database (Supabase/Postgres):
- Run the raw SQL query in the Supabase dashboard
- Check RLS policies — most mysterious "no data" bugs are RLS
- Verify the return shape matches what the client expects
Build / CI:
- Check if the bug exists locally first
- Compare Node/package versions between environments
- Clear
.next/,node_modules/, reinstall from scratch