tdd-refactor
Hierarchical TDD & Refactoring state machine with nested micro-cycles, regression detection, event bubbling, and live projections
- License 许可
- AGPL-3.0
- 最近更新
- 2026-11-14
- Stars
- ★ 1
- Forks
- 1
01 前言 Front Matter
- name
- tdd-refactor
- description
- Hierarchical TDD & Refactoring state machine with nested micro-cycles, regression detection, event bubbling, and live projections
03 SKILL.md 正文
tdd-refactor
Work through these phases in order. Do not start a phase before the previous one has ended as described.
State: RED_SPEC (Failing Specification)
Active Constraints:
- Target File:
src/auth.ts - Test File:
tests/auth.test.ts - Requirement:
the requirement you were given
Your Goal:
- View the current test suite in
tests/auth.test.ts. - Add one precise test case for the requirement. If it is empty, ask the user for the requirement before writing the test.
- Run the test suite using a shell command.
- DO NOT write the production code implementation yet.
- The test MUST fail (
exit_code != 0).
Continue to GREEN_CODE when the run exits non-zero.
State: GREEN_CODE (Minimal Passing Implementation)
Active Constraints:
- Target File:
src/auth.ts - Test File:
tests/auth.test.ts
Your Goal:
- Write the minimal necessary implementation in
src/auth.tsto make the failing test pass. - Run the test suite using a shell command.
- Do not perform extraneous refactoring yet—only make the tests green (
exit_code === 0).
Continue to REFACTOR when every run exits 0.
Substate: REFACTOR.CLEAN_CODE (Structure & Readability)
Invariants:
- Target File:
src/auth.ts - All tests MUST remain green.
Your Goal:
- Simplify logic, extract deep helper functions, and clarify naming.
- Verify tests pass (a shell command).
Continue to PERF_AUDIT when this phase is done. If a test fails at any point during refactoring, go back to GREEN_CODE.
Substate: REFACTOR.PERF_AUDIT (Performance & Allocation Gate)
Invariants:
- Target File:
src/auth.ts - All tests MUST remain green.
Your Goal:
- Audit memory allocations, loop complexity, and asynchronous bottlenecks.
- Verify zero regressions using a shell command.
Continue to AUDIT_VERIFY when this phase is done. If a test fails at any point during refactoring, go back to GREEN_CODE.
State: AUDIT_VERIFY (Verification & Quality Gate)
Your Goal:
- Run linter, typecheck, and full test suite verification.
- Confirm zero regression across the workspace.
Continue to COMPLETED when every run exits 0. If any check fails, go back to GREEN_CODE.
State: COMPLETED (Delivery Finalized)
The TDD refactor cycle has successfully concluded. All transition contracts and safety invariants have been satisfied.
Write .docs/tdd-refactor-summary.md listing each phase you completed, in order, with the check result that ended it.
04 同仓库更多 Skills
clean-code-sample
Applies clean code rules for naming and modular functions
_test_hsm_skill
暂无简介
_test_hitl_skill
暂无简介
test-fsm
Generic FSM test fixture
triage-bug
Investigate a reported bug and write a triage note before anyone changes code.
release-note
Record a shipped fix in the changelog once its tests pass.