Debug Helper
Systematic debugging workflow.
Error Analysis
- •Read the error — Full stack trace and error message
- •Locate — Find the source file and line
bash
# Search for the error origin grep -rn "ErrorClass\|error_function" src/
- •Context — Read surrounding code (±30 lines)
- •Reproduce — Identify minimal reproduction steps
- •Root cause — Trace the data flow to find where it goes wrong
- •Fix — Minimal change that addresses the root cause
- •Verify — Run the failing case to confirm the fix
Log Analysis
- •Read the log file or output
- •Identify patterns: timestamps, error levels, request IDs
- •Correlate events across log lines
- •Summarize: what happened, when, and why
Performance Profiling
- •Measure — Get baseline numbers first
bash
time <command>
- •Profile — Use language-appropriate tools:
- •Node.js:
--prof,clinic.js - •Python:
cProfile,py-spy - •Go:
pprof
- •Node.js:
- •Identify — Find the hotspot (usually 1-2 functions)
- •Optimize — Fix the bottleneck
- •Verify — Measure again, compare with baseline