systematic-debugging
4-phase bug-fix protocol (evidence, pattern, hypothesis, verify). Use when investigating any error, failure, or unexpected behavior, handling bug reports from users or monitoring, or diagnosing test failures with non-obvious causes.
- License 许可
- MIT
- 所属仓库
- muratovv/ai-hats
- 最近更新
- 2026-11-05
- Stars
- ★ 3
- Forks
- 1
01 前言 Front Matter
- name
- systematic-debugging
- ai_hats
- { "type": "skill", "schema_version": 1 }
- license
- MIT
- description
- 4-phase bug-fix protocol (evidence, pattern, hypothesis, verify). Use when investigating any error, failure, or unexpected behavior, handling bug reports from users or monitoring, or diagnosing test failures with non-obvious causes.
03 SKILL.md 正文
Systematic Debugging
4-phase protocol for bug fixing and error investigation. No guess-and-check.
When to Use
Code-level root-cause via a failing test — evidence before fixes, no guess-and-check. Its sibling for production trouble is incident-response: a live outage with an on-call / mitigation dimension starts there (stop the bleeding first) and only then drops into this protocol for the underlying bug. If there's no running-system urgency, you're in the right place.
Phase 1: Evidence Gathering
- Read full stack traces and error logs.
- Inspect environment state (env vars, active processes, disk space).
- Map affected files using
rgandfd.
Phase 2: Pattern Analysis
- Is this isolated or part of a larger pattern?
- Identify blast radius: what else could this affect?
- Check if it's a regression from a recent change (
git log,git bisect).
Phase 3: Hypothesis & Strategy
- State a falsifiable hypothesis: "The error happens because [X] is in state [Y]."
- Design a minimal reproduction script or failing test.
- Only then draft the fix.
Phase 4: Implementation & Verification
- Apply minimal, surgical changes.
- Run the reproduction script to confirm the fix.
- Run the full test suite for regression check.
- A task is not done until behavioral correctness is verified.
Completion
- Root cause identified and documented
- Fix applied with minimal surgical changes
- Reproduction script or failing test confirms the fix
- Full test suite passes (no regressions)
Bundled Rules
Pessimistic Verification
- Anti-Momentum: Do NOT proceed to the next step until the current one is physically verified (tests, lint, check command).
- Assumption Audit: Before execution, list assumptions. If testable, test first.
- Foundation First: When modifying shared components, sanity check after every file modification.
- No Premature Optimization: Do not clean up unrelated code during a critical fix.
Anti-Patterns
- Guess-and-check — changing things randomly hoping it works
- Fixing symptoms instead of root cause — the bug will return
- Swallowing the failure, returning a default, or skipping the crashing case, while the cause stays. That handler is not the fix. The fix is the change that makes the failing test green because the cause is gone.
- Skipping regression check — fix one bug, introduce two more
04 同仓库更多 Skills
tool-evaluation-protocol
Time-bounded protocol for evaluating new tools, libraries, or methodologies before adoption. Use when evaluating a candidate dependency for the project, researching a methodology (e.g. ML/LLM frameworks, testing approaches), or following up on a hype-driven recommendation.
skill-template
Canonical template and validation guide for ai-hats skills. Use when creating a new skill, reviewing an existing one for structural compliance, or deciding which pattern fits a new behavior.
skill-optimization
Audit and refactor library components to eliminate redundancy and staleness. Use during periodic library maintenance, after adding multiple new skills or rules, when a role's token budget is too high, or after retrospectives identify component issues.
silent-fallback-gate
PreToolUse hook — refuses an Edit or Write that adds an inert broad except. Use when a Python edit was blocked for a silent fallback.
retro-to-framework
Convert an observation about agent behavior — from a retrospective or from a single incident — into a framework-level change (hook, rule, skill, skill update). Use after a retrospective identifies problems that are not project-specific, after an incident where an agent misapplied a component it had read, when CLAUDE.md band-aids accumulate (more than 3 per-project rules that could be generic), or when the same problem recurs across multiple projects.
py-security-lint
PostToolUse hook — reports the project's own ruff security (`S`) findings on every `.py` you Edit/Write, non-blockingly; fail-open, no manual invocation.