Debugging
Intro
Debugging is a fixed loop: reproduce the failure, read the error,
isolate the cause, fix it, verify the fix, and add a regression
test. Skipping steps causes the bug to come back.
Overview
The debugging loop
- Reproduce — get the exact steps, inputs, and error
messages. Confirm you can trigger the issue on demand.
- Read the error — parse the full stack trace or error
message. The root cause is usually in the first or last frame,
not the middle.
- Isolate — narrow the scope:
- Binary search through code (comment out halves)
- Check recent changes (
git log, git diff)
- Add targeted logging or print statements
- Test with the minimal failing input
- Hypothesize and test — form a theory, then test it. Change
one thing at a time.
- Fix — apply the minimal change that resolves the issue.
- Verify — confirm the original error is gone, run the full
test suite for regressions, and exercise edge cases near the
fix.
- Document — add a test that would have caught this bug, and
a comment if the fix is non-obvious.
Common diagnosis paths
- Tests pass locally, fail in CI — environment differences:
OS, dependency versions, file paths, timezone, locale, or race
conditions in parallel tests. Compare CI logs with local output
to find the divergence point.
- Function returns wrong results for some inputs — get the
specific failing inputs, add assertions at intermediate steps,
find where actual diverges from expected, trace back.
Gotchas
Agent-specific failure modes — provider-neutral pause-and-self-check items:
- Changing multiple things at once. When more than one variable changes between a broken and fixed state, you cannot know which change fixed the issue — and you may have introduced new bugs alongside the fix. Change one thing at a time.
- Skipping the reproduction step. Starting to diagnose before having a reliable reproduction means you're hunting in the dark. Confirm you can trigger the failure on demand before doing anything else.
- Stopping at the first fix that makes the symptom disappear. The first change that silences the error may be masking the root cause. Verify that the underlying state is correct, not just the visible output.
- No regression test after the fix. A bug that was fixed without a test will return. Add a test that would have caught it before closing the issue.
- Adding print statements everywhere without a plan. Each print should test a specific hypothesis ("is the value non-nil here?"). Random prints produce noise that slows diagnosis.
- Confusing correlation with causation in logs. The last log entry before a crash is rarely the cause — it is just the last thing that ran. Trace the full causal chain; do not assume temporal proximity implies causation.
- Treating a CI/local mismatch as mysterious. Environment differences (OS, timezone, locale, implicit tool version, parallel test ordering) are the most common cause. Diff the CI environment against local systematically rather than guessing.
Full reference
Anti-patterns
- Shotgun debugging — changing many things at once. You won't
know which fix worked, and you'll introduce new bugs.
- Print-statement spelunking with no plan — adding prints is
fine, but each one should test a specific hypothesis.
- Skipping reproduction — "it sometimes fails" is not a bug
report. Find the trigger first.
- Stopping at the first fix — the first thing that makes the
symptom go away is often masking the real cause. Verify the
underlying state is correct, not just the visible output.
- No regression test — if you don't add a test, the bug will
return.
Tools and techniques
git bisect for regressions: a known-good and known-bad
commit narrows the offending change in log(N) steps.
- Debuggers over prints when state is rich (object graphs,
step-through control flow).
- Differential debugging — diff the working case against the
failing case, not the other way around.
- Rubber-duck explanation — articulating the problem out loud
often surfaces the bug before you write any code.
When to stop and ask
If you've spent more than ~30 minutes without forming a viable
hypothesis, stop and either gather more information (logs,
reproduction steps, recent commits) or escalate. Continued flailing
is not progress.
1---2name: debugging3description: |4 Systematic debugging — reproduce, read the error, isolate, hypothesize, fix, verify, document. Use when tracking down a bug, unexpected behavior, or test failure — including phrases like "this doesn't work", "why is this failing", or "help me debug".5metadata:6 source: https://skillmd.com/skills/projectious-work/debugging7 processkit:8 apiVersion: processkit.projectious.work/v19 id: SKILL-debugging10 version: "1.1.0"11 created: 2026-04-06T00:00:00Z12 category: engineering13 layer: 314---1516# Debugging1718## Intro1920Debugging is a fixed loop: reproduce the failure, read the error,21isolate the cause, fix it, verify the fix, and add a regression22test. Skipping steps causes the bug to come back.2324## Overview2526### The debugging loop27281. **Reproduce** — get the exact steps, inputs, and error29 messages. Confirm you can trigger the issue on demand.302. **Read the error** — parse the full stack trace or error31 message. The root cause is usually in the first or last frame,32 not the middle.333. **Isolate** — narrow the scope:34 - Binary search through code (comment out halves)35 - Check recent changes (`git log`, `git diff`)36 - Add targeted logging or print statements37 - Test with the minimal failing input384. **Hypothesize and test** — form a theory, then test it. Change39 one thing at a time.405. **Fix** — apply the minimal change that resolves the issue.416. **Verify** — confirm the original error is gone, run the full42 test suite for regressions, and exercise edge cases near the43 fix.447. **Document** — add a test that would have caught this bug, and45 a comment if the fix is non-obvious.4647### Common diagnosis paths4849- **Tests pass locally, fail in CI** — environment differences:50 OS, dependency versions, file paths, timezone, locale, or race51 conditions in parallel tests. Compare CI logs with local output52 to find the divergence point.53- **Function returns wrong results for some inputs** — get the54 specific failing inputs, add assertions at intermediate steps,55 find where actual diverges from expected, trace back.5657## Gotchas5859Agent-specific failure modes — provider-neutral pause-and-self-check items:6061- **Changing multiple things at once.** When more than one variable changes between a broken and fixed state, you cannot know which change fixed the issue — and you may have introduced new bugs alongside the fix. Change one thing at a time.62- **Skipping the reproduction step.** Starting to diagnose before having a reliable reproduction means you're hunting in the dark. Confirm you can trigger the failure on demand before doing anything else.63- **Stopping at the first fix that makes the symptom disappear.** The first change that silences the error may be masking the root cause. Verify that the underlying state is correct, not just the visible output.64- **No regression test after the fix.** A bug that was fixed without a test will return. Add a test that would have caught it before closing the issue.65- **Adding print statements everywhere without a plan.** Each print should test a specific hypothesis ("is the value non-nil here?"). Random prints produce noise that slows diagnosis.66- **Confusing correlation with causation in logs.** The last log entry before a crash is rarely the cause — it is just the last thing that ran. Trace the full causal chain; do not assume temporal proximity implies causation.67- **Treating a CI/local mismatch as mysterious.** Environment differences (OS, timezone, locale, implicit tool version, parallel test ordering) are the most common cause. Diff the CI environment against local systematically rather than guessing.6869## Full reference7071### Anti-patterns7273- **Shotgun debugging** — changing many things at once. You won't74 know which fix worked, and you'll introduce new bugs.75- **Print-statement spelunking with no plan** — adding prints is76 fine, but each one should test a specific hypothesis.77- **Skipping reproduction** — "it sometimes fails" is not a bug78 report. Find the trigger first.79- **Stopping at the first fix** — the first thing that makes the80 symptom go away is often masking the real cause. Verify the81 underlying state is correct, not just the visible output.82- **No regression test** — if you don't add a test, the bug will83 return.8485### Tools and techniques8687- **`git bisect`** for regressions: a known-good and known-bad88 commit narrows the offending change in log(N) steps.89- **Debuggers over prints** when state is rich (object graphs,90 step-through control flow).91- **Differential debugging** — diff the working case against the92 failing case, not the other way around.93- **Rubber-duck explanation** — articulating the problem out loud94 often surfaces the bug before you write any code.9596### When to stop and ask9798If you've spent more than ~30 minutes without forming a viable99hypothesis, stop and either gather more information (logs,100reproduction steps, recent commits) or escalate. Continued flailing101is not progress.