add-tdd-cycle
[ADD v0.11.0] Execute complete TDD cycle — RED → GREEN → REFACTOR → VERIFY against a spec
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
[ADD v0.11.0] Execute complete TDD cycle — RED → GREEN → REFACTOR → VERIFY against a spec
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
[ADD v0.11.0] Generate or sync a portable AGENTS.md from ADD project state — writes, checks drift, or merges with hand-curated content
[ADD v0.11.0] Declare absence — get autonomous work plan for the duration
[ADD v0.11.0] Return from absence — get briefing on autonomous work
[ADD v0.11.0] View project branding — accent color, palette, drift detection, image gen status
[ADD v0.11.0] Update project branding — new colors, fonts, tone, audit artifacts
[ADD v0.11.0] Generate or refresh CHANGELOG.md from conventional commits
| name | add-tdd-cycle |
| description | [ADD v0.11.0] Execute complete TDD cycle — RED → GREEN → REFACTOR → VERIFY against a spec |
| argument-hint | specs/{feature}.md [--ac AC-001,AC-002] [--parallel] [--allow-test-rewrite] |
Execute a complete Test-Driven Development cycle for a feature from the specification through production-quality code.
The TDD Cycle is the primary "do the work" skill in Agent Driven Development. It orchestrates the full lifecycle:
This skill coordinates sub-agents (test-writer, implementer, reviewer, verify) and maintains traceability between specs, tests, and implementation.
Every Task-tool dispatch from this skill (test-writer, implementer, reviewer,
verify) MUST emit a prompt body laid out per rules/cache-discipline.md.
Construct the prompt as follows — the STABLE block is byte-identical across
every dispatch in a session; only the VOLATILE block changes per role.
knowledge/global.md)~/.claude/add/library-active.md) if present.add/config.json.add/learnings-active.md)rules/model-roles.md, never
hardcoded model names)~/.codex/add/references/swarm-protocol.md (overridable
via .add/config.json → swarm.budgets)Validate compliance with python3 scripts/validate-cache-discipline.py.
Before beginning, validate:
~/.codex/add/references/skill-epilogue.mdInvoke the /add-test-writer skill with the spec reference:
specs/{feature}.md [--ac AC-001,AC-002]test_AC_NNN_description for traceabilityVerify tests actually fail:
npm test or python -m pytest depending on configRED-end snapshot (test-deletion guardrail — required since v0.9.0):
After test-writer signals RED complete, capture the test surface snapshot:
python3 ~/.codex/add/../../scripts/check-test-count.py snapshot \
--phase red \
--cycle-id {N} \
--spec-slug {slug} \
--base-sha {cycle-base-sha} \
--fail-on-empty
This writes .add/cycles/cycle-{N}/tdd-{slug}-red.json. The --fail-on-empty flag
enforces AC-006: a RED phase that produced zero new tests is itself a TDD violation
and halts the cycle. Commit the snapshot with:
git add .add/cycles/cycle-{N}/tdd-{slug}-red.json
git commit -m "test(red): snapshot {total_functions} tests for {slug}"
See core/rules/tdd-enforcement.md "Test-Deletion Invariant" for the full rationale.
Pre-GREEN: files-likely-affected hint.
Before invoking the implementer, generate the impact hint so the implementer enters GREEN with a focused set of candidate files:
bash ~/.codex/add/lib/impact-hint.sh {cycle-base-sha} specs/{feature}.md .
The helper emits a two-section block: Files likely to need changes (from diff +
import resolution + spec path scan) and Files to be careful around (paths mentioned
in anti-pattern learnings). Pass this block to the implementer verbatim as part of its
context — see core/skills/implementer/SKILL.md §Pre-Flight.
Once RED phase is complete, invoke the /add-implementer skill:
specs/{feature}.md [--ac AC-001,AC-002]After implementation:
npm test or equivalentGREEN-end snapshot (test-deletion guardrail — required since v0.9.0):
python3 ~/.codex/add/../../scripts/check-test-count.py snapshot \
--phase green \
--cycle-id {N} \
--spec-slug {slug} \
--base-sha {cycle-base-sha}
This writes .add/cycles/cycle-{N}/tdd-{slug}-green.json. Gate 3.5 in /add-verify
compares RED vs GREEN and fails if tests were removed without a recorded override.
With all tests green, refactor for quality:
specs/{feature}.md --scope fullnpm testRun the full verification suite using /add-verify skill:
--level deploy (all gates for production readiness).add/cycles/cycle-{N}/ and fails if tests were removed without an override.
If --allow-test-rewrite was passed to this cycle and the user approved via the
prompt, the approval is recorded in .add/cycles/cycle-{N}/overrides.json and
the gate reads it.If any gate fails:
Upon successful completion, output:
# TDD Cycle Complete ✓
## Feature
{feature-name} v{spec-version}
## Summary
- Tests Written: {count}
- Tests Passing: {count}
- Code Coverage: {percentage}%
- Refactoring Issues Fixed: {count}
- Quality Gates: {pass/total}
## Acceptance Criteria Status
- AC-001: ✓ Passing
- AC-002: ✓ Passing
... (all ACs listed with status)
## Next Steps
1. Review code in {implementation-path}
2. Merge to main branch
3. Deploy to staging environment
## Artifacts
- Tests: {test-file-paths}
- Implementation: {code-file-paths}
- Plan: docs/plans/{feature}-plan.md
Tasks to create (mechanics per ~/.codex/add/references/skill-epilogue.md):
| Phase | Subject | activeForm |
|---|---|---|
| Pre-flight | Loading spec and config | Loading spec and config... |
| RED | Writing failing tests | Writing failing tests... |
| GREEN | Implementing code | Implementing code to pass tests... |
| REFACTOR | Refactoring for quality | Refactoring for code quality... |
| VERIFY | Running verification gates | Running verification gates... |
Tests won't compile/run
npm install or equivalent dependency installationTests still failing after GREEN phase
/add-implementer again with specific AC rangeQuality gate failures
--fix flag on /add-verifyPerformance issues detected
--allow-test-rewrite flag (v0.9.0+)By default, if the GREEN snapshot shows any test removed OR any same-name test with a
changed body, Gate 3.5 fails the cycle. If the user knows a test was legitimately wrong
(asserted incorrect behavior), pass --allow-test-rewrite:
GREEN comparison detects the replacement
Human approval prompt is shown with the RED body and the GREEN body side by side
If the human confirms, an override is recorded in
.add/cycles/cycle-{N}/overrides.json:
{
"kind": "test-rewrite",
"approved_by": "human",
"timestamp": "2026-04-22T14:32:00Z",
"affected_tests": ["tests/test_auth.py::test_validation"]
}
Gate 3.5 reads the override and passes
Telemetry records override_used: true for retro review
Without --allow-test-rewrite, or without explicit human confirmation, Gate 3.5 fails
and the cycle does not advance.
If --parallel flag is set:
The skill respects these .add/config.json settings:
test.framework: The test framework (jest, pytest, vitest, etc.)test.minCoverage: Minimum code coverage percentagetest.convention: Test file naming conventioncode.style: Code style rules and lintersci.gates: Which gates to run and in what orderEnd-of-skill epilogue: follow ~/.codex/add/references/skill-epilogue.md (observation + learning checkpoint + progress tracking). Learning checkpoint trigger: "After TDD Cycle Completes".