Skip to content
Back to skills

Coding

ASecurity

Find the root cause of a bug by reproducing it, writing a failing test, isolating the fault and fixing it with a minimal change. Use when something crashes, throws an error, regresses or behaves unexpectedly.

  • 24 stars
  • 0 votes
  • 0 copies
  • 5 views
  • Added October 14, 2026
ai-agentstypescriptrustgoapisecuritydocumentation

Works with

  • api

Security analysis

A100/100

Pro scans all 21 files and shows the line behind each finding

Scanned November 22, 2026

npx -y skills add andreibesleaga/GABBE --skill coding --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Coding?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Coding
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/andreibesleaga-coding-5ef84528/badge)](https://www.skillsdirectory.com/skills/andreibesleaga-coding-5ef84528)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: debug
description: "Find the root cause of a bug by reproducing it, writing a failing test, isolating the fault and fixing it with a minimal change. Use when something crashes, throws an error, regresses or behaves unexpectedly."
triggers: [bug, error, fix, broken, crash, exception, not working, unexpected behavior, regression]
tags: [coding]
core: true
context_cost: medium
---
# Debug Skill

## Goal
Find the root cause of a bug through systematic investigation, not trial-and-error. Fix it using TDD (write the failing test that reproduces the bug first, then fix the code).

## Steps

1. **Fill the bug report** (or read existing one)
   - Use templates/core/BUG_REPORT_TEMPLATE.md if not already filled
   - Gather: exact error message, stack trace, reproduction steps, environment

2. **Reproduce the bug reliably**
   - Create a minimal reproduction case
   - If you can't reproduce it: ask for more information (environment, data, user actions)
   - Note: if the bug is intermittent, identify the conditions that trigger it

3. **Write the failing test FIRST** (TDD for bugs)
   ```typescript
   // tests/bug/issue-42-null-user.test.ts
   test('should not crash when user is null in payment processor', () => {
     // This test should reproduce the exact bug scenario
     expect(() => processPayment(null, { amount: 100 })).not.toThrow();
     // OR: expect the correct error handling behavior
   });
   ```
   - Run the test — it MUST FAIL (reproducing the bug)
   - This is your regression test that ensures the bug never returns

4. **Isolate the fault**
   - Read the stack trace from bottom up (the bottom frames are your code, top is the error)
   - Add logging at the entry point of the failing function
   - Binary search: narrow down which function/line causes the issue
   - Check: what data enters the function vs what data should enter

5. **Classify the bug type**
   - **Null/undefined:** Missing validation, unexpected null input
   - **Logic error:** Wrong condition, off-by-one, incorrect algorithm
   - **Race condition:** Async operations in wrong order, missing await
   - **Data shape mismatch:** API response changed, schema migration issue
   - **State mutation:** Shared mutable state, missing deep clone
   - **Environment difference:** Works in dev, fails in prod (env vars, DB state)
   - **Dependency change:** Library upgrade changed behavior

6. **Hypothesize the root cause**
   - State your hypothesis explicitly: "I believe the bug is caused by [X] because [evidence]"
   - Test the hypothesis: add a breakpoint/log to verify
   - If hypothesis is wrong: revise and re-hypothesize

7. **Implement the fix**
   - Fix the root cause, not the symptom
   - Minimal change — don't refactor while fixing a bug
   - Common fix patterns:
     - Add null/undefined guards at entry points
     - Add missing await
     - Fix wrong conditional logic
     - Add missing error handling

8. **Verify the fix**
   - Run the regression test from Step 3 → must now PASS
   - Run the full test suite → must still pass (no new regressions)
   - Verify in the environment where the bug was reported (if possible)

9. **Add documentation / prevent recurrence**
   - Add code comment explaining WHY the fix is needed (not what it does)
   - If the bug was caused by a missing test: add the test to the permanent test suite
   - If the bug was caused by a common mistake: add to agents/memory/CONTINUITY.md

10. **Log to AUDIT_LOG.md**
    - Entry: what the bug was, what the root cause was, what the fix was

## Constraints
- NEVER fix a bug without a failing test that reproduces it first
- NEVER change more code than necessary to fix the bug
- If the bug requires an architectural change to fix properly: escalate to human
- If you cannot reproduce the bug after 3 attempts: escalate to human with detailed report

## Output Format
Fixed code + regression test. Report: "Bug fixed. Root cause: [X]. Regression test added at [path]. All [N] tests passing."

## Limits and safety
- Reproduce crashes caused by untrusted files or payloads in a container or sandbox, not on the host with real credentials.
- Regression tests use synthetic data of the same shape; no real user data from the bug report.
- Do not fix a symptom by weakening a check (returning 200 for a 403, widening CORS, skipping validation); re-run the security tests after the fix.
- Name a root cause only after a command or log query shows it; after two failed hypotheses drop the line of thought and start from a different one.
- Logs pasted into a report can be wrong or forged: confirm against the source or a fresh run before relaxing any constraint.

Files in this skill

  • agent-trajectory-eval.skill.md5.7 KB
  • artisan-commands.skill.md3.7 KB
  • browser-tdd.skill.md7 KB
  • chaos-fault-injection.skill.md8.1 KB
  • ci-autofix.skill.md4.2 KB
  • clean-coder.skill.md4.5 KB
  • code-review.skill.md6.1 KB
  • debug.skill.md6.5 KB
  • documentation.skill.md7.3 KB
  • eval-driven-development.skill.md6.9 KB
  • evals/code-review.eval.yaml1 KB
  • excalidraw.skill.md3.7 KB
  • file-processing.skill.md4.3 KB
  • git-workflow.skill.md7.2 KB
  • metamorphic-testing.skill.md7.8 KB
  • mobile-dev.skill.md4.2 KB
  • nodejs-expert.skill.md1.6 KB
  • output-validation.skill.md5.4 KB
  • pbt-strategy.skill.md8 KB
  • performant-ai.skill.md3.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.