[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-c7290dc7-f320-49cd-85b2-0cedac33e266":3,"$f1gGnEdKDKV6yaj9OyZlX31jlKy20IaoDTfwFlJG6d9k":43},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":34},"c7290dc7-f320-49cd-85b2-0cedac33e266","tdd-workflow","测试驱动开发工作流程原则。红-绿-重构周期。","cat_coding_review","mod_coding","sickn33,coding","---\nname: tdd-workflow\ndescription: \"Test-Driven Development workflow principles. RED-GREEN-REFACTOR cycle.\"\nrisk: unknown\nsource: community\ndate_added: \"2026-02-27\"\n---\n\n# TDD Workflow\n\n> Write tests first, code second.\n\n---\n\n## 1. The TDD Cycle\n\n```\n🔴 RED → Write failing test\n    ↓\n🟢 GREEN → Write minimal code to pass\n    ↓\n🔵 REFACTOR → Improve code quality\n    ↓\n   Repeat...\n```\n\n---\n\n## 2. The Three Laws of TDD\n\n1. Write production code only to make a failing test pass\n2. Write only enough test to demonstrate failure\n3. Write only enough code to make the test pass\n\n---\n\n## 3. RED Phase Principles\n\n### What to Write\n\n| Focus | Example |\n|-------|---------|\n| Behavior | \"should add two numbers\" |\n| Edge cases | \"should handle empty input\" |\n| Error states | \"should throw for invalid data\" |\n\n### RED Phase Rules\n\n- Test must fail first\n- Test name describes expected behavior\n- One assertion per test (ideally)\n\n---\n\n## 4. GREEN Phase Principles\n\n### Minimum Code\n\n| Principle | Meaning |\n|-----------|---------|\n| **YAGNI** | You Aren't Gonna Need It |\n| **Simplest thing** | Write the minimum to pass |\n| **No optimization** | Just make it work |\n\n### GREEN Phase Rules\n\n- Don't write unneeded code\n- Don't optimize yet\n- Pass the test, nothing more\n\n---\n\n## 5. REFACTOR Phase Principles\n\n### What to Improve\n\n| Area | Action |\n|------|--------|\n| Duplication | Extract common code |\n| Naming | Make intent clear |\n| Structure | Improve organization |\n| Complexity | Simplify logic |\n\n### REFACTOR Rules\n\n- All tests must stay green\n- Small incremental changes\n- Commit after each refactor\n\n---\n\n## 6. AAA Pattern\n\nEvery test follows:\n\n| Step | Purpose |\n|------|---------|\n| **Arrange** | Set up test data |\n| **Act** | Execute code under test |\n| **Assert** | Verify expected outcome |\n\n---\n\n## 7. When to Use TDD\n\n| Scenario | TDD Value |\n|----------|-----------|\n| New feature | High |\n| Bug fix | High (write test first) |\n| Complex logic | High |\n| Exploratory | Low (spike, then TDD) |\n| UI layout | Low |\n\n---\n\n## 8. Test Prioritization\n\n| Priority | Test Type |\n|----------|-----------|\n| 1 | Happy path |\n| 2 | Error cases |\n| 3 | Edge cases |\n| 4 | Performance |\n\n---\n\n## 9. Anti-Patterns\n\n| ❌ Don't | ✅ Do |\n|----------|-------|\n| Skip the RED phase | Watch test fail first |\n| Write tests after | Write tests before |\n| Over-engineer initial | Keep it simple |\n| Multiple asserts | One behavior per test |\n| Test implementation | Test behavior |\n\n---\n\n## 10. AI-Augmented TDD\n\n### Multi-Agent Pattern\n\n| Agent | Role |\n|-------|------|\n| Agent A | Write failing tests (RED) |\n| Agent B | Implement to pass (GREEN) |\n| Agent C | Optimize (REFACTOR) |\n\n---\n\n> **Remember:** The test is the specification. If you can't write a test, you don't understand the requirement.\n\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,90,1512,"2026-05-16 13:43:15",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"编程开发","coding","mdi-code-braces","代码生成、调试、审查，提升开发效率",2,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":32,"skillCount":33,"createdAt":26},"代码审查","review","mdi-magnify-scan","代码质量分析、安全审查",4,145,[35],{"id":36,"skillId":4,"version":37,"fileName":38,"fileSize":39,"filePath":40,"fileHash":41,"manifest":42,"createdAt":19},"f449aece-4b2a-440f-b77d-6af8c999a526","1.0.0","tdd-workflow.zip",1657,"uploads\u002Fskills\u002Fc7290dc7-f320-49cd-85b2-0cedac33e266\u002Ftdd-workflow.zip","dc5675e67aa919957932108a0d47da3e7907d4ead666cf409651f213646feeb3","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":3243}]",{"code":44,"message":45,"data":46},200,"success",{"items":47,"stats":48,"page":51},[],{"averageRating":49,"totalRatings":49,"ratingCounts":50},0,[49,49,49,49,49],{"limit":52,"offset":49,"hasMore":53,"nextOffset":52,"ratedOnly":16},15,false]