code-bug-investigation
A structured process to move from a bug report to a reproducible, fix-ready state.
Install
mkdir -p .claude/skills/code-bug-investigation && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/17876" && unzip -o skill.zip -d .claude/skills/code-bug-investigation && rm skill.zipInstalls to .claude/skills/code-bug-investigation
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Workflow for investigating and reproducing bugs before fixing via TDD. Use when a bug report or GitHub issue is received. Covers issue fetching, root cause analysis, reproduction planning, and handoff to TDD cycle.Key capabilities
- →Establish a tight feedback loop for bug reproduction
- →Gather details from GitHub issues or user descriptions
- →Identify the root cause and affected code
- →Present analysis before proceeding to TDD
How it works
The skill guides through phases of bug investigation, starting with establishing a reproduction loop, gathering issue details, locating the root cause, and presenting an analysis before transitioning to a TDD cycle.
Inputs & outputs
When to use code-bug-investigation
- →Investigate a GitHub issue
- →Reproduce a reported regression
- →Minimize feedback loops for debugging
About this skill
Bug Investigation
Turn a bug report into a confirmed root-cause analysis and a ready-to-establish verification plan. This skill investigates; it does not fix code or edit verification.
Use common-verification-first as the governing policy. The intent is
BUG_FIX; infrastructure, configuration, and test infrastructure do not create
separate intents.
When to Use
- A user or reviewer reports incorrect behavior.
- A GitHub issue describes a defect.
- A failing check suggests a regression.
- A patch seems obvious but the root cause has not been demonstrated.
1. Build the Fastest Feedback Loop
- Restate observed behavior, expected behavior, trigger, and environment.
- Find the narrowest existing way to trigger the symptom: test selector, API request, CLI command, build, validator, browser flow, or direct workflow.
- Reproduce before proposing a fix. If the defect cannot be reproduced, stop and report the missing conditions or evidence.
- Use temporary read-only diagnostics when the failure is otherwise invisible. Do not leave instrumentation or edit tracked artifacts during investigation.
Production Behavior
Find whether existing behavioral verification can reproduce the defect accurately. Recommend reusing or updating it when possible; otherwise recommend one focused regression at the lowest level that crosses the failing boundary. The Verifier will establish and prove that regression before implementation.
Test Infrastructure
Start with a production-behavior consumer test or direct reproduction of the affected test workflow. Shared, public, reusable, or independently versioned support code does not justify direct tests.
Recommend the smallest focused test of a stable support contract only when consumer or workflow evidence cannot localize the fault precisely enough, and state the diagnostic precision gap.
2. Gather Evidence
From an issue, collect its title, description, reproduction steps, expected and actual results, environment, labels, and relevant recent comments. From a user report, resolve material ambiguity before continuing.
Capture command, input, output, and whether the evidence is repeatable. Separate:
- confirmed observation;
- inference supported by code or runtime evidence; and
- unverified assumption.
3. Locate the Root Cause
- Identify the affected domain, application, adapter, SDK, UI, workflow, or support layer.
- Read the execution path and stable external boundary.
- Inspect existing verification and explain why it missed the defect.
- Trace the exact condition and code path that produce the wrong result.
- Confirm the root cause with the reproduction; do not confuse it with the symptom.
- Identify invariants and neighboring behavior that the fix must preserve.
4. Select the Proposed Verification Strategy
For production behavior, choose one focused regression plan:
- reuse an existing behavioral test unchanged;
- update an existing test whose expectation is wrong or incomplete; or
- add one focused regression because the behavior is absent.
Do not keep contradictory expectations or add redundant tests. Choose the lowest level that proves the real defect without mocking away its cause:
| Defect boundary | Typical level |
|---|---|
| Pure domain rule | Unit |
| Application decision with stable ports | Unit or focused integration |
| File, HTTP, cloud provider, or external adapter | Integration |
| DI, command dispatch, or cross-layer wiring | Integration |
| CLI or GitHub Action contract | Integration or e2e |
| UI rendering or interaction | Component or browser test |
| Critical user journey | E2E |
For test infrastructure, use consumer or direct-workflow evidence instead of this table unless the documented diagnostic exception applies.
Output
BugAnalysis
Observed behavior:
Expected behavior:
Trigger and environment:
Reproduction command and result:
Confirmed root cause:
Affected code and scope:
Preserved invariants:
Existing coverage and why it missed the defect:
Proposed strategy: reuse | update | add one focused regression | consumer/direct workflow
Proposed behavior and level:
Diagnostic precision gap: none | explanation
Assumptions and unresolved evidence:
Status: READY_TO_ESTABLISH_CONTRACT | NOT_REPRODUCED | BLOCKED
At an interactive checkpoint, present this analysis before implementation. Calling workflows may fold it into their single specification checkpoint.
Rules
- One defect per investigation.
- Never propose a production fix without confirmed reproduction evidence.
- Never edit production, verification, documentation, configuration, or test support.
- Never claim a planned regression has failed until the Verifier actually runs it.
- Never add direct support tests for coverage or methodology.
- Surface inability to reproduce instead of guessing.
When not to use it
- →When the goal is to fix a bug without reproducing it first
- →When multiple bugs need to be addressed in a single cycle
- →When the user does not want to validate the analysis
Limitations
- →Requires reproduction before fixing
- →Focuses on one bug per cycle
- →Requires user validation of analysis
How it compares
This structured workflow ensures a bug is fully understood and reproducible with a minimal feedback loop before any code changes are made, contrasting with ad-hoc debugging.
Compared to similar skills
code-bug-investigation side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| code-bug-investigation (this skill) | 0 | 2mo | Review | Intermediate |
| python-testing-patterns | 77 | 3mo | Review | Intermediate |
| fix-bug | 11 | 8mo | Review | Intermediate |
| test-fixing | 1 | 10mo | Review | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by macalbert
View all by macalbert →You might also like
python-testing-patterns
wshobson
Implement comprehensive testing strategies with pytest, fixtures, mocking, and test-driven development. Use when writing Python tests, setting up test suites, or implementing testing best practices.
fix-bug
tddworks
Guide for fixing bugs in ClaudeBar following Chicago School TDD and rich domain design. Use this skill when: (1) User reports a bug or unexpected behavior (2) Fixing a defect in existing functionality (3) User asks "fix this bug" or "this doesn't work correctly" (4) Correcting behavior that violates the user's mental model
test-fixing
mhattingpete
Run tests and systematically fix all failing tests using smart error grouping. Use when user asks to fix failing tests, mentions test failures, runs test suite and failures occur, or requests to make tests pass.
fixing-bugs-systematically
CaptainCrouton89
Diagnose and fix bugs through systematic investigation, root cause analysis, and targeted validation. Use when something is broken, errors occur, performance degrades, or unexpected behavior manifests.
moai-workflow-testing
modu-ai
Comprehensive development workflow specialist combining DDD testing, debugging, performance optimization, code review, PR review, and quality assurance into unified development workflows
investigate
MadAppGang
Unified entry point for code investigation. Auto-routes to specialized detective based on query keywords. Use when investigation type is unclear or for general exploration.