java/src/main/resources/targets/claude/skills/core/test/x-test-tdd/SKILL.md
Executes systematic Red-Green-Refactor TDD cycles for a task. Reads the task plan generated by x-task-plan, runs each cycle in TPP order, validates RED/GREEN/REFACTOR phases, delegates atomic commits to x-git-commit with TDD tags, and supports resume and dry-run.
npx skillsauth add edercnj/claude-environment x-test-tddInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Executes systematic Red-Green-Refactor TDD cycles for {{PROJECT_NAME}} tasks. Reads the task plan produced by /x-task-plan, iterates TDD cycles in strict Transformation Priority Premise (TPP) order, validates each phase (RED must fail, GREEN must pass with minimum code, REFACTOR must preserve behavior), and delegates atomic commits to x-git-commit with TDD tags ([TDD:RED], [TDD:GREEN], [TDD:REFACTOR]). Enforces RULE-008 (TDD Strict) and RULE-016 (Conventional Commits with Task ID).
/x-test-tdd TASK-0029-0001-001 -- execute all TDD cycles for the task/x-test-tdd TASK-0029-0001-001 --from-cycle 3 -- resume from cycle 3/x-test-tdd TASK-0029-0001-001 --dry-run -- list cycles without executing/x-test-tdd TASK-0029-0001-001 --warn-only-coverage -- legacy mode: sub-threshold coverage warns instead of blocks/x-test-tdd TASK-0029-0001-001 --orchestrated -- compact single-line cycle log (called from x-story-implement / x-epic-implement)| Parameter | Required | Default | Description |
|-----------|----------|---------|-------------|
| TASK-ID | Yes | — | Task identifier TASK-XXXX-YYYY-NNN (epic-story-task) |
| --from-cycle | No | 1 | Resume from a specific cycle number (≥ 1). Cycles before this are skipped. |
| --dry-run | No | false | List all cycles with descriptions and TPP levels; execute nothing. |
| --warn-only-coverage | No | false | Legacy override (EPIC-0042). When set, coverage < 95% line / < 90% branch emits WARNING instead of blocking the cycle. Default is blocking. |
| --orchestrated | No | false | Emit one-line-per-cycle compact log. Passed explicitly by parent orchestrators (Story 0033-0003) so the decision is deterministic, not inferred. |
x-git-commit — [TDD:RED] (test-only), [TDD:GREEN] (minimum implementation), optional [TDD:REFACTOR] (if the task plan declares opportunities and tests still pass afterward).--orchestrated, one compact line per cycle: Cycle {n}/{m}: RED FAIL_EXPECTED GREEN PASS REFACTOR {skipped|PASS} → {sha7}.0 on clean completion of all requested cycles; 1 on any ABORT condition (see ## Error Envelope).references/full-protocol.md §6).This skill is the inner loop of Double-Loop TDD. The outer loop (failing acceptance test) is driven by x-story-implement / x-task-implement; each inner cycle produces one or more unit commits that compose toward the acceptance green. Full workflow diagram and Double-Loop context live in references/full-protocol.md §5.
| Scenario | Action |
|----------|--------|
| Invalid task ID format (pattern mismatch) | ABORT: "Task ID invalid -- expected format: TASK-XXXX-YYYY-NNN" |
| Task plan file not found | ABORT: "Task plan not found: task-plan-XXXX-YYYY-NNN.md" |
| No TDD Cycles section in plan | ABORT: "No TDD Cycles section found in task plan" |
| --from-cycle N out of range (N < 1 or N > total cycles) | ABORT: "Invalid --from-cycle: N (task plan has M cycles)" |
| RED test PASSES before implementation | ABORT: "RED phase failed: test passes before implementation" (tautology / stale test / behavior already exists) |
| GREEN compile fails | Retry up to 3 times with minimum fix only; ABORT after |
| GREEN tests fail | Retry up to 3 times with minimum fix only; ABORT after |
| REFACTOR tests fail after change | REVERT (git checkout -- .), skip REFACTOR commit, log warning, continue to next cycle |
| Coverage below 95% line / 90% branch after GREEN (default, EPIC-0042) | BLOCK cycle; max 2 retry attempts writing additional tests; ABORT after. Override: --warn-only-coverage demotes to WARNING. |
| x-git-commit fails at any phase | ABORT: "Commit failed at Cycle N, phase [RED|GREEN|REFACTOR]: {error}" |
| Cycles not in strict TPP order in plan | WARN "Cycles not in strict TPP order -- proceeding but review recommended"; continue |
Minimum viable contract above. The complete 4-phase workflow (Validate → Load Plan → Dry-Run Check → Execute Cycles), the parse format for task plan cycles, the TPP reference table with all 8 priority levels, per-phase validation algorithms (RED fail validation, GREEN minimum + coverage gate, REFACTOR revert-on-fail), the compact-vs-full log rendering rules, the Double-Loop TDD diagram, and anti-patterns live in references/full-protocol.md per ADR-0012 (skill body slim-by-default). Standalone invocation from a chat prompt (happy path: given a valid task plan, produce N commits) needs only this SKILL.md; the full protocol is consulted when diagnosing a failed cycle or authoring a new task plan.
| Skill | Relationship | Context |
|-------|-------------|---------|
| x-task-plan | reads from | Task plan provides TDD cycle definitions |
| x-git-commit | delegates to | Each phase produces an atomic commit via x-git-commit |
| x-code-format | invoked via x-git-commit chain | Format runs before commit |
| x-code-lint | invoked via x-git-commit chain | Lint runs before commit |
| x-test-run | complementary | Coverage analysis helper; this skill uses {{TEST_COMMAND}} + {{COVERAGE_COMMAND}} directly |
| x-story-implement | orchestrated by | Lifecycle invokes x-test-tdd for inner-loop TDD execution (Phase 2) |
| x-task-implement | complementary | Full-task orchestrator; this skill handles per-task TDD only |
| Variable | Description | Example |
|----------|-------------|---------|
| {{TEST_COMMAND}} | Run project tests | mvn test -q |
| {{COMPILE_COMMAND}} | Compile the project | mvn compile -q |
| {{COVERAGE_COMMAND}} | Run tests with coverage | mvn verify -Pcoverage -q |
| {{LANGUAGE}} | Project language | java |
| {{PROJECT_NAME}} | Project name | my-java-cli |
| {{BUILD_TOOL}} | Project build tool | maven |
tools
Documentation automation v2: stack-aware generation from documentation.targets.
development
Generates or updates CI/CD pipelines per project stack with actionlint validation.
tools
Generates ADRs from architecture-plan mini-ADRs with sequential numbering and index update.
development
Formats source code; first step of the pre-commit chain (format -> lint -> compile).