{"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":"fa96b21647f170ef0e0ab4f8f3c53e9a374e3f3beedaa064863b6df65efd4c9e","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\n\n## Playground\n\n<!DOCTYPE html><html><head><meta charset='utf-8'><style>*{box-sizing:border-box;margin:0;padding:0}body{background:#0d1117;font-family:monospace;font-size:12px;height:100vh;display:flex;flex-direction:column;align-items:center;justify-content:center;overflow:hidden}.title{color:#58a6ff;font-size:14px;font-weight:bold;margin-bottom:24px}.flow{display:flex;align-items:center;gap:0}.step{width:112px;height:84px;border-radius:8px;display:flex;flex-direction:column;align-items:center;justify-content:center;font-size:11px;font-weight:bold;text-align:center;padding:8px}.arrow{color:#30363d;font-size:20px;padding:0 6px}.red{background:#3d1117;border:2px solid #f85149;color:#f85149}.green{background:#0d2d1a;border:2px solid #3fb950;color:#3fb950}.blue{background:#0d1f3d;border:2px solid #58a6ff;color:#58a6ff}.sub{font-size:9px;color:#8b949e;font-weight:normal;margin-top:4px;line-height:1.4}.rule{color:#8b949e;font-size:10px;margin-top:20px;text-align:center;max-width:380px;line-height:1.6}</style></head><body><div class='title'>TDD Workflow · Red→Green→Refactor</div><div class='flow'><div class='step red'>🔴 RED<div class='sub'>Write a failing test.<br>Run it. See it fail.</div></div><div class='arrow'>→</div><div class='step green'>🟢 GREEN<div class='sub'>Write minimum code<br>to pass the test.</div></div><div class='arrow'>→</div><div class='step blue'>🔵 REFACTOR<div class='sub'>Clean up. Keep tests<br>green. Repeat.</div></div></div><div class='rule'>Rule: never write production code without a failing test first.<br>Rule: commit after each green. CI must stay green at every commit.</div></body></html>"}}