AGENT SKILL

x-drive-tdd

Executes systematic Red-Green-Refactor TDD cycles for a task. Reads the task plan generated by x-plan-task, runs each cycle in TPP order, validates RED/GREEN/REFACTOR phases, delegates atomic commits to x-commit-changes with TDD tags, and supports resume and dry-run.

License 许可
MIT
最近更新
2026-10-27
Stars
★ 0
Forks
1

01 前言 Front Matter

name
x-drive-tdd
description
Executes systematic Red-Green-Refactor TDD cycles for a task. Reads the task plan generated by x-plan-task, runs each cycle in TPP order, validates RED/GREEN/REFACTOR phases, delegates atomic commits to x-commit-changes with TDD tags, and supports resume and dry-run.
allowed-tools
Bash, Read, Write, Edit, Grep, Glob, Skill
argument-hint
TASK-XXXX-YYYY-NNN [--from-cycle N] [--dry-run] [--warn-only-coverage] [--orchestrated]
context-budget
light
user-invocable
true
requires-capabilities
[]

02 资源文件 2

03 SKILL.md 正文

Global Output Policy

  • Language: English ONLY.
  • Tone: Technical, Direct, and Concise.
  • Efficiency: Remove all conversational fillers and greetings to save tokens.

Skill: TDD Execution with Atomic Cycles (slim — ADR-0012)

Executes systematic Red-Green-Refactor TDD cycles for {{PROJECT_NAME}} tasks. Reads the task plan produced by /x-plan-task, 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-commit-changes with TDD tags ([TDD:RED], [TDD:GREEN], [TDD:REFACTOR]). Enforces RULE-008 (TDD Strict) and RULE-016 (Conventional Commits with Task ID).

Triggers

  • /x-drive-tdd TASK-0029-0001-001 -- execute all TDD cycles for the task
  • /x-drive-tdd TASK-0029-0001-001 --from-cycle 3 -- resume from cycle 3
  • /x-drive-tdd TASK-0029-0001-001 --dry-run -- list cycles without executing
  • /x-drive-tdd TASK-0029-0001-001 --warn-only-coverage -- legacy mode: sub-threshold coverage warns instead of blocks
  • /x-drive-tdd TASK-0029-0001-001 --orchestrated -- compact single-line cycle log (called from x-implement-story / x-implement-epic)

Parameters

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.

Output Contract

  • Per-cycle artifacts: each TDD cycle produces up to three atomic commits via x-commit-changes — [TDD:RED] (test-only), [TDD:GREEN] (minimum implementation), optional [TDD:REFACTOR] (if the task plan declares opportunities and tests still pass afterward).
  • Final report to stdout: cycles executed, commits created with SHA + message first-line per cycle, final coverage line/branch %, warnings list. Under --orchestrated, one compact line per cycle: Cycle {n}/{m}: RED FAIL_EXPECTED GREEN PASS REFACTOR {skipped|PASS} → {sha7}.
  • Exit codes: 0 on clean completion of all requested cycles; 1 on any ABORT condition (see ## Error Envelope).
  • Commit cadence: each phase is one atomic commit; batching multiple phases into one commit is forbidden (see anti-patterns in references/full-protocol.md §6).

Double-Loop Role

This skill is the inner loop of Double-Loop TDD. The outer loop (failing acceptance test) is driven by x-implement-story / x-implement-task; 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.

Error Envelope

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-commit-changes fails at any phase ABORT: `"Commit failed at Cycle N, phase [RED
Cycles not in strict TPP order in plan WARN "Cycles not in strict TPP order -- proceeding but review recommended"; continue

Full Protocol

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.

Integration Notes

Skill Relationship Context
x-plan-task reads from Task plan provides TDD cycle definitions
x-commit-changes delegates to Each phase produces an atomic commit via x-commit-changes
x-format-code invoked via x-commit-changes chain Format runs before commit
x-lint-code invoked via x-commit-changes chain Lint runs before commit
x-execute-tests complementary Coverage analysis helper; this skill uses {{TEST_COMMAND}} + {{COVERAGE_COMMAND}} directly
x-implement-story orchestrated by Lifecycle invokes x-drive-tdd for inner-loop TDD execution (Phase 2)
x-implement-task complementary Full-task orchestrator; this skill handles per-task TDD only

Template Variables

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

04 同仓库更多 Skills

review-bench
review-bench/edercnj_ia-dev-environment

x-parallel-eval

Detects and classifies file-collision risks between work units (tasks, stories, or epic phases) before parallel execution. Reads ## File Footprint blocks produced by x-task-plan / x-story-plan, applies the parallelism-heuristics knowledge pack (hard / regen / soft categories + hotspot overrides), and emits a collision matrix + serialization recommendation in Markdown (default) or JSON.

★ 0
review-bench
review-bench/edercnj_ia-dev-environment

parallelism-heuristics

Canonical catalog of file-collision heuristics for parallel task, story, and epic execution. Defines the File Footprint block format, the three Conflict Categories (hard / regen / soft), a hotspot list of high-contention paths, and the degrade-with-warning policy. Consumed by x-task-plan, x-story-plan, x-epic-map, x-parallel-eval, and x-dev-*-implement.

★ 0
review-bench
review-bench/edercnj_ia-dev-environment

x-watch-pr-ci

Polls a PR's CI checks and Copilot review status, blocking until checks complete or timeout. Returns one of 8 stable exit codes (SUCCESS=0, CI_PENDING_PROCEED=10, CI_FAILED=20, TIMEOUT=30, PR_ALREADY_MERGED=40, NO_CI_CONFIGURED=50, PR_CLOSED=60, PR_NOT_FOUND=70). Writes a versioned state-file for session resume.

★ 0
review-bench
review-bench/edercnj_ia-dev-environment

x-validate-docs

Documentation freshness gate: validates 6 dimensions (readme, api-specs, grpc-proto, adr, skill-docs, system-architecture) against code changes in a PR. Stack-aware — only validates targets declared/auto-detected from ProjectConfig.documentation.targets. Returns exit non-zero on staleness; produces structured report.

★ 0
review-bench
review-bench/edercnj_ia-dev-environment

x-update-system-architecture

Incrementally updates docs/architecture/system.md after an epic completes. Appends new entries to the Decision Log (§11) using x-internal-write-report --append (dedup by ## ID: marker) and surgically inserts component/integration changes into sections 1-10 via Edit. Idempotent: re-running with the same epic produces a byte-identical system.md.

★ 0
review-bench
review-bench/edercnj_ia-dev-environment

x-update-architecture

Incrementally updates the service architecture document with changes from architecture plans. Adds new components, integrations, flows, and ADR references without rewriting existing content. Use after implementation to keep architecture documentation current.

★ 0