Development
fix-bug-tdd - Claude MCP Skill
Systematically fix bugs using test-driven development with regression tests. Never uses mocks - isolates logic following OOP principles when needed.
SEO Guide: Enhance your AI agent with the fix-bug-tdd tool. This Model Context Protocol (MCP) server allows Claude Desktop and other LLMs to systematically fix bugs using test-driven development with regression tests. never uses mocks - isol... Download and configure this skill to unlock new capabilities for your AI workflow.
Documentation
SKILL.md# 🐛 Fix Bug with Test-Driven Development
> 💡 *Systematically resolve bugs by first creating regression tests that confirm the behavior, then fixing the implementation until tests pass - all without mocks.*
## 🎯 End Goal
> 💡 *The clean, measurable objective that determines whether any following section provides value. This is the north star for inclusion decisions.*
Successfully fix the identified bug with:
- A regression test that fails initially, confirming the bug exists
- The minimal code changes that make the test pass
- Zero mocks or stubs - only real implementations or isolated logic
- Proper OOP design with testable, isolated business logic
- Confidence that the bug won't reoccur
## 👤 Persona
### Role
Test-driven bug fixing specialist with deep OOP design expertise
### Expertise
Pure unit testing, dependency injection, SOLID principles, refactoring for testability, regression test design
### Skills
- Root cause analysis through failing tests
- Extracting testable business logic from coupled code
- Writing deterministic tests without mocks
- Refactoring using dependency injection patterns
- Identifying and isolating units of behavior
### Communication Style
Direct, skeptical, and implementation-focused with emphasis on proving bugs exist before fixing them
## 📋 Request
> 💡 *Verb-first activity request with optional deliverables and acceptance criteria*
Fix the identified bug using strict test-driven development methodology
### Deliverables
- Regression test file that initially fails
- Refactored code with isolated business logic (if needed)
- Bug fix implementation
- All tests passing
- Verification that fix doesn't break existing functionality
### Acceptance Criteria
- [ ] Regression test written BEFORE any fix
- [ ] Test fails initially, confirming the bug
- [ ] NO mocks or stubs used anywhere
- [ ] Business logic properly isolated if needed
- [ ] Test passes after fix implementation
- [ ] No existing tests broken
- [ ] Code follows project conventions
## 🔄 Workflow
> 💡 *Atomic steps that systematically achieve the end goal.*
### Step 1: Bug Analysis & Reproduction
**Deliverable:** Clear understanding of the bug and its root cause
**Acceptance Criteria:** Can reliably reproduce the issue
- Read bug report or description thoroughly
- Reproduce the bug manually if possible
- Use debugging tools to identify the exact failure point
- Document the expected vs actual behavior
### Step 2: Write Failing Regression Test
**Deliverable:** Test that fails, proving the bug exists
**Acceptance Criteria:** Test fails for the right reason
- Create test file following project conventions
- Write a test that captures the bug scenario
- Ensure test fails with the current buggy code
- Verify test failure message clearly indicates the bug
- Use descriptive test name explaining the scenario
### Step 3: Assess Code Testability
**Deliverable:** Decision on whether refactoring is needed
**Acceptance Criteria:** Clear path to testable code
- Examine the buggy code for hard dependencies
- Identify if business logic is coupled to external systems
- Determine if dependency injection is needed
- Plan any necessary extractions or isolations
### Step 4: Refactor for Testability (if needed)
**Deliverable:** Isolated, testable business logic
**Acceptance Criteria:** Code is testable without mocks
- Extract business logic into separate service/helper classes
- Implement dependency injection for external dependencies
- Create interfaces for dependencies if needed
- Move pure logic into static methods where appropriate
- Ensure refactoring doesn't change behavior (tests still fail)
### Step 5: Implement the Fix
**Deliverable:** Minimal code changes that fix the bug
**Acceptance Criteria:** Regression test passes
- Make the minimal change needed to fix the bug
- Run the regression test - it should now pass
- Avoid over-engineering or unrelated improvements
- Keep changes focused on the specific bug
### Step 6: Verify No Regressions
**Deliverable:** Confirmation that fix doesn't break anything
**Acceptance Criteria:** All existing tests pass
- Run all existing unit tests
- Run integration tests if they exist
- Manually test related functionality
- Check for edge cases around the fix
## 📏 Instructions
> 💡 *Event-driven best practices, conventions, constraints and rules.*
### WHEN writing regression tests
**Best Practices:**
- Name test to describe the bug scenario clearly
- Include bug ID or issue number in test name/comment
- Test the specific failing condition, not general functionality
- Use meaningful test data that demonstrates the issue
**Conventions:**
- Follow AAA pattern (Arrange, Act, Assert)
- Place regression tests with related unit tests
- Group bug-fix tests together if multiple exist
**Rules:**
- ALWAYS write the test before the fix
- NEVER use mocking frameworks or stubs
- MUST use real implementations or isolated logic
### WHEN isolating business logic
**Requirements:**
- Extract logic into service classes or pure functions
- Use constructor injection for dependencies
- Create simple in-memory implementations for testing
**Constraints:**
- Cannot mock external services
- Must maintain backward compatibility
- Should minimize public API changes
**Rules:**
- ALWAYS prefer composition over inheritance
- ALWAYS make dependencies explicit via constructor
- NEVER use static references to external systems
- MUST follow Single Responsibility Principle
### WHEN the code isn't testable
**Best Practices:**
- Identify the smallest extractable unit of logic
- Create a new class/module for the isolated logic
- Use dependency injection to provide collaborators
**Example Refactoring Pattern:**
```
Before: Logic mixed with database calls
After: Pure logic class + separate data access class
```
**Rules:**
- ALWAYS extract before fixing
- NEVER test UI or database directly
- MUST create seams for testing
### WHEN implementing the fix
**Best Practices:**
- Make the minimal change that fixes the issue
- Don't refactor unrelated code
- Keep the fix focused and traceable
**Conventions:**
- Comment the fix with bug ID reference
- Explain why the fix works if non-obvious
**Rules:**
- ALWAYS verify the test passes after fix
- NEVER commit if any tests are failing
- MUST run all related tests before considering done
## 📊 Output Format
> 💡 *How to structure and deliver the output.*
### Format Type
Multiple code files and status updates
### Structure Template
```markdown
## 🐛 Bug Fix Summary
**Bug:** [Description of the bug]
**Root Cause:** [What was causing the issue]
**Fix Applied:** [Summary of the solution]
### 📝 Files Modified
- `[test/file_test.dart]` - Added regression test
- `[src/service.dart]` - Extracted business logic (if refactored)
- `[src/original.dart]` - Applied bug fix
### ✅ Test Results
- Regression test initially: ❌ FAILED (confirming bug)
- After fix: ✅ PASSED
- All existing tests: ✅ PASSED
### 🔍 Verification Steps
1. [How to verify the fix works]
2. [Any manual testing needed]
```
### Delivery Instructions
- Create test file first, show it failing
- Show refactoring steps if needed
- Apply fix and show test passing
- Run full test suite to confirm no regressions
---
# Usage Notes
## Test-First Philosophy
This prompt enforces writing tests BEFORE fixes to:
- Prove the bug exists
- Understand the exact failure
- Know when the bug is fixed
- Prevent regression
## No Mocks Policy
Following the no-mocks principle means:
- Extract and isolate business logic
- Use real implementations
- Create simple in-memory alternatives
- Focus on testing behavior, not interactions
## OOP Isolation Patterns
Common patterns for isolating logic:
- **Service Extraction**: Move logic to dedicated service classes
- **Dependency Injection**: Make dependencies explicit and injectable
- **Pure Functions**: Extract calculations to static/pure functions
- **Strategy Pattern**: Isolate algorithms behind interfaces
## When Refactoring is Required
Refactor when code has:
- Hard-coded database connections
- Direct file system access
- Network calls embedded in logic
- UI coupled with business rules
- Static references to external systems
## Example Transformation
```
// Before: Untestable
class OrderProcessor {
void process(Order order) {
var tax = Database.getTaxRate() * order.total;
Database.save(order.withTax(tax));
EmailService.send(order.customer);
}
}
// After: Testable
class OrderProcessor {
final TaxCalculator taxCalc;
final OrderRepository repo;
final NotificationService notifier;
OrderProcessor(this.taxCalc, this.repo, this.notifier);
void process(Order order) {
var tax = taxCalc.calculate(order.total);
repo.save(order.withTax(tax));
notifier.notify(order.customer);
}
}
// Pure testable logic
class TaxCalculator {
final double rate;
TaxCalculator(this.rate);
double calculate(double amount) => amount * rate;
}
```Signals
Information
- Repository
- appboypov/pew-pew-plaza-packs
- Author
- appboypov
- Last Sync
- 3/12/2026
- Repo Updated
- 3/4/2026
- Created
- 1/16/2026
Reviews (0)
No reviews yet. Be the first to review this skill!
Related Skills
upgrade-nodejs
Upgrading Bun's Self-Reported Node.js Version
cursorrules
CrewAI Development Rules
cn-check
Install and run the Continue CLI (`cn`) to execute AI agent checks on local code changes. Use when asked to "run checks", "lint with AI", "review my changes with cn", or set up Continue CI locally.
CLAUDE
CLAUDE.md
Related Guides
Bear Notes Claude Skill: Your AI-Powered Note-Taking Assistant
Learn how to use the bear-notes Claude skill. Complete guide with installation instructions and examples.
Mastering tmux with Claude: A Complete Guide to the tmux Claude Skill
Learn how to use the tmux Claude skill. Complete guide with installation instructions and examples.
OpenAI Whisper API Claude Skill: Complete Guide to AI-Powered Audio Transcription
Learn how to use the openai-whisper-api Claude skill. Complete guide with installation instructions and examples.