bug-fix-tdd

A bug-fixing workflow based on TDD, or test-driven development: first write a test that exposes the bug, then make the smallest code change that fixes it.

In plain words
What is it for?
Use it to analyse bug reports, locate the affected code, create a failing test, apply a minimal fix, and run the relevant and full test suites.
Why use it?
It proves that the reported problem is reproducible and leaves a regression test so the same bug can be detected later.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/stacklok/toolhive-studio/bug-fix-tdd
Any agent
npx skills add stacklok/toolhive-studio --skill bug-fix-tdd
Clone the repo
git clone --depth 1 https://github.com/stacklok/toolhive-studio

Made for: Claude Code, Codex.

Per session 52 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,679 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00052 $0.01679
Opus 5 $0.00026 $0.00839
Sonnet 5 $0.00010 $0.00336
Haiku 4.5 $0.00005 $0.00168

Measured 2d ago against content hash 080ff2527ac1, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

bug-fix-tdd scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/bug-fix-tdd/SKILL.md · 211 lines

How it starts

The opening of the file, as written. The whole thing — 211 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Bug Fix TDD

Reproduce bugs with a failing test, then apply the minimum fix. This skill is used by the automated bug-fix agent in CI but can also be invoked manually.

TDD Workflow

Phase 1 — Analysis & Failing Test (Red)

  1. Parse the bug report: extract description, steps to reproduce, expected vs actual behavior
  2. Find relevant code: use Grep/Glob to locate the component, hook, or route mentioned in the bug
  3. Write a unit test that reproduces the bug — the test MUST FAIL
  4. Run the test: pnpm run test:nonInteractive -- <test-file-path>
  5. Verify failure reason: the test must fail because of the bug, not because of import errors or unrelated issues
  6. Retry if needed: if the test passes (bug not reproduced), try a different approach (max 3 attempts)
  7. Write bug-analysis.md with findings (see format below)

Constraints: Do NOT modify source files in Phase 1. Only create/edit test files and bug-analysis.md.

Phase 2 — Fix (Green)

  1. Read the failing test and bug-analysis.md
  2. Apply the MINIMUM fix to make the test pass — do not over-engineer
  3. Run the single test: pnpm run test:nonInteractive -- <test-file-path>
  4. Run the full suite: pnpm run test:nonInteractive
  5. Run static checks: pnpm run lint and pnpm run type-check
  6. Retry if needed: if any check fails, adjust the fix (max 5 attempts)
  7. Write pr-body.md and fix-title.txt

Constraints: Do NOT run git, gh, or modify .env files.

Phase 2b — Direct Fix (Fallback)

If Phase 1 cannot reproduce the bug in a test (test passes after 3 attempts), Phase 2b runs instead of Phase 2.

  1. Read bug-analysis.md and issue-body.md for context
  2. Apply the MINIMUM fix based on code analysis alone
  3. If you CAN write a regression test, do so — but it is not required
  4. Run the full suite: pnpm run test:nonInteractive
  5. Run static checks: pnpm run lint and pnpm run type-check
  6. Retry if needed: if any check fails, adjust the fix (max 5 attempts)
  7. Write pr-body.md and fix-title.txt — note in the PR body that no regression test was possible

Read the full file on GitHub · 211 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 211 lines · 52 tokens per session scan A 080ff2527ac1

Subscribe to this mod's changes

bug-fix-tdd is a skill published in the GitHub repository stacklok/toolhive-studio (163 stars, last pushed 4d ago), licensed Apache-2.0. It adds 52 tokens to every session and 1,679 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories