{"manifest":{"name":"TDD Workflow","version":"1.0.0","description":"Enforces strict Red-Green-Refactor TDD cycle. Tests first, minimal implementation, then refactor. Inspired by obra/superpowers and Aider architect mode.","tags":["tdd","testing","workflow","methodology"],"standard":"agentskills.io","standard_version":"1.0","content_checksum":"33b62d0cc4d97355d0dcc80297fc80de3f4698e441ef6f5690f2e48a259472b5","bundle_checksum":null,"metadata":{},"files":[]},"files":{"SKILL.md":"# TDD Workflow\n\n> **Purpose:** Enforce a strict Red-Green-Refactor test-driven development cycle. The agent writes tests FIRST, then implements just enough code to make them pass, then refactors.\n\n---\n\n## Invocation\n\n```\n/tdd <feature_description>\n```\n\n---\n\n## The Cycle\n\n### Phase 1: RED — Write Failing Tests\n\n1. Create a test file (or add to existing)\n2. Write test cases that describe the desired behavior\n3. Run the test suite — confirm tests FAIL\n4. **Do NOT write any implementation yet**\n\n```bash\n$ npx vitest run src/utils/slug.test.ts\n FAIL  src/utils/slug.test.ts\n  ✗ converts spaces to hyphens\n  ✗ lowercases all characters\n  ✗ removes special characters\n  ✗ handles empty string\n```\n\n### Phase 2: GREEN — Write Minimum Implementation\n\n1. Write the simplest code that makes ALL tests pass\n2. No extra features, no optimization, no \"while I'm here\" additions\n3. Run tests — confirm they PASS\n\n```bash\n$ npx vitest run src/utils/slug.test.ts\n ✓ src/utils/slug.test.ts (4 tests)\n  ✓ converts spaces to hyphens\n  ✓ lowercases all characters\n  ✓ removes special characters\n  ✓ handles empty string\n```\n\n### Phase 3: REFACTOR — Clean Up\n\n1. Improve code quality WITHOUT changing behavior\n2. Run tests after each refactor step — they must stay GREEN\n3. Look for: duplication, unclear naming, complex conditionals, missing types\n4. Commit when satisfied\n\n---\n\n## Rules\n\n1. **Never write implementation before tests** — If you catch yourself coding logic before a test exists, stop and write the test first.\n2. **One test at a time** — Write one test, see it fail, make it pass. Then the next.\n3. **Minimal implementation** — Don't write code \"you'll need later.\" Only satisfy current tests.\n4. **Tests must fail first** — If a new test passes immediately, either the test is wrong or the behavior already exists. Investigate.\n5. **Refactor only when green** — Never refactor while tests are failing.\n6. **Small commits** — Commit at the end of each RED-GREEN-REFACTOR cycle.\n\n---\n\n## Commit Convention\n\n```\ntest: add tests for slug utility (RED)\nfeat(utils): implement slug generation (GREEN)\nrefactor(utils): simplify slug regex (REFACTOR)\n```\n\n---\n\n## When to Break the Cycle\n\nIt's okay to skip TDD for:\n- Configuration files (no logic to test)\n- Type definitions (TypeScript compiler is the test)\n- One-line wrappers around well-tested libraries\n- UI layout (visual testing is better here)\n\nBut ALWAYS use TDD for:\n- Business logic\n- Data transformations\n- Validation rules\n- API endpoint handlers\n- State management logic"}}