workflow-tdd-plan
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWorkflow TDD Plan
TDD工作流规划
6-phase TDD planning workflow that orchestrates session discovery, context gathering, test coverage analysis, conflict resolution, and TDD task generation to produce implementation plans with Red-Green-Refactor cycles. Includes post-execution TDD compliance verification.
包含会话发现、上下文收集、测试覆盖率分析、冲突解决及TDD任务生成的6阶段TDD规划工作流,可生成带有红-绿-重构周期的实施计划,同时支持执行后的TDD合规验证。
Architecture Overview
架构概述
┌──────────────────────────────────────────────────────────────────┐
│ Workflow TDD Plan Orchestrator (SKILL.md) │
│ → Pure coordinator: Execute phases, parse outputs, pass context │
└───────────────┬──────────────────────────────────────────────────┘
│
┌────────────┼────────────┬────────────┬────────────┐
↓ ↓ ↓ ↓ ↓
┌────────┐ ┌────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
│ Phase 1│ │ Phase 2│ │ Phase 3 │ │ Phase 4 │ │ Phase 5 │
│Session │ │Context │ │Test Covg │ │Conflict │ │TDD Task │
│Discover│ │Gather │ │Analysis │ │Resolve │ │Generate │
│ (ext) │ │ (ext) │ │ (local) │ │(ext,cond)│ │ (local) │
└────────┘ └────────┘ └──────────┘ └──────────┘ └──────────┘
↓ ↓ ↓ ↓ ↓
sessionId contextPath testContext resolved IMPL_PLAN.md
conflict_risk artifacts task JSONs
Phase 6: TDD Structure Validation (inline in SKILL.md)
Post-execution verification:
┌──────────────┐ ┌───────────────────┐
│ TDD Verify │────→│ Coverage Analysis │
│ (local) │ │ (local) │
└──────────────┘ └───────────────────┘
phases/03-tdd- phases/04-tdd-
verify.md coverage-analysis.md┌──────────────────────────────────────────────────────────────────┐
│ Workflow TDD Plan Orchestrator (SKILL.md) │
│ → Pure coordinator: Execute phases, parse outputs, pass context │
└───────────────┬──────────────────────────────────────────────────┘
│
┌────────────┼────────────┬────────────┬────────────┐
↓ ↓ ↓ ↓ ↓
┌────────┐ ┌────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
│ Phase 1│ │ Phase 2│ │ Phase 3 │ │ Phase 4 │ │ Phase 5 │
│Session │ │Context │ │Test Covg │ │Conflict │ │TDD Task │
│Discover│ │Gather │ │Analysis │ │Resolve │ │Generate │
│ (ext) │ │ (ext) │ │ (local) │ │(ext,cond)│ │ (local) │
└────────┘ └────────┘ └──────────┘ └──────────┘ └──────────┘
↓ ↓ ↓ ↓ ↓
sessionId contextPath testContext resolved IMPL_PLAN.md
conflict_risk artifacts task JSONs
Phase 6: TDD Structure Validation (inline in SKILL.md)
Post-execution verification:
┌──────────────┐ ┌───────────────────┐
│ TDD Verify │────→│ Coverage Analysis │
│ (local) │ │ (local) │
└──────────────┘ └───────────────────┘
phases/03-tdd- phases/04-tdd-
verify.md coverage-analysis.mdKey Design Principles
核心设计原则
- Pure Orchestrator: Execute phases in sequence, parse outputs, pass context between them
- Auto-Continue: All phases run autonomously without user intervention between phases
- Subagent Lifecycle: Explicit lifecycle management with spawn_agent → wait → close_agent
- Progressive Phase Loading: Phase docs are read on-demand, not all at once
- Conditional Execution: Phase 4 only executes when conflict_risk >= medium
- TDD-First: Every feature starts with a failing test (Red phase)
- Role Path Loading: Subagent roles loaded via path reference in MANDATORY FIRST STEPS
CLI Tool Selection: CLI tool usage is determined semantically from user's task description. Include "use Codex/Gemini/Qwen" in your request for CLI execution.
Task Attachment Model:
- Skill execute expands workflow by attaching sub-tasks to current TodoWrite
- When executing a sub-command, its internal tasks are attached to the orchestrator's TodoWrite
- Orchestrator executes these attached tasks sequentially
- After completion, attached tasks are collapsed back to high-level phase summary
- This is task expansion, not external delegation
Auto-Continue Mechanism:
- TodoList tracks current phase status and dynamically manages task attachment/collapse
- When each phase finishes executing, automatically execute next pending phase
- All phases run autonomously without user interaction
- CONTINUOUS EXECUTION - Do not stop until all phases complete
- 纯编排器:按顺序执行各个阶段,解析输出结果,在阶段间传递上下文
- 自动续行:所有阶段自主运行,阶段间无需用户干预
- 子代理生命周期:通过spawn_agent → wait → close_agent实现明确的生命周期管理
- 渐进式阶段加载:按需读取阶段文档,而非一次性加载全部
- 条件执行:仅当conflict_risk >= medium时才执行第4阶段
- TDD先行:每个功能都从失败的测试开始(红阶段)
- 角色路径加载:子代理角色通过MANDATORY FIRST STEPS中的路径引用加载
CLI工具选择:CLI工具的使用由用户任务描述语义决定。若需CLI执行,请在请求中包含"use Codex/Gemini/Qwen"。
任务附加模型:
- Skill执行时会扩展工作流,将子任务附加到当前TodoWrite
- 执行子命令时,其内部任务会附加到编排器的TodoWrite
- 编排器按顺序执行这些附加任务
- 完成后,附加任务会折叠回高级阶段摘要
- 此为任务扩展,而非外部委托
自动续行机制:
- TodoList跟踪当前阶段状态,动态管理任务的附加/折叠
- 每个阶段执行完成后,自动执行下一个待处理阶段
- 所有阶段自主运行,无需用户交互
- 持续执行 - 所有阶段完成前请勿停止
Auto Mode
自动模式
When or : Auto-continue all phases (skip confirmations), use recommended conflict resolutions, skip TDD clarifications.
--yes-y当使用或参数时:自动续行所有阶段(跳过确认),使用推荐的冲突解决方案,跳过TDD澄清步骤。
--yes-ySubagent API Reference
子代理API参考
spawn_agent
spawn_agent
Create a new subagent with task assignment.
javascript
const agentId = spawn_agent({
message: `创建一个分配了任务的新子代理。
javascript
const agentId = spawn_agent({
message: `TASK ASSIGNMENT
TASK ASSIGNMENT
MANDATORY FIRST STEPS (Agent Execute)
MANDATORY FIRST STEPS (Agent Execute)
- Read role definition: ~/.codex/agents/{agent-type}.md (MUST read first)
- Read: {projectRoot}/.workflow/project-tech.json
- Read: {projectRoot}/.workflow/project-guidelines.json
- Read role definition: ~/.codex/agents/{agent-type}.md (MUST read first)
- Read: {projectRoot}/.workflow/project-tech.json
- Read: {projectRoot}/.workflow/project-guidelines.json
TASK CONTEXT
TASK CONTEXT
${taskContext}
${taskContext}
DELIVERABLES
DELIVERABLES
${deliverables}
`
})
undefined${deliverables}
`
})
undefinedwait
wait
Get results from subagent (only way to retrieve results).
javascript
const result = wait({
ids: [agentId],
timeout_ms: 600000 // 10 minutes
})
if (result.timed_out) {
// Handle timeout - can continue waiting or send_input to prompt completion
}从子代理获取结果(唯一的结果获取方式)。
javascript
const result = wait({
ids: [agentId],
timeout_ms: 600000 // 10 minutes
})
if (result.timed_out) {
// Handle timeout - can continue waiting or send_input to prompt completion
}send_input
send_input
Continue interaction with active subagent (for clarification or follow-up).
javascript
send_input({
id: agentId,
message: `与活跃子代理继续交互(用于澄清或后续操作)。
javascript
send_input({
id: agentId,
message: `CLARIFICATION ANSWERS
CLARIFICATION ANSWERS
${answers}
${answers}
NEXT STEP
NEXT STEP
Continue with plan generation.
`
})
undefinedContinue with plan generation.
`
})
undefinedclose_agent
close_agent
Clean up subagent resources (irreversible).
javascript
close_agent({ id: agentId })清理子代理资源(操作不可逆)。
javascript
close_agent({ id: agentId })Usage
使用方法
workflow-tdd-plan <task description>
workflow-tdd-plan [-y|--yes] "<task description>"workflow-tdd-plan <task description>
workflow-tdd-plan [-y|--yes] "<task description>"Flags
标志参数
-y, --yes Skip all confirmations (auto mode)
-y, --yes 跳过所有确认(自动模式)
Arguments
参数
<task description> Task description text, TDD-structured format, or path to .md file
<task description> 任务描述文本、TDD结构化格式内容,或指向.md文件的路径
Examples
示例
workflow-tdd-plan "Build user authentication with tests" # Simple TDD task
workflow-tdd-plan "Add JWT auth with email/password and token refresh" # Detailed task
workflow-tdd-plan -y "Implement payment processing" # Auto mode
workflow-tdd-plan "tdd-requirements.md" # From file
undefinedworkflow-tdd-plan "Build user authentication with tests" # 简单TDD任务
workflow-tdd-plan "Add JWT auth with email/password and token refresh" # 详细任务
workflow-tdd-plan -y "Implement payment processing" # 自动模式
workflow-tdd-plan "tdd-requirements.md" # 从文件读取
undefinedTDD Compliance Requirements
TDD合规要求
The Iron Law
铁律
NO PRODUCTION CODE WITHOUT A FAILING TEST FIRSTEnforcement Method:
- Phase 5: includes test-first steps (Red → Green → Refactor)
implementation_approach - Green phase: Includes test-fix-cycle configuration (max 3 iterations)
- Auto-revert: Triggered when max iterations reached without passing tests
Verification: Phase 6 validates Red-Green-Refactor structure in all generated tasks
NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST执行方法:
- 第5阶段:包含测试先行步骤(红 → 绿 → 重构)
implementation_approach - 绿阶段:包含测试修复周期配置(最多3次迭代)
- 自动回滚:当达到最大迭代次数仍未通过测试时触发
验证:第6阶段验证所有生成任务中的红-绿-重构结构
TDD Compliance Checkpoint
TDD合规检查点
| Checkpoint | Validation Phase | Evidence Required |
|---|---|---|
| Test-first structure | Phase 5 | |
| Red phase exists | Phase 6 | Step 1: |
| Green phase with test-fix | Phase 6 | Step 2: |
| Refactor phase exists | Phase 6 | Step 3: |
| 检查点 | 验证阶段 | 所需证据 |
|---|---|---|
| 测试先行结构 | 第5阶段 | |
| 红阶段存在 | 第6阶段 | 步骤1: |
| 带测试修复的绿阶段 | 第6阶段 | 步骤2: |
| 重构阶段存在 | 第6阶段 | 步骤3: |
Core TDD Principles
核心TDD原则
Red Flags - STOP and Reassess:
- Code written before test
- Test passes immediately (no Red phase witnessed)
- Cannot explain why test should fail
- "Just this once" rationalization
- "Tests after achieve same goals" thinking
Why Order Matters:
- Tests written after code pass immediately → proves nothing
- Test-first forces edge case discovery before implementation
- Tests-after verify what was built, not what's required
危险信号 - 立即停止并重新评估:
- 先编写代码再编写测试
- 测试立即通过(未经历红阶段)
- 无法解释测试为何应该失败
- “就这一次”的合理化借口
- “事后测试也能达到同样目标”的想法
顺序为何重要:
- 代码编写完成后再写的测试会立即通过 → 无法证明任何问题
- 测试先行迫使在实现前发现边缘情况
- 事后测试仅验证已构建的内容,而非需求内容
Core Rules
核心规则
- Start Immediately: First action is TodoWrite initialization, second action is execute Phase 1
- No Preliminary Analysis: Do not read files before Phase 1
- Parse Every Output: Extract required data for next phase
- Auto-Continue via TodoList: Check TodoList status to execute next pending phase automatically
- Track Progress: Update TodoWrite dynamically with task attachment/collapse pattern
- TDD Context: All descriptions include "TDD:" prefix
- Task Attachment Model: Skill execute attaches sub-tasks to current workflow. Orchestrator executes these attached tasks itself, then collapses them after completion
- CRITICAL: DO NOT STOP: Continuous multi-phase workflow. After executing all attached tasks, immediately collapse them and execute next phase
- Explicit Lifecycle: Always close_agent after wait completes to free resources
- 立即启动:第一个操作是初始化TodoWrite,第二个操作是执行第1阶段
- 无预先分析:在第1阶段前请勿读取任何文件
- 解析所有输出:提取下一阶段所需的数据
- 通过TodoList自动续行:检查TodoList状态以自动执行下一个待处理阶段
- 跟踪进度:通过任务附加/折叠模式动态更新TodoWrite
- TDD上下文:所有描述均以“TDD:”为前缀
- 任务附加模型:Skill执行时会将子任务附加到当前工作流。编排器自行执行这些附加任务,完成后将其折叠
- 关键:请勿停止:持续的多阶段工作流。执行完所有附加任务后,立即将其折叠并执行下一阶段
- 明确生命周期:wait完成后务必调用close_agent以释放资源
Execution Flow
执行流程
Input Parsing:
└─ Convert user input to TDD-structured format (TDD:/GOAL/SCOPE/CONTEXT/TEST_FOCUS)
Phase 1: Session Discovery
└─ Ref: workflow-plan-execute/phases/01-session-discovery.md (external)
└─ Output: sessionId (WFS-xxx)
Phase 2: Context Gathering
└─ Ref: workflow-plan-execute/phases/02-context-gathering.md (external)
├─ Tasks attached: Analyze structure → Identify integration → Generate package
└─ Output: contextPath + conflict_risk
Phase 3: Test Coverage Analysis ← ATTACHED (3 tasks)
└─ Ref: phases/01-test-context-gather.md
├─ Phase 3.1: Detect test framework
├─ Phase 3.2: Analyze existing test coverage
└─ Phase 3.3: Identify coverage gaps
└─ Output: test-context-package.json ← COLLAPSED
Phase 4: Conflict Resolution (conditional)
└─ Decision (conflict_risk check):
├─ conflict_risk ≥ medium → Inline conflict resolution (within Phase 2)
│ ├─ Tasks attached: Detect conflicts → Present to user → Apply strategies
│ └─ Output: Modified brainstorm artifacts ← COLLAPSED
└─ conflict_risk < medium → Skip to Phase 5
Phase 5: TDD Task Generation ← ATTACHED (3 tasks)
└─ Ref: phases/02-task-generate-tdd.md
├─ Phase 5.1: Discovery - analyze TDD requirements
├─ Phase 5.2: Planning - design Red-Green-Refactor cycles
└─ Phase 5.3: Output - generate IMPL tasks with internal TDD phases
└─ Output: IMPL-*.json, IMPL_PLAN.md ← COLLAPSED
Phase 6: TDD Structure Validation (inline)
└─ Internal validation + summary returned
└─ Recommend: plan-verify (external)
Return:
└─ Summary with recommended next steps输入解析:
└─ 将用户输入转换为TDD结构化格式(TDD:/GOAL/SCOPE/CONTEXT/TEST_FOCUS)
第1阶段:会话发现
└─ 参考:workflow-plan-execute/phases/01-session-discovery.md(外部)
└─ 输出:sessionId(WFS-xxx)
第2阶段:上下文收集
└─ 参考:workflow-plan-execute/phases/02-context-gathering.md(外部)
├─ 附加任务:分析结构 → 识别集成点 → 生成包
└─ 输出:contextPath + conflict_risk
第3阶段:测试覆盖率分析 ← 已附加(3个任务)
└─ 参考:phases/01-test-context-gather.md
├─ 第3.1阶段:检测测试框架
├─ 第3.2阶段:分析现有测试覆盖率
└─ 第3.3阶段:识别覆盖率缺口
└─ 输出:test-context-package.json ← 已折叠
第4阶段:冲突解决(条件执行)
└─ 决策(检查conflict_risk):
├─ conflict_risk ≥ medium → 内联冲突解决(在第2阶段内)
│ ├─ 附加任务:检测冲突 → 呈现给用户 → 应用解决方案
│ └─ 输出:修改后的头脑风暴产物 ← 已折叠
└─ conflict_risk < medium → 跳至第5阶段
第5阶段:TDD任务生成 ← 已附加(3个任务)
└─ 参考:phases/02-task-generate-tdd.md
├─ 第5.1阶段:发现 - 分析TDD需求
├─ 第5.2阶段:规划 - 设计红-绿-重构周期
└─ 第5.3阶段:输出 - 生成包含内部TDD阶段的IMPL任务
└─ 输出:IMPL-*.json, IMPL_PLAN.md ← 已折叠
第6阶段:TDD结构验证(内联)
└─ 执行内部验证并返回摘要
└─ 推荐:plan-verify(外部)
返回:
└─ 包含推荐后续步骤的摘要Phase Reference Documents
阶段参考文档
Local phases (read on-demand when phase executes):
| Phase | Document | Purpose |
|---|---|---|
| Phase 3 | phases/01-test-context-gather.md | Test coverage context gathering via test-context-search-agent |
| Phase 5 | phases/02-task-generate-tdd.md | TDD task JSON generation via action-planning-agent |
External phases (from workflow-plan-execute skill):
| Phase | Document | Purpose |
|---|---|---|
| Phase 1 | workflow-plan-execute/phases/01-session-discovery.md | Session creation/discovery |
| Phase 2 | workflow-plan-execute/phases/02-context-gathering.md | Project context collection + inline conflict resolution |
Post-execution verification:
| Phase | Document | Purpose |
|---|---|---|
| TDD Verify | phases/03-tdd-verify.md | TDD compliance verification with quality gate |
| Coverage Analysis | phases/04-tdd-coverage-analysis.md | Test coverage and cycle analysis (called by TDD Verify) |
本地阶段(阶段执行时按需读取):
| 阶段 | 文档 | 用途 |
|---|---|---|
| 第3阶段 | phases/01-test-context-gather.md | 通过test-context-search-agent收集测试覆盖率上下文 |
| 第5阶段 | phases/02-task-generate-tdd.md | 通过action-planning-agent生成TDD任务JSON |
外部阶段(来自workflow-plan-execute skill):
| 阶段 | 文档 | 用途 |
|---|---|---|
| 第1阶段 | workflow-plan-execute/phases/01-session-discovery.md | 会话创建/发现 |
| 第2阶段 | workflow-plan-execute/phases/02-context-gathering.md | 项目上下文收集 + 内联冲突解决 |
执行后验证:
| 阶段 | 文档 | 用途 |
|---|---|---|
| TDD验证 | phases/03-tdd-verify.md | 带有质量门的TDD合规验证 |
| 覆盖率分析 | phases/04-tdd-coverage-analysis.md | 测试覆盖率和周期分析(由TDD验证调用) |
6-Phase Execution
6阶段执行
Phase 1: Session Discovery
第1阶段:会话发现
Step 1.1: Execute - Session discovery and initialization
Read and execute: with
workflow-plan-execute/phases/01-session-discovery.md--type tdd --auto "TDD: [structured-description]"TDD Structured Format:
TDD: [Feature Name]
GOAL: [Objective]
SCOPE: [Included/excluded]
CONTEXT: [Background]
TEST_FOCUS: [Test scenarios]Parse: Extract sessionId
TodoWrite: Mark phase 1 completed, phase 2 in_progress
After Phase 1: Return to user showing Phase 1 results, then auto-continue to Phase 2
步骤1.1:执行 - 会话发现与初始化
读取并执行:,参数为
workflow-plan-execute/phases/01-session-discovery.md--type tdd --auto "TDD: [structured-description]"TDD结构化格式:
TDD: [Feature Name]
GOAL: [Objective]
SCOPE: [Included/excluded]
CONTEXT: [Background]
TEST_FOCUS: [Test scenarios]解析:提取sessionId
TodoWrite:标记第1阶段已完成,第2阶段进行中
第1阶段后:向用户返回第1阶段结果,然后自动续行至第2阶段
Phase 2: Context Gathering
第2阶段:上下文收集
Step 2.1: Execute - Context gathering and analysis
Read and execute: with
workflow-plan-execute/phases/02-context-gathering.md--session [sessionId] "TDD: [structured-description]"Use Same Structured Description: Pass the same structured format from Phase 1
Input: from Phase 1
sessionIdParse Output:
- Extract: context-package.json path (store as )
contextPath - Typical pattern:
{projectRoot}/.workflow/active/[sessionId]/.process/context-package.json
Validation:
- Context package path extracted
- File exists and is valid JSON
TodoWrite: Mark phase 2 completed, phase 3 in_progress
After Phase 2: Return to user showing Phase 2 results, then auto-continue to Phase 3
步骤2.1:执行 - 上下文收集与分析
读取并执行:,参数为
workflow-plan-execute/phases/02-context-gathering.md--session [sessionId] "TDD: [structured-description]"使用相同的结构化描述:传递与第1阶段相同的结构化格式内容
输入:来自第1阶段的
sessionId解析输出:
- 提取:context-package.json路径(存储为)
contextPath - 典型路径:
{projectRoot}/.workflow/active/[sessionId]/.process/context-package.json
验证:
- 已提取上下文包路径
- 文件存在且为有效JSON
TodoWrite:标记第2阶段已完成,第3阶段进行中
第2阶段后:向用户返回第2阶段结果,然后自动续行至第3阶段
Phase 3: Test Coverage Analysis
第3阶段:测试覆盖率分析
Step 3.1: Execute - Test coverage analysis and framework detection
Read and execute: with
phases/01-test-context-gather.md--session [sessionId]Purpose: Analyze existing codebase for:
- Existing test patterns and conventions
- Current test coverage
- Related components and integration points
- Test framework detection
Parse: Extract testContextPath ()
{projectRoot}/.workflow/active/[sessionId]/.process/test-context-package.jsonTodoWrite Update (Phase 3 - tasks attached):
json
[
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
{"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
{"content": "Phase 3: Test Coverage Analysis", "status": "in_progress", "activeForm": "Executing test coverage analysis"},
{"content": " → Detect test framework and conventions", "status": "in_progress", "activeForm": "Detecting test framework"},
{"content": " → Analyze existing test coverage", "status": "pending", "activeForm": "Analyzing test coverage"},
{"content": " → Identify coverage gaps", "status": "pending", "activeForm": "Identifying coverage gaps"},
{"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
{"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
]Note: Skill execute attaches test-context-gather's 3 tasks. Orchestrator executes these tasks.
Next Action: Tasks attached → Execute Phase 3.1-3.3 sequentially
TodoWrite Update (Phase 3 completed - tasks collapsed):
json
[
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
{"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
{"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
{"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
{"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
]After Phase 3: Return to user showing test coverage results, then auto-continue to Phase 4/5
步骤3.1:执行 - 测试覆盖率分析与框架检测
读取并执行:,参数为
phases/01-test-context-gather.md--session [sessionId]目的:分析现有代码库的以下内容:
- 现有测试模式与约定
- 当前测试覆盖率
- 相关组件与集成点
- 测试框架检测
解析:提取testContextPath()
{projectRoot}/.workflow/active/[sessionId]/.process/test-context-package.jsonTodoWrite更新(第3阶段 - 任务已附加):
json
[
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
{"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
{"content": "Phase 3: Test Coverage Analysis", "status": "in_progress", "activeForm": "Executing test coverage analysis"},
{"content": " → Detect test framework and conventions", "status": "in_progress", "activeForm": "Detecting test framework"},
{"content": " → Analyze existing test coverage", "status": "pending", "activeForm": "Analyzing test coverage"},
{"content": " → Identify coverage gaps", "status": "pending", "activeForm": "Identifying coverage gaps"},
{"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
{"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
]注意:Skill执行时会附加test-context-gather的3个任务。编排器执行这些任务。
下一步操作:任务已附加 → 依次执行第3.1-3.3阶段
TodoWrite更新(第3阶段完成 - 任务已折叠):
json
[
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
{"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
{"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
{"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
{"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
]第3阶段后:向用户返回测试覆盖率结果,然后自动续行至第4/5阶段
Phase 4: Conflict Resolution (Optional)
第4阶段:冲突解决(可选)
Trigger: Only execute when context-package.json indicates conflict_risk is "medium" or "high"
Step 4.1: Execute - Conflict detection and resolution
Conflict resolution is handled inline within Phase 2 (context-gathering). When conflict_risk >= medium, Phase 2 automatically performs detection and resolution.
Input:
- sessionId from Phase 1
- contextPath from Phase 2
- conflict_risk from context-package.json
Parse Output:
- Extract: Execution status (success/skipped/failed)
- Verify: conflict-resolution.json file path (if executed)
Skip Behavior:
- If conflict_risk is "none" or "low", skip directly to Phase 5
- Display: "No significant conflicts detected, proceeding to TDD task generation"
TodoWrite Update (Phase 4 - tasks attached, if conflict_risk >= medium):
json
[
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
{"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
{"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
{"content": "Phase 4: Conflict Resolution", "status": "in_progress", "activeForm": "Executing conflict resolution"},
{"content": " → Detect conflicts with CLI analysis", "status": "in_progress", "activeForm": "Detecting conflicts"},
{"content": " → Log and analyze detected conflicts", "status": "pending", "activeForm": "Analyzing conflicts"},
{"content": " → Apply resolution strategies", "status": "pending", "activeForm": "Applying resolution strategies"},
{"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
{"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
]TodoWrite Update (Phase 4 completed - tasks collapsed):
json
[
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
{"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
{"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
{"content": "Phase 4: Conflict Resolution", "status": "completed", "activeForm": "Executing conflict resolution"},
{"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
{"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
]After Phase 4: Return to user showing conflict resolution results, then auto-continue to Phase 5
Memory State Check:
-
Evaluate current context window usage and memory state
-
If memory usage is high (>110K tokens or approaching context limits):Step 4.5: Execute - Memory compaction (external skill: compact)
- This optimizes memory before proceeding to Phase 5
-
Memory compaction is particularly important after analysis phase which may generate extensive documentation
触发条件:仅当context-package.json中conflict_risk为"medium"或"high"时执行
步骤4.1:执行 - 冲突检测与解决
冲突解决在第2阶段(上下文收集)内联处理。当conflict_risk >= medium时,第2阶段自动执行检测与解决。
输入:
- 来自第1阶段的sessionId
- 来自第2阶段的contextPath
- 来自context-package.json的conflict_risk
解析输出:
- 提取:执行状态(成功/已跳过/失败)
- 验证:conflict-resolution.json文件路径(若已执行)
跳过行为:
- 若conflict_risk为"none"或"low",直接跳至第5阶段
- 显示:"未检测到重大冲突,继续执行TDD任务生成"
TodoWrite更新(第4阶段 - 任务已附加,若conflict_risk >= medium):
json
[
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
{"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
{"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
{"content": "Phase 4: Conflict Resolution", "status": "in_progress", "activeForm": "Executing conflict resolution"},
{"content": " → Detect conflicts with CLI analysis", "status": "in_progress", "activeForm": "Detecting conflicts"},
{"content": " → Log and analyze detected conflicts", "status": "pending", "activeForm": "Analyzing conflicts"},
{"content": " → Apply resolution strategies", "status": "pending", "activeForm": "Applying resolution strategies"},
{"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
{"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
]TodoWrite更新(第4阶段完成 - 任务已折叠):
json
[
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
{"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
{"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
{"content": "Phase 4: Conflict Resolution", "status": "completed", "activeForm": "Executing conflict resolution"},
{"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
{"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
]第4阶段后:向用户返回冲突解决结果,然后自动续行至第5阶段
内存状态检查:
-
评估当前上下文窗口使用情况与内存状态
-
若内存使用率过高(>110K tokens或接近上下文限制):步骤4.5:执行 - 内存压缩(外部skill: compact)
- 此操作会在进入第5阶段前优化内存
-
分析阶段可能生成大量文档,因此内存压缩尤为重要
Phase 5: TDD Task Generation
第5阶段:TDD任务生成
Step 5.1: Execute - TDD task generation via action-planning-agent with Phase 0 user configuration
Read and execute: with
phases/02-task-generate-tdd.md--session [sessionId]Note: Phase 0 now includes:
- Supplementary materials collection (file paths or inline content)
- Execution method preference (Agent/Hybrid/CLI)
- CLI tool preference (Codex/Gemini/Qwen/Auto)
- These preferences are passed to agent for task generation
Parse: Extract feature count, task count, CLI execution IDs assigned
Validate:
- IMPL_PLAN.md exists (unified plan with TDD Implementation Tasks section)
- IMPL-*.json files exist (one per feature, or container + subtasks for complex features)
- TODO_LIST.md exists with internal TDD phase indicators
- Each IMPL task includes:
meta.tdd_workflow: truemeta.cli_execution_id: {session_id}-{task_id}meta.cli_execution: { "strategy": "new|resume|fork|merge_fork", ... }- with exactly 3 steps (red/green/refactor)
flow_control.implementation_approach - Green phase includes test-fix-cycle configuration
- : absolute or clear relative paths
context.focus_paths - : includes exploration integration_points analysis
flow_control.pre_analysis
- IMPL_PLAN.md contains workflow_type: "tdd" in frontmatter
- Task count <=18 (compliance with hard limit)
Red Flag Detection (Non-Blocking Warnings):
- Task count >18:
Warning: Task count exceeds hard limit - request re-scope - Missing cli_execution_id:
Warning: Task lacks CLI execution ID for resume support - Missing test-fix-cycle:
Warning: Green phase lacks auto-revert configuration - Generic task names:
Warning: Vague task names suggest unclear TDD cycles - Missing focus_paths:
Warning: Task lacks clear file scope for implementation
Action: Log warnings to (non-blocking)
{projectRoot}/.workflow/active/[sessionId]/.process/tdd-warnings.logTodoWrite Update (Phase 5 - tasks attached):
json
[
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
{"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
{"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
{"content": "Phase 5: TDD Task Generation", "status": "in_progress", "activeForm": "Executing TDD task generation"},
{"content": " → Discovery - analyze TDD requirements", "status": "in_progress", "activeForm": "Analyzing TDD requirements"},
{"content": " → Planning - design Red-Green-Refactor cycles", "status": "pending", "activeForm": "Designing TDD cycles"},
{"content": " → Output - generate IMPL tasks with internal TDD phases", "status": "pending", "activeForm": "Generating TDD tasks"},
{"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
]TodoWrite Update (Phase 5 completed - tasks collapsed):
json
[
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
{"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
{"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
{"content": "Phase 5: TDD Task Generation", "status": "completed", "activeForm": "Executing TDD task generation"},
{"content": "Phase 6: TDD Structure Validation", "status": "in_progress", "activeForm": "Validating TDD structure"}
]步骤5.1:执行 - 通过action-planning-agent结合第0阶段用户配置生成TDD任务
读取并执行:,参数为
phases/02-task-generate-tdd.md--session [sessionId]注意:第0阶段现在包含:
- 补充材料收集(文件路径或内联内容)
- 执行方式偏好(Agent/Hybrid/CLI)
- CLI工具偏好(Codex/Gemini/Qwen/Auto)
- 这些偏好会传递给代理用于任务生成
解析:提取功能数量、任务数量、已分配的CLI执行ID
验证:
- IMPL_PLAN.md存在(包含TDD实现任务章节的统一计划)
- IMPL-*.json文件存在(每个功能对应一个,复杂功能包含容器+子任务)
- TODO_LIST.md存在且包含内部TDD阶段标识
- 每个IMPL任务包含:
meta.tdd_workflow: truemeta.cli_execution_id: {session_id}-{task_id}meta.cli_execution: { "strategy": "new|resume|fork|merge_fork", ... }- 包含恰好3个步骤(红/绿/重构)
flow_control.implementation_approach - 绿阶段包含测试修复周期配置
- : 绝对路径或清晰的相对路径
context.focus_paths - : 包含探索性集成点分析
flow_control.pre_analysis
- IMPL_PLAN.md的前置元数据中包含workflow_type: "tdd"
- 任务数量<=18(符合硬限制)
危险信号检测(非阻塞警告):
- 任务数量>18:
Warning: Task count exceeds hard limit - request re-scope - 缺少cli_execution_id:
Warning: Task lacks CLI execution ID for resume support - 缺少测试修复周期:
Warning: Green phase lacks auto-revert configuration - 通用任务名称:
Warning: Vague task names suggest unclear TDD cycles - 缺少focus_paths:
Warning: Task lacks clear file scope for implementation
操作:将警告日志记录到(非阻塞)
{projectRoot}/.workflow/active/[sessionId]/.process/tdd-warnings.logTodoWrite更新(第5阶段 - 任务已附加):
json
[
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
{"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
{"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
{"content": "Phase 5: TDD Task Generation", "status": "in_progress", "activeForm": "Executing TDD task generation"},
{"content": " → Discovery - analyze TDD requirements", "status": "in_progress", "activeForm": "Analyzing TDD requirements"},
{"content": " → Planning - design Red-Green-Refactor cycles", "status": "pending", "activeForm": "Designing TDD cycles"},
{"content": " → Output - generate IMPL tasks with internal TDD phases", "status": "pending", "activeForm": "Generating TDD tasks"},
{"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
]TodoWrite更新(第5阶段完成 - 任务已折叠):
json
[
{"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
{"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
{"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
{"content": "Phase 5: TDD Task Generation", "status": "completed", "activeForm": "Executing TDD task generation"},
{"content": "Phase 6: TDD Structure Validation", "status": "in_progress", "activeForm": "Validating TDD structure"}
]Phase 6: TDD Structure Validation & Action Plan Verification (RECOMMENDED)
第6阶段:TDD结构验证与行动计划验证(推荐)
Internal validation first, then recommend external verification
Internal Validation:
- Each task contains complete TDD workflow (Red-Green-Refactor internally)
- Task structure validation:
- in all IMPL tasks
meta.tdd_workflow: true - present (format: {session_id}-{task_id})
meta.cli_execution_id - strategy assigned (new/resume/fork/merge_fork)
meta.cli_execution - has exactly 3 steps
flow_control.implementation_approach - Each step has correct : "red", "green", "refactor"
tdd_phase - are absolute or clear relative paths
context.focus_paths - includes exploration integration analysis
flow_control.pre_analysis
- Dependency validation:
- Sequential features: IMPL-N depends_on ["IMPL-(N-1)"] if needed
- Complex features: IMPL-N.M depends_on ["IMPL-N.(M-1)"] for subtasks
- CLI execution strategies correctly assigned based on dependency graph
- Agent assignment: All IMPL tasks use @code-developer
- Test-fix cycle: Green phase step includes test-fix-cycle logic with max_iterations
- Task count: Total tasks <=18 (simple + subtasks hard limit)
- User configuration:
- Execution method choice reflected in task structure
- CLI tool preference documented in implementation guidance (if CLI selected)
Red Flag Checklist (from TDD best practices):
- No tasks skip Red phase (exists in step 1)
tdd_phase: "red" - Test files referenced in Red phase (explicit paths, not placeholders)
- Green phase has test-fix-cycle with configured
max_iterations - Refactor phase has clear completion criteria
Non-Compliance Warning Format:
Warning TDD Red Flag: [issue description]
Task: [IMPL-N]
Recommendation: [action to fix]Evidence Gathering (Before Completion Claims):
bash
undefined先执行内部验证,再推荐外部验证
内部验证:
- 每个任务包含完整的TDD工作流(内部红-绿-重构)
- 任务结构验证:
- 所有IMPL任务中
meta.tdd_workflow: true - 存在(格式: {session_id}-{task_id})
meta.cli_execution_id - 已分配策略(new/resume/fork/merge_fork)
meta.cli_execution - 包含恰好3个步骤
flow_control.implementation_approach - 每个步骤的正确:"red"、"green"、"refactor"
tdd_phase - 为绝对路径或清晰的相对路径
context.focus_paths - 包含探索性集成分析
flow_control.pre_analysis
- 所有IMPL任务中
- 依赖验证:
- 顺序功能:若需要,IMPL-N depends_on ["IMPL-(N-1)"]
- 复杂功能:IMPL-N.M depends_on ["IMPL-N.(M-1)"](子任务)
- 根据依赖图正确分配CLI执行策略
- 代理分配:所有IMPL任务使用@code-developer
- 测试修复周期:绿阶段步骤包含带有max_iterations的测试修复周期逻辑
- 任务数量:总任务数<=18(简单任务+子任务硬限制)
- 用户配置:
- 任务结构反映执行方式选择
- 若选择CLI,实现指南中记录了CLI工具偏好
危险信号检查表(来自TDD最佳实践):
- 无任务跳过红阶段(步骤1中存在)
tdd_phase: "red" - 红阶段引用了测试文件(明确路径,而非占位符)
- 绿阶段带有配置了的测试修复周期
max_iterations - 重构阶段有清晰的完成标准
不合规警告格式:
Warning TDD Red Flag: [issue description]
Task: [IMPL-N]
Recommendation: [action to fix]证据收集(完成声明前):
bash
undefinedVerify session artifacts exist
验证会话产物存在
ls -la ${projectRoot}/.workflow/active/[sessionId]/{IMPL_PLAN.md,TODO_LIST.md}
ls -la ${projectRoot}/.workflow/active/[sessionId]/.task/IMPL-*.json
ls -la ${projectRoot}/.workflow/active/[sessionId]/{IMPL_PLAN.md,TODO_LIST.md}
ls -la ${projectRoot}/.workflow/active/[sessionId]/.task/IMPL-*.json
Count generated artifacts
统计生成的产物数量
echo "IMPL tasks: $(ls ${projectRoot}/.workflow/active/[sessionId]/.task/IMPL-*.json 2>/dev/null | wc -l)"
echo "IMPL tasks: $(ls ${projectRoot}/.workflow/active/[sessionId]/.task/IMPL-*.json 2>/dev/null | wc -l)"
Sample task structure verification (first task)
验证任务结构示例(第一个任务)
jq '{id, tdd: .meta.tdd_workflow, cli_id: .meta.cli_execution_id, phases: [.flow_control.implementation_approach[].tdd_phase]}'
"$(ls ${projectRoot}/.workflow/active/[sessionId]/.task/IMPL-*.json | head -1)"
"$(ls ${projectRoot}/.workflow/active/[sessionId]/.task/IMPL-*.json | head -1)"
**Evidence Required Before Summary**:
| Evidence Type | Verification Method | Pass Criteria |
|---------------|---------------------|---------------|
| File existence | `ls -la` artifacts | All files present |
| Task count | Count IMPL-*.json | Count matches claims (<=18) |
| TDD structure | jq sample extraction | Shows red/green/refactor + cli_execution_id |
| CLI execution IDs | jq extraction | All tasks have cli_execution_id assigned |
| Warning log | Check tdd-warnings.log | Logged (may be empty) |
**Return Summary**:TDD Planning complete for session: [sessionId]
Features analyzed: [N]
Total tasks: [M] (1 task per simple feature + subtasks for complex features)
Task breakdown:
- Simple features: [K] tasks (IMPL-1 to IMPL-K)
- Complex features: [L] features with [P] subtasks
- Total task count: [M] (within 18-task hard limit)
Structure:
- IMPL-1: {Feature 1 Name} (Internal: Red → Green → Refactor)
- IMPL-2: {Feature 2 Name} (Internal: Red → Green → Refactor)
- IMPL-3: {Complex Feature} (Container)
- IMPL-3.1: {Sub-feature A} (Internal: Red → Green → Refactor)
- IMPL-3.2: {Sub-feature B} (Internal: Red → Green → Refactor) [...]
Plans generated:
- Unified Implementation Plan: {projectRoot}/.workflow/active/[sessionId]/IMPL_PLAN.md (includes TDD Implementation Tasks section with workflow_type: "tdd")
- Task List: {projectRoot}/.workflow/active/[sessionId]/TODO_LIST.md (with internal TDD phase indicators and CLI execution strategies)
- Task JSONs: {projectRoot}/.workflow/active/[sessionId]/.task/IMPL-*.json (with cli_execution_id and execution strategies for resume support)
TDD Configuration:
- Each task contains complete Red-Green-Refactor cycle
- Green phase includes test-fix cycle (max 3 iterations)
- Auto-revert on max iterations reached
- CLI execution strategies: new/resume/fork/merge_fork based on dependency graph
User Configuration Applied:
- Execution Method: [agent|hybrid|cli]
- CLI Tool Preference: [codex|gemini|qwen|auto]
- Supplementary Materials: [included|none]
- Task generation follows cli-tools-usage.md guidelines
ACTION REQUIRED: Before execution, ensure you understand WHY each Red phase test is expected to fail.
This is crucial for valid TDD - if you don't know why the test fails, you can't verify it tests the right thing.
Recommended Next Steps:
- plan-verify (external) --session [sessionId] # Verify TDD plan quality and dependencies
- workflow:execute (external) --session [sessionId] # Start TDD execution with CLI strategies
- phases/03-tdd-verify.md [sessionId] # Post-execution TDD compliance check
Quality Gate: Consider running plan-verify to validate TDD task structure, dependencies, and CLI execution strategies
undefinedjq '{id, tdd: .meta.tdd_workflow, cli_id: .meta.cli_execution_id, phases: [.flow_control.implementation_approach[].tdd_phase]}'
"$(ls ${projectRoot}/.workflow/active/[sessionId]/.task/IMPL-*.json | head -1)"
"$(ls ${projectRoot}/.workflow/active/[sessionId]/.task/IMPL-*.json | head -1)"
**摘要前所需证据**:
| 证据类型 | 验证方法 | 通过标准 |
|---------------|---------------------|---------------|
| 文件存在性 | `ls -la` 产物 | 所有文件均存在 |
| 任务数量 | 统计IMPL-*.json数量 | 数量与声明一致(<=18) |
| TDD结构 | jq提取示例 | 显示红/绿/重构 + cli_execution_id |
| CLI执行ID | jq提取 | 所有任务均有cli_execution_id |
| 警告日志 | 检查tdd-warnings.log | 已记录(可能为空) |
**返回摘要**:TDD Planning complete for session: [sessionId]
Features analyzed: [N]
Total tasks: [M] (1 task per simple feature + subtasks for complex features)
Task breakdown:
- Simple features: [K] tasks (IMPL-1 to IMPL-K)
- Complex features: [L] features with [P] subtasks
- Total task count: [M] (within 18-task hard limit)
Structure:
- IMPL-1: {Feature 1 Name} (Internal: Red → Green → Refactor)
- IMPL-2: {Feature 2 Name} (Internal: Red → Green → Refactor)
- IMPL-3: {Complex Feature} (Container)
- IMPL-3.1: {Sub-feature A} (Internal: Red → Green → Refactor)
- IMPL-3.2: {Sub-feature B} (Internal: Red → Green → Refactor) [...]
Plans generated:
- Unified Implementation Plan: {projectRoot}/.workflow/active/[sessionId]/IMPL_PLAN.md (includes TDD Implementation Tasks section with workflow_type: "tdd")
- Task List: {projectRoot}/.workflow/active/[sessionId]/TODO_LIST.md (with internal TDD phase indicators and CLI execution strategies)
- Task JSONs: {projectRoot}/.workflow/active/[sessionId]/.task/IMPL-*.json (with cli_execution_id and execution strategies for resume support)
TDD Configuration:
- Each task contains complete Red-Green-Refactor cycle
- Green phase includes test-fix cycle (max 3 iterations)
- Auto-revert on max iterations reached
- CLI execution strategies: new/resume/fork/merge_fork based on dependency graph
User Configuration Applied:
- Execution Method: [agent|hybrid|cli]
- CLI Tool Preference: [codex|gemini|qwen|auto]
- Supplementary Materials: [included|none]
- Task generation follows cli-tools-usage.md guidelines
ACTION REQUIRED: Before execution, ensure you understand WHY each Red phase test is expected to fail.
This is crucial for valid TDD - if you don't know why the test fails, you can't verify it tests the right thing.
Recommended Next Steps:
- plan-verify (external) --session [sessionId] # Verify TDD plan quality and dependencies
- workflow:execute (external) --session [sessionId] # Start TDD execution with CLI strategies
- phases/03-tdd-verify.md [sessionId] # Post-execution TDD compliance check
Quality Gate: Consider running plan-verify to validate TDD task structure, dependencies, and CLI execution strategies
undefinedInput Processing
输入处理
Convert user input to TDD-structured format:
Simple text → Add TDD context
Detailed text → Extract components with TEST_FOCUS
File/Issue → Read and structure with TDD
将用户输入转换为TDD结构化格式:
简单文本 → 添加TDD上下文
详细文本 → 提取包含TEST_FOCUS的组件
文件/问题 → 读取并按TDD格式结构化
Data Flow
数据流
User Input (task description)
↓
[Convert to TDD Structured Format]
↓ TDD Structured Description:
↓ TDD: [Feature Name]
↓ GOAL: [objective]
↓ SCOPE: [boundaries]
↓ CONTEXT: [background]
↓ TEST_FOCUS: [test scenarios]
↓
Phase 1: session:start --type tdd --auto "TDD: structured-description"
↓ Output: sessionId
↓
Phase 2: context-gather --session sessionId "TDD: structured-description"
↓ Output: contextPath + conflict_risk
↓
Phase 3: test-context-gather --session sessionId
↓ Output: testContextPath (test-context-package.json)
↓
Phase 4: conflict-resolution [AUTO-TRIGGERED if conflict_risk >= medium]
↓ Output: Modified brainstorm artifacts
↓ Skip if conflict_risk is none/low → proceed directly to Phase 5
↓
Phase 5: task-generate-tdd --session sessionId
↓ Output: IMPL_PLAN.md, task JSONs, TODO_LIST.md
↓
Phase 6: Internal validation + summary
↓
Return summary to userUser Input (task description)
↓
[Convert to TDD Structured Format]
↓ TDD Structured Description:
↓ TDD: [Feature Name]
↓ GOAL: [objective]
↓ SCOPE: [boundaries]
↓ CONTEXT: [background]
↓ TEST_FOCUS: [test scenarios]
↓
Phase 1: session:start --type tdd --auto "TDD: structured-description"
↓ Output: sessionId
↓
Phase 2: context-gather --session sessionId "TDD: structured-description"
↓ Output: contextPath + conflict_risk
↓
Phase 3: test-context-gather --session sessionId
↓ Output: testContextPath (test-context-package.json)
↓
Phase 4: conflict-resolution [AUTO-TRIGGERED if conflict_risk >= medium]
↓ Output: Modified brainstorm artifacts
↓ Skip if conflict_risk is none/low → proceed directly to Phase 5
↓
Phase 5: task-generate-tdd --session sessionId
↓ Output: IMPL_PLAN.md, task JSONs, TODO_LIST.md
↓
Phase 6: Internal validation + summary
↓
Return summary to userTodoWrite Pattern
TodoWrite模式
Core Concept: Dynamic task attachment and collapse for TDD workflow with test coverage analysis and Red-Green-Refactor cycle generation.
核心概念:针对TDD工作流的动态任务附加与折叠,包含测试覆盖率分析及红-绿-重构周期生成。
Key Principles
关键原则
-
Task Attachment (when Skill executed):
- Sub-command's internal tasks are attached to orchestrator's TodoWrite
- First attached task marked as , others as
in_progresspending - Orchestrator executes these attached tasks sequentially
-
Task Collapse (after sub-tasks complete):
- Remove detailed sub-tasks from TodoWrite
- Collapse to high-level phase summary
- Maintains clean orchestrator-level view
-
Continuous Execution:
- After collapse, automatically proceed to next pending phase
- No user intervention required between phases
- TodoWrite dynamically reflects current execution state
Lifecycle Summary: Initial pending tasks → Phase executed (tasks ATTACHED) → Sub-tasks executed sequentially → Phase completed (tasks COLLAPSED to summary) → Next phase begins (conditional Phase 4 if conflict_risk >= medium) → Repeat until all phases complete.
-
任务附加(Skill执行时):
- 子命令的内部任务附加到编排器的TodoWrite
- 第一个附加任务标记为,其余为
in_progresspending - 编排器按顺序执行这些附加任务
-
任务折叠(子任务完成后):
- 从TodoWrite中移除详细子任务
- 折叠为高级阶段摘要
- 保持编排器层面的清晰视图
-
持续执行:
- 折叠后,自动进入下一个待处理阶段
- 阶段间无需用户干预
- TodoWrite动态反映当前执行状态
生命周期摘要:初始待处理任务 → 执行阶段(任务已附加) → 按顺序执行子任务 → 阶段完成(任务折叠为摘要) → 进入下一阶段(若conflict_risk >= medium则执行条件性第4阶段) → 重复直至所有阶段完成。
TDD-Specific Features
TDD特定功能
- Phase 3: Test coverage analysis detects existing patterns and gaps
- Phase 5: Generated IMPL tasks contain internal Red-Green-Refactor cycles
- Conditional Phase 4: Conflict resolution only if conflict_risk >= medium
Note: See individual Phase descriptions (Phase 3, 4, 5) for detailed TodoWrite Update examples with full JSON structures.
- 第3阶段:测试覆盖率分析检测现有模式与缺口
- 第5阶段:生成的IMPL任务包含内部红-绿-重构周期
- 条件性第4阶段:仅当conflict_risk >= medium时执行冲突解决
注意:请查看各个阶段描述(第3、4、5阶段)获取带有完整JSON结构的详细TodoWrite更新示例。
Execution Flow Diagram
执行流程图
TDD Workflow Orchestrator
│
├─ Phase 1: Session Discovery
│ └─ workflow-plan-execute/phases/01-session-discovery.md --auto
│ └─ Returns: sessionId
│
├─ Phase 2: Context Gathering
│ └─ workflow-plan-execute/phases/02-context-gathering.md
│ └─ Returns: context-package.json path
│
├─ Phase 3: Test Coverage Analysis ← ATTACHED (3 tasks)
│ └─ phases/01-test-context-gather.md
│ ├─ Phase 3.1: Detect test framework
│ ├─ Phase 3.2: Analyze existing test coverage
│ └─ Phase 3.3: Identify coverage gaps
│ └─ Returns: test-context-package.json ← COLLAPSED
│
├─ Phase 4: Conflict Resolution (conditional)
│ IF conflict_risk >= medium:
│ └─ Inline within Phase 2 context-gathering ← ATTACHED (3 tasks)
│ ├─ Phase 4.1: Detect conflicts with CLI
│ ├─ Phase 4.2: Log and analyze detected conflicts
│ └─ Phase 4.3: Apply resolution strategies
│ └─ Returns: conflict-resolution.json ← COLLAPSED
│ ELSE:
│ └─ Skip to Phase 5
│
├─ Phase 5: TDD Task Generation ← ATTACHED (3 tasks)
│ └─ phases/02-task-generate-tdd.md
│ ├─ Phase 5.1: Discovery - analyze TDD requirements
│ ├─ Phase 5.2: Planning - design Red-Green-Refactor cycles
│ └─ Phase 5.3: Output - generate IMPL tasks with internal TDD phases
│ └─ Returns: IMPL-*.json, IMPL_PLAN.md ← COLLAPSED
│ (Each IMPL task contains internal Red-Green-Refactor cycle)
│
└─ Phase 6: TDD Structure Validation
└─ Internal validation + summary returned
└─ Recommend: plan-verify (external)
Key Points:
• ← ATTACHED: Sub-tasks attached to orchestrator TodoWrite
• ← COLLAPSED: Sub-tasks executed and collapsed to phase summary
• TDD-specific: Each generated IMPL task contains complete Red-Green-Refactor cycleTDD Workflow Orchestrator
│
├─ Phase 1: Session Discovery
│ └─ workflow-plan-execute/phases/01-session-discovery.md --auto
│ └─ Returns: sessionId
│
├─ Phase 2: Context Gathering
│ └─ workflow-plan-execute/phases/02-context-gathering.md
│ └─ Returns: context-package.json path
│
├─ Phase 3: Test Coverage Analysis ← ATTACHED (3 tasks)
│ └─ phases/01-test-context-gather.md
│ ├─ Phase 3.1: Detect test framework
│ ├─ Phase 3.2: Analyze existing test coverage
│ └─ Phase 3.3: Identify coverage gaps
│ └─ Returns: test-context-package.json ← COLLAPSED
│
├─ Phase 4: Conflict Resolution (conditional)
│ IF conflict_risk >= medium:
│ └─ Inline within Phase 2 context-gathering ← ATTACHED (3 tasks)
│ ├─ Phase 4.1: Detect conflicts with CLI
│ ├─ Phase 4.2: Log and analyze detected conflicts
│ └─ Phase 4.3: Apply resolution strategies
│ └─ Returns: conflict-resolution.json ← COLLAPSED
│ ELSE:
│ └─ Skip to Phase 5
│
├─ Phase 5: TDD Task Generation ← ATTACHED (3 tasks)
│ └─ phases/02-task-generate-tdd.md
│ ├─ Phase 5.1: Discovery - analyze TDD requirements
│ ├─ Phase 5.2: Planning - design Red-Green-Refactor cycles
│ └─ Phase 5.3: Output - generate IMPL tasks with internal TDD phases
│ └─ Returns: IMPL-*.json, IMPL_PLAN.md ← COLLAPSED
│ (Each IMPL task contains internal Red-Green-Refactor cycle)
│
└─ Phase 6: TDD Structure Validation
└─ Internal validation + summary returned
└─ Recommend: plan-verify (external)
Key Points:
• ← ATTACHED: Sub-tasks attached to orchestrator TodoWrite
• ← COLLAPSED: Sub-tasks executed and collapsed to phase summary
• TDD-specific: Each generated IMPL task contains complete Red-Green-Refactor cycleError Handling
错误处理
- Parsing failure: Retry once, then report
- Validation failure: Report missing/invalid data
- Command failure: Keep phase in_progress, report error
- TDD validation failure: Report incomplete chains or wrong dependencies
- Subagent timeout: Retry wait or send_input to prompt completion, then close_agent
- 解析失败:重试一次,然后报告
- 验证失败:报告缺失/无效数据
- 命令失败:保持阶段为in_progress,报告错误
- TDD验证失败:报告不完整的链或错误的依赖
- 子代理超时:重试wait或发送send_input提示完成,然后close_agent
TDD Warning Patterns
TDD警告模式
| Pattern | Warning Message | Recommended Action |
|---|---|---|
| Task count >10 | High task count detected | Consider splitting into multiple sessions |
| Missing test-fix-cycle | Green phase lacks auto-revert | Add |
| Red phase missing test path | Test file path not specified | Add explicit test file paths |
| Generic task names | Vague names like "Add feature" | Use specific behavior descriptions |
| No refactor criteria | Refactor phase lacks completion criteria | Define clear refactor scope |
| 模式 | 警告信息 | 推荐操作 |
|---|---|---|
| 任务数量>10 | 检测到任务数量过多 | 考虑拆分为多个会话 |
| 缺少测试修复周期 | 绿阶段缺少自动回滚 | 在任务配置中添加 |
| 红阶段缺少测试路径 | 未指定测试文件路径 | 添加明确的测试文件路径 |
| 通用任务名称 | 如"Add feature"之类的模糊名称 | 使用具体的行为描述 |
| 无重构标准 | 重构阶段缺少完成标准 | 定义清晰的重构范围 |
Non-Blocking Warning Policy
非阻塞警告策略
All warnings are advisory - they do not halt execution:
- Warnings logged to
.process/tdd-warnings.log - Summary displayed in Phase 6 output
- User decides whether to address before execution
所有警告均为建议性 - 不会终止执行:
- 警告记录到
.process/tdd-warnings.log - 在第6阶段输出中显示摘要
- 用户决定是否在执行前处理
Error Handling Quick Reference
错误处理快速参考
| Error Type | Detection | Recovery Action |
|---|---|---|
| Parsing failure | Empty/malformed output | Retry once, then report |
| Missing context-package | File read error | Re-run context-gather (workflow-plan-execute/phases/02-context-gathering.md) |
| Invalid task JSON | jq parse error | Report malformed file path |
| Task count exceeds 18 | Count validation >=19 | Request re-scope, split into multiple sessions |
| Missing cli_execution_id | All tasks lack ID | Regenerate tasks with phase 0 user config |
| Test-context missing | File not found | Re-run phases/01-test-context-gather.md |
| Phase timeout | No response | Retry phase, check CLI connectivity |
| CLI tool not available | Tool not in cli-tools.json | Fall back to alternative preferred tool |
| Subagent unresponsive | wait timed_out | send_input to prompt, or close_agent and spawn new |
| 错误类型 | 检测方式 | 恢复操作 |
|---|---|---|
| 解析失败 | 输出为空/格式错误 | 重试一次,然后报告 |
| 缺少context-package | 文件读取错误 | 重新运行context-gather(workflow-plan-execute/phases/02-context-gathering.md) |
| 无效任务JSON | jq解析错误 | 报告格式错误的文件路径 |
| 任务数量超过18 | 数量验证>=19 | 请求重新划定范围,拆分为多个会话 |
| 缺少cli_execution_id | 所有任务均无ID | 使用第0阶段用户配置重新生成任务 |
| 缺少测试上下文 | 文件未找到 | 重新运行phases/01-test-context-gather.md |
| 阶段超时 | 无响应 | 重试阶段,检查CLI连接性 |
| CLI工具不可用 | 工具不在cli-tools.json中 | 回退到替代首选工具 |
| 子代理无响应 | wait超时 | 发送send_input提示,或close_agent并生成新代理 |
Post-Execution: TDD Verification
执行后:TDD验证
After TDD tasks have been executed (via workflow:execute), run TDD compliance verification:
Read and execute: with
phases/03-tdd-verify.md--session [sessionId]This generates a comprehensive TDD_COMPLIANCE_REPORT.md with quality gate recommendation.
TDD任务执行完成后(通过workflow:execute),运行TDD合规验证:
读取并执行:,参数为
phases/03-tdd-verify.md--session [sessionId]此操作会生成包含质量门建议的全面TDD_COMPLIANCE_REPORT.md。
Related Skills
相关Skills
Prerequisite:
- None - TDD planning is self-contained (can optionally run brainstorm before)
Called by This Skill (6 phases):
- workflow-plan-execute/phases/01-session-discovery.md - Phase 1: Create or discover TDD workflow session
- workflow-plan-execute/phases/02-context-gathering.md - Phase 2: Gather project context and analyze codebase
- phases/01-test-context-gather.md - Phase 3: Analyze existing test patterns and coverage
- Inline conflict resolution within Phase 2 - Phase 4: Detect and resolve conflicts (conditional)
- compact (external skill) - Phase 4.5: Memory optimization (if context approaching limits)
- phases/02-task-generate-tdd.md - Phase 5: Generate TDD tasks
Follow-up:
- plan-verify (external) - Recommended: Verify TDD plan quality and structure before execution
- workflow:status (external) - Review TDD task breakdown
- workflow:execute (external) - Begin TDD implementation
- phases/03-tdd-verify.md - Post-execution: Verify TDD compliance and generate quality report
前置要求:
- 无 - TDD规划是自包含的(可选择在之前运行brainstorm)
本Skill调用的内容(6个阶段):
- workflow-plan-execute/phases/01-session-discovery.md - 第1阶段:创建或发现TDD工作流会话
- workflow-plan-execute/phases/02-context-gathering.md - 第2阶段:收集项目上下文并分析代码库
- phases/01-test-context-gather.md - 第3阶段:分析现有测试模式与覆盖率
- 第2阶段内联冲突解决 - 第4阶段:检测并解决冲突(条件执行)
- compact(外部skill) - 第4.5阶段:内存优化(若上下文接近限制)
- phases/02-task-generate-tdd.md - 第5阶段:生成TDD任务
后续操作:
- plan-verify(外部) - 推荐:执行前验证TDD计划质量与结构
- workflow:status(外部) - 查看TDD任务细分
- workflow:execute(外部) - 开始TDD实施
- phases/03-tdd-verify.md - 执行后:验证TDD合规性并生成质量报告
Next Steps Decision Table
下一步操作决策表
| Situation | Recommended Action | Purpose |
|---|---|---|
| First time planning | Run plan-verify (external) | Validate task structure before execution |
| Warnings in tdd-warnings.log | Review log, refine tasks | Address Red Flags before proceeding |
| High task count warning | Consider new session | Split into focused sub-sessions |
| Ready to implement | Run workflow:execute (external) | Begin TDD Red-Green-Refactor cycles |
| After implementation | Run phases/03-tdd-verify.md | Generate TDD compliance report |
| Need to review tasks | Run workflow:status (external) | Inspect current task breakdown |
| 情况 | 推荐操作 | 目的 |
|---|---|---|
| 首次规划 | 运行plan-verify(外部) | 执行前验证任务结构 |
| tdd-warnings.log中有警告 | 查看日志,优化任务 | 处理危险信号后再继续 |
| 任务数量过多警告 | 考虑新建会话 | 拆分为聚焦的子会话 |
| 准备实施 | 运行workflow:execute(外部) | 开始TDD红-绿-重构周期 |
| 实施完成后 | 运行phases/03-tdd-verify.md | 生成TDD合规报告 |
| 需要查看任务 | 运行workflow:status(外部) | 检查当前任务细分 |
TDD Workflow State Transitions
TDD工作流状态转换
workflow-tdd-plan (this skill)
↓
[Planning Complete] ──→ plan-verify (external, recommended)
↓
[Verified/Ready] ─────→ workflow:execute (external)
↓
[Implementation] ─────→ phases/03-tdd-verify.md (post-execution)
↓
[Quality Report] ─────→ Done or iterateworkflow-tdd-plan (this skill)
↓
[Planning Complete] ──→ plan-verify (external, recommended)
↓
[Verified/Ready] ─────→ workflow:execute (external)
↓
[Implementation] ─────→ phases/03-tdd-verify.md (post-execution)
↓
[Quality Report] ─────→ Done or iterate