# Fixing Bugs — Strict TDD Red/Green Bug-Fix Cycle

> Fixes bugs test-first: reproduce with a failing test, apply the minimum fix, prove it green, then run the full suite.

Fixing Bugs — Strict TDD Red/Green Bug-Fix Cycle is a free AI agent skill on Agensi by Cristhian Zanforlin Lousa, in Testing & Debugging. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: Free
- Creator: [Cristhian Zanforlin Lousa](https://www.agensi.io/creators/cristhian-zanforlin-lousa)
- Category: [Testing & Debugging](https://www.agensi.io/skills/testing-debugging)
- Uses: 2
- Version: 1.2
- Last updated: 2026-11-25
- Security: scan passed (2026-11-25); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/fixing-bugs-strict-tdd-red-green-bug-fix-cycle
- Tags: testing, code-review, debugging, bug-fix, tdd, regression, root-cause, git-bisect

## About this skill

**Fixing Bugs** makes your agent prove a bug exists before it touches the code. A fix only counts if a test goes from RED (failing for the reason in the bug report) to GREEN, and the rest of the suite stays green.

**The problems it solves**
- "Fixes" that change five things and hope one of them works
- Tests that cover an error path *similar* to the reported one instead of the exact one (e.g. `CancelledError` when Sentry reported `GeneratorExit`)
- Bug fixes that quietly grow into refactors
- Platform bugs reproduced on Linux when they were reported on Windows

**The workflow (strict order):** UNDERSTAND (GIVEN/WHEN/THEN/EXPECTED, platform dimension, investigation technique) → REPRODUCE (failing test named `should_<expected>_when_<condition>`) → VERIFY RED → FIX (root cause written down first, minimum change, scope rules) → VERIFY GREEN → VALIDATE (full suite, CI matrix if the bug is platform-related) → optional REFACTOR in a separate commit. The output is a fixed sequence: root cause, characterization tests, failing test, fix, passing test, regression check, short explanation.

**Scope stays on the causal path.** The fix touches only lines that caused the bug. Other bugs found along the way are reported under "Out of scope — noticed, not done", existing tests are never edited to pass, and a scope audit runs before VALIDATE ends.

**What's inside**
- `SKILL.md`: the cycle, scope rules, how to handle pre-existing issues, logging rules for fixes, output format
- `references/cycle.md`: phase-by-phase detail, the exact-error-path rule, test naming, AAA structure
- `references/investigation.md`: 5 Whys, automated `git bisect`, a debugging journal, bug clustering, anti-patterns
- `references/checklist.md`: the end-of-fix checklist, commit format, edge cases (several bugs in one report, untested code, bugs that need an integration test, regressions)
- `learnings/`: project-specific bug patterns that override the defaults

**When it triggers:** a bug report, "fix this", a Sentry alert, a regression, or a pasted stack trace.

Free and MIT-licensed, part of the claude-skills-czl collection.

**Source on GitHub:** [this skill](https://github.com/Cristhianzl/claude-skills-czl/tree/main/configs/agnostic/skills/fixing-bugs) · [full repository](https://github.com/Cristhianzl/claude-skills-czl)

## Requires

- Git

## Known limitations

If the bug cannot be reproduced with a failing test, it stops and asks for more information instead of guessing a fix. Platform-specific bugs must be verified on the affected OS. The fix stays on the bug's causal path; other bugs are reported, and refactors go in a separate commit.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the Fixing Bugs — Strict TDD Red/Green Bug-Fix Cycle skill from Agensi" and describe your task.
3. Your agent loads the skill from Agensi when it needs it. Nothing is downloaded.

## Frequently asked questions

### Does it work outside Claude Code?

Yes. It is a plain SKILL.md with Markdown references, so any agent that loads SKILL.md skills can use it. It was built and tested mainly on Claude Code.

### Will it change my code and run things?

Yes, that is the point of it. It writes a test, runs it to confirm it fails, applies the smallest fix it can, then runs the test and the full suite. It doesn't push or open PRs on its own.

### What if the bug can't be reproduced?

The skill stops and asks for more information instead of guessing. If the new test passes before any fix, the skill sends you back to UNDERSTAND, because either the scenario is wrong or the bug is already fixed.

### How is it triggered?

Automatically when you report a bug, say "fix this", mention a Sentry error or regression, or paste a stack trace. You can also call it by name.

### How do I install it?

Unzip it into `~/.claude/skills/` (all projects) or into your project's `.claude/skills/` folder, so you end up with `.claude/skills/fixing-bugs/SKILL.md`. Then restart the session.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
