test-first
Write a failing behavior test, make it pass, then refactor. Use for TDD, regression tests, or bugs with obvious repros; use eval-runs or eval-hillclimb for skill or prompt evals.
Cynnamoroll · 已有静态检查记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add Cynnamoroll/factory-stack --skill test-first技能说明
name: test-first description: "Write a failing behavior test, make it pass, then refactor. Use for TDD, regression tests, or bugs with obvious repros; use eval-runs or eval-hillclimb for skill or prompt evals." license: MIT compatibility: droid
Test first
Before changing production code, make the intended behavior executable. Require failure before and success after.
Steps
- Pin the behavior. State the intended behavior, the current behavior, and the smallest observable case.
- Pick the narrowest test. Use the closest existing unit, component, or integration test for the path, without building a new harness just for this skill.
- Write the test. Drive the code through the interface its users touch. Derive the expected value from the requirement, not from a run of the code. See
engineering-principles(test-behavior-not-implementation). - Watch it fail. Run it. It must fail for the intended reason. If it passes, or fails for another reason, fix the test first.
- Make it pass. Write the smallest production change that satisfies the test.
- Rerun. The new test passes, and the nearby tests still pass.
- Refactor. Clean up with the tests green. Rerun after each step.
- Order the commits. The failing test lands before the fix, so a reviewer can watch it go red, then green.
When a test is impractical
If the only test needs broad harness setup, brittle mocks, production-only state, or large fixture churn, use a script, repro command, or app drive through prove-it-works instead.
Guardrails
- Never change a test to match a wrong implementation.
- Never weaken an existing assertion unless the expected behavior changed, and say why.
- Keep the test on this behavior. No unrelated coverage.
- For a flaky bug, make the test deterministic and name the signal it locks down.
Done when
The reply names the test, pastes its failing output from before the change and its passing output after, lists the nearby checks you ran, and confirms the production change is limited to what the test required. If no failing test was practical, it says why and shows the check used instead.