Debug

From InugamiDev/ultrathink-oss · View interactive version

Debug is an AI agent skill from the GitHub repository InugamiDev/ultrathink-oss. Systematic debugging using hypothesis-driven investigation with test, narrow, and resolve loops

How to use this skill

Skill file

Debug Skill

Purpose

Systematically find the root cause of bugs using a disciplined hypothesis-test-narrow loop. This skill treats debugging as a scientific investigation, not a guessing game.

The core principle: never change code to debug. Observe, hypothesize, test, narrow. Only hand off to fix once the root cause is identified with evidence.

Workflow

Phase 1: Symptom Analysis

  1. Capture the symptom precisely
  1. Gather initial evidence
  1. Classify the bug type (this guides the investigation strategy)

Phase 2: Hypothesis Generation

  1. Generate 2-5 hypotheses ranked by likelihood. For each hypothesis:
  1. Prioritize hypotheses using these heuristics:

Phase 3: Hypothesis Testing (Loop)

  1. Test the highest-priority hypothesis
  1. Record the result
  1. Narrow the search space
  1. Repeat from step 6 until root cause is identified or all hypotheses are exhausted.

Phase 4: Root Cause Confirmation

  1. State the root cause clearly
  1. Verify with evidence
  1. If all hypotheses exhausted without finding root cause:

Phase 5: Handoff

  1. Produce the debug report using the template below.
  2. Recommend fix approach -- hand off to fix skill for implementation.
  3. Recommend test -- suggest what test should be written to prevent regression.

Debug Report Template

# Debug Report

## Symptom
**Observed**: [exact behavior]
**Expected**: [correct behavior]
**Reproducibility**: Always | Sometimes | Rare
**First noticed**: [when/context]

## Root Cause
**Location**: [file:line]
**Cause**: [precise description]
**Mechanism**: [how the cause produces the symptom]

## Evidence Chain
1. [observation 1] → indicates [conclusion 1]
2. [observation 2] → confirms [conclusion 2]
3. Therefore: [root cause]

## Hypothesis Log
| # | Hypothesis | Test | Result |
|---|-----------|------|--------|
| H1 | [statement] | [what was checked] | Eliminated: [reason] |
| H2 | [statement] | [what was checked] | Confirmed |

## Recommended Fix
[Description of what should change and why]
**Affected files**: [list]
**Risk**: Low | Medium | High

## Regression Prevention
[What test should be written to catch this if it recurs]

Usage

With error message

/debug TypeError: Cannot read property 'map' of undefined in UserList component

With symptom description

/debug The checkout flow completes but the order is not saved to the database

With context

/debug Login stopped working after merging PR #42. Users get a 401 even with valid credentials.

Continuing investigation

/debug We eliminated the auth middleware hypothesis. What else could cause 401s on the /api/user endpoint?

Examples

Example: Frontend crash

Symptom: "TypeError: Cannot read property 'map' of undefined"

Hypotheses:

  1. API returns null instead of array (H1 -- test by checking API response)
  2. Component renders before data loads (H2 -- test by checking loading state)
  3. Data shape changed after API update (H3 -- test by comparing schema)

Investigation: Read the component, find it expects data.items.map(...). Check the API endpoint -- it returns { items: [...] } on success but { error: "..." } on failure with no items key.

Root cause: Missing error handling -- component assumes API always returns items.

Example: Silent data loss

Symptom: "Orders created via API are missing the discount field"

Hypotheses:

  1. Discount field not included in API request body (H1)
  2. Discount field not mapped in ORM model (H2)
  3. Database migration did not add the column (H3)

Investigation: Check API route -- discount is in the request. Check ORM model -- discount field exists. Check database -- column exists. Check the create function -- found it: the createOrder function destructures the input but does not include discount in the destructured fields.

Root cause: Destructuring omission in createOrder() at src/lib/orders.ts:42.

Guidelines

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.