skill-tdd
GitHub指导遵循测试驱动开发(TDD)流程,严格执行红绿重构循环。要求先写失败测试验证行为,再实现最小代码使其通过,最后重构并保持测试绿色。禁止无测试直接修改生产代码。
Trigger Scenarios
Install
npx skills add nyldn/claude-octopus --skill skill-tdd -g -y
SKILL.md
Frontmatter
{
"name": "skill-tdd",
"paths": [
"**\/*.test.*",
"**\/*.spec.*",
"**\/tests\/**",
"**\/__tests__\/**"
],
"aliases": [
"tdd",
"test-driven-development"
],
"trigger": "Use when a feature, bug fix, or behavior change requires test-first evidence.\nDo not use for documentation-only changes or disposable exploration.\n",
"description": "Build a behavior change with observed red, minimal green, and measured test consolidation",
"validation_gates": [
"focused_red_observed",
"focused_and_affected_suites_green"
],
"pre_execution_contract": [
"observable_behavior_named"
],
"disable-model-invocation": true
}
Test-driven development
Read skills/blocks/engineering-method-selection.md from the installed plugin
for review admission. Natural-language requests and --peer-review share that
policy. Honor host-only requests; risk alone does not authorize paid usage.
Run the red, green, and refactor cycle on the current host. Routine TDD makes
zero additional provider dispatches. Use one external reviewer only when the
user passes --peer-review, explicitly requests independent review, or an
existing risk policy requires it. Explicit debate, council, and multi-model
commands retain their own execution contracts.
The rule
Do not change production behavior until a focused test fails for the expected reason. Existing implementation outside the requested change remains intact.
- Name the observable behavior and the smallest public boundary that proves it.
- Write one focused test. Directly test an internal invariant only when the public boundary cannot isolate its failure mode.
- Run it and record the expected failure, command, and exit status.
- Implement the smallest change that passes.
- Run the focused test, then the affected suite.
- Refactor only while the tests remain green.
If a test passes before implementation, it is not red evidence. If it errors due to fixture or syntax problems, repair the test until it fails on the missing behavior.
Consolidating tests
Do not equate similar assertions with duplicate guarantees. Keep separate OS,
security, cancellation, and integration boundaries. For every removed test,
record old_test, behavior, replacement, mutant, red_observed,
baseline_ms, candidate_ms, and reason. The retained test must kill the
named mutant at the intended caller boundary.
After one warm-up, measure five isolated runs and report every sample and the median. Review a slowdown only when it exceeds both 20 percent and 100 ms.
Completion requires observed red and green evidence, affected-suite results, and the consolidation ledger when tests were removed. A missing reviewer is reported as incomplete review, never simulated.
Strategy rotation
If the same test remains red after two implementation attempts, stop and recheck the test boundary, fixture, and expected behavior. The strategy-rotation hook is a signal to try a fundamentally different hypothesis, not another variation of the same patch.
Adapted from DEEPENING in mattpocock/skills at commit
3cca18b368ae95cdbdebbff572ccafa662551015 under the MIT License. See
THIRD_PARTY_NOTICES.md.
Version History
-
2d3ee65
Current 2026-09-22 23:05
简化了违规惩罚描述,移除了对 orchestrate.sh 的强制依赖,强调自然语言请求和 peer-review 共享准入策略,优化了测试合并与性能测量的记录规范。
- 242e51d 2026-08-20 09:31


