Skip to content

Add Cursor rule: enforce TDD workflow #20

@r2DoesInc

Description

@r2DoesInc

Summary

Add a Cursor rule (.cursor/rules/mdc-tdd-workflow.mdc) that enforces test-driven development whenever possible.

Rule details

The rule should mandate a Red-Green-Refactor cycle for all non-trivial changes:

  1. Red — write a small, focused test that fails.
  2. Green — write the minimum code to make it pass.
  3. Refactor — clean up without changing behavior; tests stay green.

When to apply TDD

  • New functions, utilities, helpers
  • Bug fixes (reproduce with a test first)
  • API route handlers and data-processing logic
  • Parsers, validators, transformation code

When TDD is impractical

  • Pure layout/styling changes with no logic
  • One-line config tweaks
  • Temporary spikes (flagged as such)

Test quality guidelines

  • One assertion per behavior; many small tests over few large ones
  • Name tests as sentences: it("returns 0 when the cart is empty")
  • Test inputs/outputs, not implementation details
  • Mock external services; never hit real APIs in unit tests
  • Keep test files next to source (src/lib/foo.tssrc/lib/__tests__/foo.test.ts)

Acceptance criteria

  • .cursor/rules/mdc-tdd-workflow.mdc exists with alwaysApply: true
  • Rule documents the Red-Green-Refactor cycle with examples
  • Rule lists when TDD applies and when it can be skipped
  • Rule includes test quality guidelines

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions