tdd
cursor/plugins
Write focused regression tests before fixing bugs with clear, cheap test paths.
What is tdd?
TDD Bug Fix guides you to write a failing test first when fixing a bug that has an obvious, practical test target. Use it when the user explicitly requests TDD, a regression test, or when a bug has a clear local test path. Skip it when testing would be expensive, integration-heavy, or impractical.
- Identify the narrowest executable test for a bug's reproduction path
- Write a focused failing test that encodes intended behavior before fixing code
- Confirm the test fails for the right reason before making production changes
- Fix the bug with minimal production code changes
- Verify the regression test passes after the fix
- Suggest practical alternatives (scripts, snapshots, log assertions) when formal tests are impractical
How to install tdd
npx skills add https://github.com/cursor/plugins --skill tddHow to use tdd
- 1.Understand the bug: identify intended behavior, current behavior, and smallest reproduction
- 2.Choose the narrowest executable check (unit, component, integration, or regression test)
- 3.Write the smallest focused test that encodes the intended behavior
- 4.Run the test before fixing to confirm it fails for the intended reason
- 5.Make the minimal production code change to fix the bug
- 6.Rerun the test to confirm it now passes
- 7.Report the failing-before evidence, the fix, and the passing-after result
Use cases
- Fix a bug with a clear unit test that reproduces the issue locally
- Add a regression test when a user explicitly requests TDD workflow
- Verify a fix for a component bug using an existing test harness
- Create a targeted executable check when full test infrastructure is unavailable
- Document and lock down flaky behavior with a deterministic regression check
- Developers fixing bugs with clear, reproducible test paths
- Teams practicing test-driven development or regression testing
- Engineers working in codebases with established test infrastructure
- Anyone needing evidence that a fix actually solves the reported problem
tdd FAQ
Use it when the user explicitly asks for TDD, a failing test, or a regression test, OR when the bug has an obvious cheap local test target. Skip it if the test path is unclear, expensive, integration-heavy, or not requested.
Use the closest executable regression check instead: a targeted script, manual reproduction command, browser automation, snapshot comparison, log assertion, or focused integration check. Prefer no new test over a bad test.
No. Do not change tests merely to match a wrong implementation or weaken assertions unless the expected behavior has genuinely changed and the reason is clear.
Report the evidence: name the failing-before test and its failure, name the passing-after test run, and any nearby validation performed. If you couldn't demonstrate failing-before evidence, explain why and describe the closest regression check used instead.
Make the test deterministic where possible and document the signal being locked down. For broader failures, land the focused regression path first, then consider additional sibling coverage.
Full instructions (SKILL.md)
Source of truth, from cursor/plugins.
name: tdd description: "Use only when the user explicitly asks for TDD, a failing test, or a regression test, OR when the bug has an obvious cheap local test target. Skip when the test path is unclear, expensive, integration-heavy, or not requested." disable-model-invocation: true
TDD Bug Fix
When fixing a bug with a clear, cheap test path, make the broken behavior executable before changing production code. The goal is a focused regression test that fails before the fix and passes after it.
Do not force a test when it would be impractical. If the available test would require broad harness setup, brittle mocks, slow end-to-end infrastructure, production-only state, vague reproduction steps, or large unrelated fixture churn, skip adding a new test and use the closest useful verification instead.
Workflow
- Understand the bug. Identify the intended behavior, current behavior, affected path, and smallest observable reproduction.
- Choose the narrowest executable check. Prefer the closest unit, component, integration, or regression test already used for that codepath. If no practical test path is obvious, do not create one from scratch just to satisfy the workflow.
- Write the failing test first. Add the smallest focused test that would have caught the bug. The test should encode intended behavior, not mirror the current implementation.
- Run the new test before fixing. Confirm it fails for the intended reason. If it passes or fails for an unrelated reason, correct the test or reproduction before editing the implementation.
- Fix the bug. Make the smallest production change that satisfies the intended behavior while preserving nearby contracts.
- Rerun the regression test. Confirm the test now passes.
If a Failing Test Is Impractical
Use the closest executable regression check instead: a targeted script, manual reproduction command, browser automation, snapshot comparison, log assertion, or focused integration check.
Prefer no new test over a bad test. A bad test is one that mostly tests mocks, encodes current implementation details, depends on timing or unrelated global state, needs expensive infrastructure for a small fix, or would be deleted immediately after proving the fix.
Guardrails
- Do not change tests merely to match a wrong implementation.
- Do not weaken existing assertions unless the expected behavior has genuinely changed and the reason is clear.
- Keep the regression test focused on the bug. Avoid broad fixture churn or unrelated coverage expansion.
- If the bug is flaky, make the test deterministic where possible and document the signal being locked down.
- If the bug exposes a broader class of failures, first land the focused regression path, then consider additional sibling coverage.
Final Response
Report the evidence, not just the outcome:
- Name the failing-before test or executable check and the failure it produced.
- Name the passing-after test run and any nearby validation performed.
- If failing-before evidence could not be demonstrated, state why and describe the closest regression check used instead.
Related skills
More from cursor/plugins and the wider catalog.

teach
Explain code and systems plainly by combining how and why analysis into one clear account.

technical-writing
Layered technical-writing standard: Diátaxis structure, Google style, STE rules, Global English syntax.

thermo-nuclear-code-quality-review
Extremely strict code quality review focused on maintainability, abstraction, and structural simplification.

thermo-nuclear-review
Comprehensive security and correctness audit of branch changes for bugs, breaking changes, and vulnerabilities.

thermos
Run parallel thermo-nuclear code reviews and synthesize findings for comprehensive branch audits.

typescript-best-practices
TypeScript best practices for type safety, discriminated unions, and constructive modeling.