tdd
Test-driven development workflow using the Red-Green-Refactor cycle.
- License 许可
- Apache-2.0
- 最近更新
- 2026-10-14
- Stars
- ★ 8
- Forks
- 0
01 前言 Front Matter
- name
- tdd
- description
- Test-driven development workflow using the Red-Green-Refactor cycle.
- when-to-use
- Use when implementing any new feature or fixing a bug. Write the test first.
- allowed-tools
- [ "Bash", "Read", "Write", "Edit" ]
- disable-model-invocation
- false
02 资源文件 1
- 参考文档references/template.md1.3 KB
03 SKILL.md 正文
Red Phase
Write a test that describes the expected behavior. The test must fail before any implementation code is written. Run the test and confirm the failure message is clear and specific.
go test ./path/to/package -run TestNew -v
Verify the test fails with a meaningful message, not a compile error.
Green Phase
Write the minimal code required to make the failing test pass. Do not add extra functionality, error handling for hypothetical cases, or premature abstractions. Run the test and confirm it passes.
Refactor Phase
Improve the code structure without changing behavior. Extract functions, rename variables, remove duplication. Run the full test suite after each refactoring step to ensure nothing breaks.
Rules
- Never skip the red phase. If the test passes before implementation, the test is wrong.
- One assertion per test when possible. Multiple assertions obscure which behavior failed.
- Test names describe the scenario:
TestCompile_MissingField_ReturnsError. - Use
t.Helper()in all test helper functions so failures report the caller's line number.
04 同仓库更多 Skills
tdd
Test-driven development workflow using the Red-Green-Refactor cycle.
debugging
Systematic debugging workflow for isolating root causes before applying fixes.
tdd
Test-driven development workflow using the Red-Green-Refactor cycle.
code-review
Structured code review process covering correctness, security, and performance.
web-search
Search the web
code-review
Systematic code review workflow