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
Structured workflow for going from bug report to reproduction-ready TDD plan.
When to Use
- A GitHub issue is referenced (e.g., "#42", issue URL)
- A reviewer describes incorrect behavior
- A user reports unexpected output or error
- A test failure indicates a regression
Phase 1: Build a Feedback Loop
This is the skill. Everything else is mechanical. Before investigating anything, establish a tight loop that lets you observe the bug:
- Can you trigger the bug right now? Find the fastest command or action that demonstrates the failure (CLI invocation, test command, API call).
- Minimize the loop. Strip to the simplest reproduction: fewest inputs, shortest path. A 2-second feedback loop beats a 30-second one.
- Instrument if needed. If the bug isn't directly observable (silent failure, wrong value in cloud), add a temporary log or assertion that makes it visible. Remove instrumentation after fix.
If you can't reproduce → stop and report to the user immediately. No guessing.
Phase 2: Gather Issue Details
From GitHub issue:
gh issue view {number} --json title,body,labels,assignees,comments
Extract: title, description, steps to reproduce, expected vs actual behavior.
From user description:
Summarize: what's happening, what should happen, reproduction conditions.
Phase 3: Investigate and Locate
- Identify the domain area: which handler, service, or component
- Read the affected code: understand current behavior
- Check existing tests: why didn't they catch this?
- Identify root cause: pinpoint the exact code path
Phase 4: Present Analysis
Before writing any code, present findings:
## Bug Analysis
**Issue:** {title or summary}
**Root cause:** {explanation}
**Affected code:** {file}:{line range}: {what's wrong}
**Existing coverage:** {tests that exist but missed the bug}
**Reproduction plan:**
| # | Test behavior | Level | Justification |
|---|---------------|-------|---------------|
| 1 | Should_{X}_When_{Y} | Unit | {why} |
Proceed with reproduction test? (Y/n)
Wait for user confirmation before proceeding to TDD cycle.
Phase 5: Handoff to TDD
After analysis is confirmed:
- RED: Write a failing test that reproduces the bug (asserts correct behavior, fails because bug exists)
- GREEN: Fix the production code minimally
- REFACTOR: Clean up if needed
Investigation Tools
- Terminal: Run CLI commands,
pnpm test,dotnet test, reproduce failures - Browser/Playwright: Navigate website, take screenshots, check console errors
- Read/Search: Explore codebase, trace code paths
ghCLI: Fetch issue details, comments, labels
Rules
- Never fix without reproducing first: a failing test is mandatory
- One bug per cycle: multiple bugs need separate investigations
- Present analysis before acting: user validates understanding first
- Report blockers immediately: if reproduction fails, stop and explain
Summary Format
After fix is complete:
## Bug Fix Complete
**Issue:** {title}
**Root cause:** {one-line explanation}
**Red:** {test_file}::{test_name}: reproduced ✓
**Green:** {production_file}: {what was fixed}
**Refactor:** {what improved, or "no changes needed"}
**Tests:** pnpm test: {N} passed, 0 failed
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 | 17d | Review | Intermediate |
| python-testing-patterns | 77 | 2mo | Review | Intermediate |
| fix-bug | 11 | 6mo | Review | Intermediate |
| test-fixing | 1 | 8mo | 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.