Agent skill
investigate
Systematic root-cause debugging. Four phases: investigate, analyze, hypothesize, implement. Iron Law: no fixes without root cause investigation first. Use when debugging errors, unexpected behavior, or troubleshooting.
Install this agent skill to your Project
npx add-skill https://github.com/DenchHQ/DenchClaw/tree/main/skills/gstack/investigate
SKILL.md
Systematic Debugging — Find the Root Cause
Iron Law: NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST.
Fixing symptoms creates whack-a-mole debugging. Every fix that doesn't address root cause makes the next bug harder to find.
Related skills: review | qa | careful
Phase 1: Root Cause Investigation
Gather context before forming any hypothesis.
-
Collect symptoms: Read error messages, stack traces, reproduction steps. If not enough context, ask ONE question at a time.
-
Read the code: Trace the code path from symptom to potential cause.
-
Check recent changes:
bashgit log --oneline -20 -- <affected-files>Was this working before? What changed? A regression means the root cause is in the diff.
-
Reproduce: Can you trigger the bug deterministically? If not, gather more evidence.
Output: "Root cause hypothesis: ..." — a specific, testable claim about what is wrong and why.
Phase 2: Pattern Analysis
Check if this bug matches a known pattern:
| Pattern | Signature | Where to look |
|---|---|---|
| Race condition | Intermittent, timing-dependent | Concurrent access to shared state |
| Nil/null propagation | TypeError, undefined is not a function | Missing guards on optional values |
| State corruption | Inconsistent data, partial updates | Transactions, callbacks, hooks |
| Integration failure | Timeout, unexpected response | External API calls, service boundaries |
| Configuration drift | Works locally, fails in staging | Env vars, feature flags, DB state |
| Stale cache | Shows old data, fixes on cache clear | Redis, CDN, browser cache |
Also check TODOS.md for related known issues and git log for prior fixes in the same area — recurring bugs in the same files are an architectural smell.
Phase 3: Hypothesis Testing
Before writing ANY fix, verify your hypothesis.
-
Confirm: Add a temporary log or assertion at the suspected root cause. Reproduce. Does evidence match?
-
If wrong: Return to Phase 1. Gather more evidence. Do not guess.
-
3-strike rule: If 3 hypotheses fail, STOP. Ask the user:
- A) Continue investigating with a new hypothesis
- B) Escalate for human review
- C) Add logging and catch it next time
Red flags — slow down:
- "Quick fix for now" — there is no "for now." Fix it right or escalate.
- Proposing a fix before tracing data flow — you're guessing.
- Each fix reveals a new problem elsewhere — wrong layer, not wrong code.
Phase 4: Implementation
Once root cause is confirmed:
- Fix the root cause, not the symptom. Smallest change that eliminates the actual problem.
- Minimal diff. Fewest files, fewest lines. Resist refactoring adjacent code.
- Write a regression test that fails without the fix and passes with it.
- Run the full test suite. No regressions.
- If fix touches >5 files: Flag the blast radius and ask before proceeding.
Phase 5: Verification & Report
Reproduce the original bug and confirm it's fixed. This is not optional.
DEBUG REPORT
════════════════════════════════════════
Symptom: [what the user observed]
Root cause: [what was actually wrong]
Fix: [what was changed, file:line]
Evidence: [test output showing fix works]
Regression test: [file:line of the new test]
Status: DONE | DONE_WITH_CONCERNS | BLOCKED
════════════════════════════════════════
Important Rules
- 3+ failed fix attempts → STOP and question the architecture.
- Never apply a fix you cannot verify.
- Never say "this should fix it." Verify and prove it.
- If fix touches >5 files → ask first.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
dench-integrations
Connected app integration recipes for Dench Integrations (Gmail, Slack, GitHub, Notion, Google Calendar, Linear, Stripe, YouTube, and 500+ more)
gstack-workflow
Structured AI-assisted development workflow with specialist roles — Think, Plan, Build, Review, Test, Ship, Reflect. Adapted from garrytan/gstack (MIT).
plan-ceo-review
CEO/founder-mode plan review. Rethink the problem, find the 10-star product, challenge premises. Four modes: SCOPE EXPANSION, SELECTIVE EXPANSION, HOLD SCOPE, SCOPE REDUCTION. Use when reviewing strategy, questioning scope, or before engineering review.
design-consultation
Build a complete design system from scratch. Research the landscape, propose safe choices AND creative risks, generate DESIGN.md. Use when creating a new design system or establishing design foundations for a project.
land-and-deploy
Merge the PR, wait for CI and deploy, verify production health. Takes over after ship. One command from "approved" to "verified in production."
guard
Maximum safety mode — combines careful (destructive command warnings) with freeze (edit scope restriction). Use when working with production systems or making sensitive changes.
Didn't find tool you were looking for?