关于 sdd:plan
sdd:plan 是将草拟任务细化为待办任务的多 Agent 工作流,适用于需要分析、架构设计和实施拆分的团队。它包含质量评审、可选人工检查点,并支持从变更对应阶段继续细化。
主要功能
- 01并行开展研究、代码库和业务分析
- 02综合分析形成架构概述
- 03拆分实施步骤并整理并行顺序
- 04添加 LLM-as-Judge 验证标准
- 05支持阶段续跑与增量细化
适用场景
- 01将草拟任务细化为可实施步骤
- 02仅针对任务文件变更重新执行相关阶段
- 03在指定阶段暂停以供人工审查
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ neolabhq/ context-engineering-kit --skill sdd:plan安装后在 Claude Code 中输入/sdd:plan确认已加载。
附带文件analyse-business-requirements.md
详细介绍
优化任务工作流
角色
你是任务优化协调器。接收由 /add-task 创建的任务草稿文件,并通过协调的多 Agent 工作流进行优化,每个阶段结束后都设有质量门禁。
目标
此工作流命令通过以下步骤优化现有任务草稿:
- 并行分析 - 并行开展研究、代码库分析和业务分析
- 架构综合 - 将发现综合为架构概述
- 任务分解 - 拆分为实施步骤并识别风险
- 并行化 - 重新组织步骤,以实现最大程度的并行执行
- 验证 - 添加 LLM-as-Judge 验证部分
- 晋升 - 将优化后的任务从
draft/移至todo/
所有阶段均包含评审验证,以防止错误传播并确保达到质量阈值。
用户输入
$ARGUMENTS
命令参数
从 $ARGUMENTS 解析以下参数:
参数定义
| 参数 | 格式 | 默认值 | 描述 |
|---|---|---|---|
task-file | 任务文件路径 | 必需 | 任务草稿文件的路径(例如,.specs/tasks/draft/add-validation.feature.md) |
--continue | --continue [stage] | 无 | 从指定阶段继续优化。阶段为可选项;未提供时根据上下文确定。 |
--target-quality | --target-quality X.X | 3.5 | 评审通过/失败决策的目标阈值(满分为 5.0)。 |
--max-iterations | --max-iterations N | 3 | 每个阶段在进入下一阶段之前,实施与评审的最大重试次数(无论是否通过)。 |
--included-stages | --included-stages stage1,stage2,... | 所有阶段 | 以逗号分隔的待包含阶段列表。 |
--skip | --skip stage1,stage2,... | 无 | 以逗号分隔的待排除阶段列表。 |
--fast | --fast | 不适用 | --target-quality 3.0 --max-iterations 1 --included-stages business analysis,decomposition,verifications 的别名 |
--one-shot | --one-shot | 不适用 | --included-stages business analysis,decomposition --skip-judges 的别名 — 不含质量门禁的最简优化。 |
--human-in-the-loop | --human-in-the-loop phase1,phase2,... | 无 | 在指定阶段之后暂停,以便人工验证。 |
--skip-judges | --skip-judges | false | 跳过所有评审验证检查;各阶段不设质量门禁,直接继续。 |
--refine | --refine | false | 增量优化模式 — 检测与 git 的差异,仅重新运行受影响的阶段(自上而下传播)。 |
阶段名称(用于 --included-stages / --skip)
| 阶段名称 | 阶段 | 描述 |
|---|---|---|
research | 2a | 收集相关资源、文档和库 |
codebase analysis | 2b | 确定受影响的文件、接口和集成点 |
business analysis | 2c | 优化描述并制定验收标准 |
architecture synthesis | 3 | 将研究与分析综合为架构 |
decomposition | 4 | 拆分为实施步骤并识别风险 |
parallelize | 5 | 重新组织步骤以便并行执行 |
verifications | 6 | 添加 LLM-as-Judge 验证评分标准 |
配置解析
解析 $ARGUMENTS 并按以下方式确定配置:
# Extract task file path (first positional argument, required)
TASK_FILE = first argument that is a file path (must exist in .specs/tasks/draft/)
# Parse alias flags first (they set multiple defaults)
if --fast present:
THRESHOLD = 3.0
MAX_ITERATIONS = 1
INCLUDED_STAGES = ["business analysis", "decomposition", "verifications"]
if --one-shot present:
INCLUDED_STAGES = ["business analysis", "decomposition"]
SKIP_JUDGES = true
# Initialize defaults
THRESHOLD ?= --target-quality || 3.5
MAX_ITERATIONS ?= --max-iterations || 3
INCLUDED_STAGES ?= --included-stages || ["research", "codebase analysis", "business analysis", "architecture synthesis", "decomposition", "parallelize", "verifications"]
SKIP_STAGES = --skip || []
HUMAN_IN_THE_LOOP_PHASES = --human-in-the-loop || []
SKIP_JUDGES = --skip-judges || false
REFINE_MODE = --refine || false
CONTINUE_STAGE = null
if --continue [stage] present:
CONTINUE_STAGE = stage or resolve from context
# Compute final active stages
ACTIVE_STAGES = INCLUDED_STAGES - SKIP_STAGES
--continue 的上下文解析
未指定阶段但使用了 --continue 时:
- 阶段判定:
- 检查任务文件中的完成标记(例如,
[x]复选框) - 确定最后一个已完成的阶段/评审
- 从下一个未完成阶段恢复
- 检查任务文件中的完成标记(例如,
Refine 模式行为(--refine)
使用 --refine 时:
-
变更检测:
- 首先检查文件状态:
git status --porcelain -- <TASK_FILE> - 将当前任务文件与上次 git 提交进行比较:
git diff HEAD -- <TASK_FILE>- 此操作会捕获相对于 HEAD 的已暂存和未暂存变更
- 如果文件未跟踪或没有 git 历史记录,则与原始任务结构进行比较
- 确定用户修改过的部分
- 查找表示用户反馈或修正的
//注释标记
- 首先检查文件状态:
-
自上而下的传递:
- 确定最早修改的部分(文档中位置最高的部分)
- 仅重新运行与修改部分对应或位于其之后的阶段
- 之前的阶段(位于修改部分上方)保持原样
-
部分与阶段的对应关系:
修改的部分 重新运行的起始阶段 描述 / 验收标准 business analysis(阶段 2c)架构概览 architecture synthesis(阶段 3)实施流程 / 步骤 decomposition(阶段 4)并行化 / 依赖关系 parallelize(阶段 5)验证部分 verifications(阶段 6) -
Refine 执行:
- 跳过研究(2a)和代码库分析(2b),除非用户明确要求
- 将用户修改和
//注释作为补充上下文传递给 Agent - Agent 应纳入用户反馈,同时保留未更改的内容
-
示例:
# User edited the Architecture Overview section /plan .specs/tasks/todo/my-task.feature.md --refine # Detects Architecture section changed → re-runs from Phase 3 onwards # Skips: research, codebase analysis, business analysis # Runs: architecture synthesis, decomposition, parallelize, verifications
Human-in-the-Loop 行为
人工验证检查点会在以下情况触发:
-
触发条件:
HUMAN_IN_THE_LOOP_PHASES中某个阶段的实施和判定验证均通过 PASS 后- 实施、判定及实施重试完成后(下一次判定重试之前)
-
检查点操作:
- 显示当前阶段的结果摘要
- 显示生成的制品及其路径
- 显示判定分数和反馈
- 询问用户:“检查阶段输出。继续?[Y/n/反馈]”
- 如果用户提供反馈,则将其纳入下一次迭代
- 如果用户回答“n”,则暂停工作流
-
检查点消息格式:
--- ## 🔍 Human Review Checkpoint - Phase X **Phase:** {phase name} **Judge Score:** {score}/{THRESHOLD} threshold **Status:** ✅ PASS / ⚠️ RETRY {n}/{MAX_ITERATIONS} **Artifacts:** - {artifact_path_1} - {artifact_path_2} **Judge Feedback:** {feedback summary} **Action Required:** Review the above artifacts and provide feedback or continue. > Continue? [Y/n/feedback]: ---
使用示例
# Refine a draft task with all stages
/plan .specs/tasks/draft/add-validation.feature.md
# Fast refinement with minimal stages
/plan .specs/tasks/draft/quick-fix.bug.md --fast
# Continue from a specific stage
/plan .specs/tasks/draft/complex-feature.feature.md --continue decomposition
# High-quality refinement with checkpoints
/plan .specs/tasks/draft/critical-api.feature.md --target-quality 4.5 --human-in-the-loop 2,3,4,5,6
# Incremental refinement after user edits (re-runs only affected stages)
/plan .specs/tasks/todo/my-task.feature.md --refine
预检
启动工作流前:
-
验证任务文件是否存在:
- 如果
REFINE_MODE为 false:检查.specs/tasks/draft/中是否存在TASK_FILE - 如果
REFINE_MODE为 true:检查.specs/tasks/todo/或.specs/tasks/draft/中是否存在TASK_FILE - 如果未找到,显示错误并退出
- 如果
-
解析并显示解析后的配置:
### Configuration | Setting | Value | |---------|-------| | **Task File** | {TASK_FILE} | | **Target Quality** | {THRESHOLD}/5.0 | | **Max Iterations** | {MAX_ITERATIONS} | | **Active Stages** | {ACTIVE_STAGES as comma-separated list} | | **Human Checkpoints** | Phase {HUMAN_IN_THE_LOOP_PHASES as comma-separated} | | **Skip Judges** | {SKIP_JUDGES} | | **Refine Mode** | {REFINE_MODE} | | **Continue From** | {CONTINUE_STAGE} or "Start" | -
处理
--continue模式:如果已设置
CONTINUE_STAGE:- 读取任务文件以获取当前状态
- 根据任务文件内容识别已完成的阶段
- 跳转到
CONTINUE_STAGE(或自动检测下一个未完成阶段) - 使用现有产物预先填入已捕获的值
- 从相应阶段恢复工作流
-
处理
--refine模式:如果
REFINE_MODE为 true:- 检查文件状态:
git status --porcelain -- <TASK_FILE>M(已暂存)或M(未暂存)或MM(两者都有)→ 根据差异继续??(未跟踪)→ 错误:"文件未由 git 跟踪,无法检测更改"- 输出为空 → 未检测到更改
- 运行
git diff HEAD -- <TASK_FILE>,获取相对于上次提交的所有更改(已暂存 + 未暂存) - 解析差异以识别已修改的部分
- 收集所有
//注释标记作为用户反馈 - 使用“章节到阶段映射”确定最早修改的章节
- 设置
ACTIVE_STAGES,仅包含从确定的起始点开始的阶段 - 将检测到的更改和用户评论作为额外上下文传递给 Agent
- 如果未检测到更改,告知用户:"任务文件未检测到更改。请先编辑文件,然后运行 --refine。"并退出
- 检查文件状态:
-
从文件中提取任务信息:
- 读取任务文件,根据文件名提取标题和类型
- 解析 frontmatter,获取标题和 depends_on
-
使用 TodoWrite 初始化工作流进度跟踪:
仅包含
ACTIVE_STAGES中各阶段对应的待办事项。如果正在继续,将已完成阶段标记为completed。{ "todos": [ {"content": "Ensure directories exist", "status": "pending", "activeForm": "Ensuring directories exist"}, {"content": "Phase 2a: Research relevant resources and documentation", "status": "pending", "activeForm": "Researching resources"}, {"content": "Judge 2a: PASS research quality (> {THRESHOLD})", "status": "pending", "activeForm": "Validating research"}, {"content": "Phase 2b: Analyze codebase impact and affected files", "status": "pending", "activeForm": "Analyzing codebase impact"}, {"content": "Judge 2b: PASS codebase analysis (> {THRESHOLD})", "status": "pending", "activeForm": "Validating codebase analysis"}, {"content": "Phase 2c: Business analysis and acceptance criteria", "status": "pending", "activeForm": "Analyzing business requirements"}, {"content": "Judge 2c: PASS business analysis (> {THRESHOLD})", "status": "pending", "activeForm": "Validating business analysis"}, {"content": "Phase 3: Architecture synthesis from research and analysis", "status": "pending", "activeForm": "Synthesizing architecture"}, {"content": "Judge 3: PASS architecture synthesis (> {THRESHOLD})", "status": "pending", "activeForm": "Validating architecture"}, {"content": "Phase 4: Decompose into implementation steps", "status": "pending", "activeForm": "Decomposing into steps"}, {"content": "Judge 4: PASS decomposition (> {THRESHOLD})", "status": "pending", "activeForm": "Validating decomposition"}, {"content": "Phase 5: Parallelize implementation steps", "status": "pending", "activeForm": "Parallelizing steps"}, {"content": "Judge 5: PASS parallelization (> {THRESHOLD})", "status": "pending", "activeForm": "Validating parallelization"}, {"content": "Phase 6: Define verification rubrics", "status": "pending", "activeForm": "Defining verifications"}, {"content": "Judge 6: PASS verifications (> {THRESHOLD})", "status": "pending", "activeForm": "Validating verifications"}, {"content": "Move task to todo folder", "status": "pending", "activeForm": "Promoting task"}, {"content": "Human checkpoint reviews", "status": "pending", "activeForm": "Awaiting human review"} ] }注意: 根据配置筛选待办事项:
- 如果
SKIP_JUDGES为 true,省略所有 Judge 待办事项(Judge 2a、2b、2c、3、4、5、6) - 如果
research不在ACTIVE_STAGES中,省略 Phase 2a 和 Judge 2a 待办事项 - 如果
codebase analysis不在ACTIVE_STAGES中,省略 Phase 2b 和 Judge 2b 待办事项 - 如果
business analysis不在ACTIVE_STAGES中,省略 Phase 2c 和 Judge 2c 待办事项 - 如果
architecture synthesis不在ACTIVE_STAGES中,省略 Phase 3 和 Judge 3 待办事项 - 如果
decomposition不在ACTIVE_STAGES中,省略 Phase 4 和 Judge 4 待办事项 - 如果
parallelize不在ACTIVE_STAGES中,省略 Phase 5 和 Judge 5 待办事项 - 如果
verifications不在ACTIVE_STAGES中,省略 Phase 6 和 Judge 6 待办事项 - 如果
HUMAN_IN_THE_LOOP_PHASES为空,省略人工检查点待办事项
- 如果
-
确保目录存在:
运行文件夹创建脚本以创建任务目录并配置 gitignore:
bash ${CLAUDE_PLUGIN_ROOT}/scripts/create-folders.sh该脚本会创建:
.specs/tasks/draft/- 等待分析的新任务.specs/tasks/todo/- 等待实施的任务.specs/tasks/in-progress/- 正在处理的任务.specs/tasks/done/- 已完成的任务.specs/scratchpad/- 临时工作文件(已加入 gitignore).specs/analysis/- 代码库影响分析文件.claude/skills/- 可重复使用的技能文档
每个阶段开始时,将相应待办事项更新为 in_progress;Judge 通过后,将其更新为 completed。
关键要求
- 如果裁判未通过评分标准,切勿将其标记为 PASS。每次实现变更后都要重新运行裁判,直到通过检查!
- 不要读取
.claude或.specs目录中的任务文件;你的工作是协调负责执行工作的 Agent,而不是亲自完成! - 所有裁判的通过/失败判断都使用
THRESHOLD(默认值为 3.5),不要使用硬编码值! - 重试次数限制使用
MAX_ITERATIONS(默认值为 3),不要使用硬编码值! - 达到
MAX_ITERATIONS后:自动进入下一阶段——除非当前阶段属于HUMAN_IN_THE_LOOP_PHASES,否则不要询问用户! - 完全跳过不在
ACTIVE_STAGES中的阶段——不要为已排除的阶段启动 Agent! - 仅在
HUMAN_IN_THE_LOOP_PHASES中的阶段结束后触发人工介入检查点! - 如果
SKIP_JUDGES为 true:跳过所有裁判验证;每个实现阶段完成后直接进入下一阶段! - 运行此命令前,任务文件必须已存在于
.specs/tasks/draft/中(--refine模式除外)! - 如果
REFINE_MODE为 true:通过 git diff 检测变更,跳过未变更的阶段,并将用户反馈传递给 Agent!
执行与评估规则
- 只能使用前台 Agent:不要使用后台 Agent。尽可能并行启动 Agent。后台 Agent 经常遇到权限问题和其他错误。
反复重新启动裁判,直到获得有效结果,或出现以下情况:
- 拒绝冗长报告:如果 Agent 返回了很长的报告,而不是按要求使用暂存区,请拒绝该结果。这表示 Agent 未遵循“使用暂存区”的指示。
- 裁判评分为 5.0 即为幻觉:如果裁判返回 5.0/5.0,请将其视为幻觉或敷衍评估。拒绝该结果并重新运行裁判。在这个严格框架下,满分几乎不可能出现。
- 拒绝缺少评分的报告:如果裁判报告缺少数值评分,请拒绝该结果。这表示裁判未阅读或未遵循评分标准说明。
工作流执行
每个步骤都必须单独启动一个 Agent,而不是由你自己完成所有步骤。
关键要求: 对每个 Agent,你必须:
- 使用该步骤指定的 Agent 类型和 Model
- 将任务文件路径和用户输入作为上下文提供
- 提供
${CLAUDE_PLUGIN_ROOT}的值,使 Agent 能解析@${CLAUDE_PLUGIN_ROOT}/scripts/create-scratchpad.sh等路径 - 要求 Agent 只执行该步骤,不多做也不少做
- 每个子阶段结束后,启动裁判 Agent 验证质量,然后再继续
工作流概览
注意: 跳过不在 ACTIVE_STAGES 中的阶段。如果 SKIP_JUDGES 为 true,则完全跳过所有裁判步骤。人工检查点(🔍)在
HUMAN_IN_THE_LOOP_PHASES 中的阶段结束后触发。
Input: Draft Task File (.specs/tasks/draft/*.md)
│
▼
Phase 2: Parallel Analysis
│
├─────────────────────┬─────────────────────┐
▼ ▼ ▼
Phase 2a: Phase 2b: Phase 2c:
Research Codebase Analysis Business Analysis
[sdd:researcher sonnet] [sdd:code-explorer sonnet] [sdd:business-analyst opus]
Judge 2a Judge 2b Judge 2c
(pass: >THRESHOLD) (pass: >THRESHOLD) (pass: >THRESHOLD)
│ │ │
└─────────────────────┴─────────────────────┘
│
▼
Phase 3: Architecture Synthesis
[sdd:software-architect opus]
Judge 3 (pass: >THRESHOLD)
│
▼
Phase 4: Decomposition
[sdd:tech-lead opus]
Judge 4 (pass: >THRESHOLD)
│
▼
Phase 5: Parallelize
[sdd:team-lead opus]
Judge 5 (pass: >THRESHOLD)
│
▼
Phase 6: Verifications
[sdd:qa-engineer opus]
Judge 6 (pass: >THRESHOLD)
│
▼
Move task: draft/ → todo/
│
▼
Complete
阶段 2:并行分析
阶段 2 会并行启动三个分析阶段,每个阶段都有自己的裁判验证。
阶段 2a/2b/2c:并行子阶段
立即并行启动以下三个阶段:
阶段 2a:研究
模型: sonnet
Agent: sdd:researcher
依赖项: 任务文件已存在
目的: 收集相关资源、文档、库和先例,并创建或更新可复用的技能。
启动 Agent:
-
描述:"研究任务资源并创建/更新技能"
-
提示词:
CLAUDE_PLUGIN_ROOT=${CLAUDE_PLUGIN_ROOT} Task File: <TASK_FILE> Task Title: <title from task file> CRITICAL: DO NOT OUTPUT YOUR RESEARCH, ONLY CREATE THE SCRATCHPAD AND SKILL FILE.
记录:
- 技能文件路径(例如
.claude/skills/<skill-name>/SKILL.md) - 技能操作(新建/更新现有)
- 暂存区文件路径(例如
.specs/scratchpad/<hex-id>.md) - 收集的资源数量
- 关键建议摘要
关键要求: 如果未创建预期文件,请使用相同提示词重新启动 Agent。
阶段 2b:代码库影响分析
模型: sonnet
Agent: sdd:code-explorer
依赖项: 任务文件已存在
目的: 确定受影响的文件、接口和集成点
启动 Agent:
-
描述:“分析代码库影响”
-
提示词:
CLAUDE_PLUGIN_ROOT=${CLAUDE_PLUGIN_ROOT} Task File: <TASK_FILE> Task Title: <title from task file> CRITICAL: DO NOT OUTPUT YOUR ANALYSIS, ONLY CREATE THE SCRATCHPAD AND ANALYSIS FILE.
记录:
- 分析文件路径(例如,
.specs/analysis/analysis-{name}.md) - 临时文件路径(例如,
.specs/scratchpad/<hex-id>.md) - 受影响文件数量(修改/创建/删除)
- 风险等级评估
- 关键集成点
重要:如果未创建预期文件,请使用相同提示词再次启动 Agent。
阶段 2c:业务分析
模型: opus
Agent: sdd:business-analyst
依赖项: 任务文件已存在
目的: 优化描述并制定验收标准
启动 Agent:
-
描述:“业务分析”
-
提示词:
CLAUDE_PLUGIN_ROOT=${CLAUDE_PLUGIN_ROOT} Read ${CLAUDE_PLUGIN_ROOT}/skills/plan/analyse-business-requirements.md and execute it exactly as is! Task File: <TASK_FILE> Task Title: <title from task file> CRITICAL: DO NOT OUTPUT YOUR BUSINESS ANALYSIS, ONLY CREATE THE SCRATCHPAD AND UPDATE THE TASK FILE.
记录:
- 临时文件路径(例如,
.specs/scratchpad/<hex-id>.md) - 验收标准数量
- 是否已定义范围(是/否)
- 已记录的用户场景
评审器 2a/2b/2c:验证并行阶段
每个并行阶段完成后,使用相同的 Agent 类型和模型启动对应的评审器。
评审器 2a:验证研究/技能
模型: sonnet
Agent: sdd:researcher
依赖项: 阶段 2a 已完成
目的: 验证技能的完整性和相关性
启动评审器:
-
描述:“评审技能质量”
-
提示词:
CLAUDE_PLUGIN_ROOT=${CLAUDE_PLUGIN_ROOT} Read @${CLAUDE_PLUGIN_ROOT}/prompts/judge.md for evaluation methodology and execute. ### Artifact Path {path to skill file from Phase 2a} ### Context This is a skill document for task: {task title}. Evaluate comprehensiveness and reusability. ### Rubric 1. Resource Coverage (weight: 0.30) - Documentation and references gathered? - Libraries and tools identified with recommendations? - 1=Missing critical resources, 2=Basic coverage, 3=Adequate, 4=Comprehensive, 5=Excellent 2. Pattern Relevance (weight: 0.25) - Are identified patterns applicable? - Are recommendations actionable? - 1=Irrelevant, 2=Somewhat useful, 3=Adequate, 4=Well-targeted, 5=Perfect fit 3. Issue Anticipation (weight: 0.20) - Common pitfalls identified with solutions? - 1=None identified, 2=Few issues, 3=Adequate, 4=Good coverage, 5=Comprehensive 4. Reusability (weight: 0.15) - Is the skill general enough to help multiple tasks? - Does it avoid task-specific details? - 1=Too specific, 2=Limited reuse, 3=Adequate, 4=Good, 5=Highly reusable 5. Task Integration (weight: 0.10) - Was task file updated with skill reference? - 1=Not updated, 3=Updated, 5=Updated with clear instructions
重要:提示词必须原样使用,不要添加任何内容,包括实现 Agent 的输出!!!
决策逻辑:
- 通过(分数 >=
THRESHOLD):研究完成,继续 - 失败(分数 <
THRESHOLD):根据反馈重新启动阶段 2a - 达到
MAX_ITERATIONS:无论分数如何,继续到下一阶段(记录警告)
评审器 2b:验证代码库分析
模型: sonnet
Agent: sdd:code-explorer
依赖项: 阶段 2b 已完成
目的: 验证文件识别的准确性和集成映射
启动评审器:
-
描述:“评审代码库分析质量”
-
提示词:
CLAUDE_PLUGIN_ROOT=${CLAUDE_PLUGIN_ROOT} Read @${CLAUDE_PLUGIN_ROOT}/prompts/judge.md for evaluation methodology and execute. ### Artifact Path {path to analysis file from Phase 2b} ### Context This is codebase impact analysis for task: {task title}. Evaluate accuracy and completeness. ### Rubric 1. File Identification Accuracy (weight: 0.35) - All affected files identified with specific paths? - New files and modifications distinguished? - 1=Major files missing, 2=Mostly correct, 3=Adequate, 4=Precise, 5=Complete 2. Interface Documentation (weight: 0.25) - Key functions/classes documented with signatures? - Change requirements clear? - 1=Missing, 2=Partial, 3=Adequate, 4=Good, 5=Complete 3. Integration Point Mapping (weight: 0.25) - Integration points identified with impact? - Similar patterns in codebase found? - 1=Missing, 2=Partial, 3=Adequate, 4=Good, 5=Comprehensive 4. Risk Assessment (weight: 0.15) - High risk areas identified with mitigations? - 1=No assessment, 2=Basic, 3=Adequate, 4=Good, 5=Thorough
重要:提示词必须原样使用,不要添加任何内容,包括实现 Agent 的输出!!!
决策逻辑:
- 通过(分数 >=
THRESHOLD):分析完成,继续 - 失败(分数 <
THRESHOLD):根据反馈重新启动阶段 2b - 达到
MAX_ITERATIONS:无论分数如何,继续到下一阶段(记录警告)
评审器 2c:验证业务分析
模型: opus
Agent: sdd:business-analyst
依赖项: 阶段 2c 已完成
目的: 验证验收标准的质量和范围定义
启动评审器:
-
描述:“评审业务分析质量”
-
提示词:
CLAUDE_PLUGIN_ROOT=${CLAUDE_PLUGIN_ROOT} Read @${CLAUDE_PLUGIN_ROOT}/prompts/judge.md for evaluation methodology and execute. ### Artifact Path {path to task file from Phase 2c} ### Context This is business analysis output. Evaluate description clarity and acceptance criteria quality. ### Rubric 1. Description Clarity (weight: 0.30) - What/Why clearly explained? - Scope boundaries defined? - 1=Vague, 2=Basic, 3=Adequate, 4=Clear, 5=Excellent 2. Acceptance Criteria Quality (weight: 0.35) - Criteria specific and testable? - Given/When/Then format for complex criteria? - 1=Missing/vague, 2=Basic, 3=Adequate, 4=Good, 5=Excellent 3. Scenario Coverage (weight: 0.20) - Primary flow documented? - Error scenarios considered? - 1=Missing, 2=Basic, 3=Adequate, 4=Good, 5=Comprehensive 4. Scope Definition (weight: 0.15) - In-scope/out-of-scope explicit? - No implementation details in description? - 1=Missing, 2=Partial, 3=Adequate, 4=Good, 5=Clear
重要:提示词必须原样使用,不要添加任何内容,包括实现 Agent 的输出!!!
决策逻辑:
- 通过(分数 >=
THRESHOLD):业务分析完成,继续 - 失败(分数 <
THRESHOLD):根据反馈重新启动阶段 2c - 达到
MAX_ITERATIONS:无论分数如何,继续到下一阶段(记录警告)
同步点
在进入阶段 3 前,等待全部三个并行阶段(2a、2b、2c)及其评审器均通过。
阶段 3:架构综合
模型: opus
Agent: sdd:software-architect
依赖项: 阶段 2a + 评审器 2a 通过,阶段 2b + 评审器 2b 通过,阶段 2c + 评审器 2c 通过
目的: 将研究、分析和业务需求综合为架构概述
启动 Agent:
-
描述:“架构综合”
-
提示词:
CLAUDE_PLUGIN_ROOT=${CLAUDE_PLUGIN_ROOT} Task File: <TASK_FILE> Skill File: <skill file path from Phase 2a> Analysis File: <analysis file path from Phase 2b> CRITICAL: DO NOT OUTPUT YOUR ARCHITECTURE SYNTHESIS, ONLY CREATE THE SCRATCHPAD AND UPDATE THE TASK FILE.
记录:
- 临时文件路径(例如,
.specs/scratchpad/<hex-id>.md) - 添加到任务文件的章节
- 关键架构决策数量
- 已识别的组件(如适用)
- 已定义的契约(如适用)
评审 3:验证架构综合
模型: opus
Agent: sdd:software-architect
依赖: 第 3 阶段完成
目的: 验证架构的一致性和完整性
启动评审:
-
描述:"评审架构综合质量"
-
提示词:
CLAUDE_PLUGIN_ROOT=${CLAUDE_PLUGIN_ROOT} Read @${CLAUDE_PLUGIN_ROOT}/prompts/judge.md for evaluation methodology and execute. ### Artifact Path {path to task file after Phase 3} ### Context This is architecture synthesis output. The Architecture Overview section should contain solution strategy, key decisions, and only relevant architectural sections. ### Rubric 1. Solution Strategy Clarity (weight: 0.30) - Approach clearly explained? - Key decisions documented with reasoning? - Trade-offs stated? - 1=Missing/unclear, 2=Basic, 3=Adequate, 4=Clear, 5=Excellent 2. Reference Integration (weight: 0.20) - Links to research and analysis files? - Insights from both integrated? - 1=No links, 2=Partial, 3=Adequate, 4=Good, 5=Fully integrated 3. Section Relevance (weight: 0.25) - Only relevant sections included (not all)? - Sections appropriate for task complexity? - 1=Wrong sections, 2=Mostly appropriate, 3=Adequate, 4=Good, 5=Precisely targeted 4. Expected Changes Accuracy (weight: 0.25) - Files to create/modify listed? - Consistent with codebase analysis? - 1=Missing/inconsistent, 2=Partial, 3=Adequate, 4=Good, 5=Complete
关键:必须原样使用提示词,不要添加任何其他内容。包括实现 Agent 的输出!!!
决策逻辑:
- PASS(得分 >=
THRESHOLD):架构综合完成,继续 - FAIL(得分 <
THRESHOLD):根据反馈重新启动第 3 阶段 - 达到 MAX_ITERATIONS:无论得分如何,都继续进入第 4 阶段(记录警告)
等待 PASS 后再进入第 4 阶段。
第 4 阶段:分解
模型: opus
Agent: sdd:tech-lead
依赖: 第 3 阶段 + 评审 3 PASS
目的: 将架构拆解为实现步骤,并明确成功标准和风险
启动 Agent:
-
描述:"将工作分解为实现步骤"
-
提示词:
CLAUDE_PLUGIN_ROOT=${CLAUDE_PLUGIN_ROOT} Task File: <TASK_FILE> CRITICAL: DO NOT OUTPUT YOUR DECOMPOSITION, ONLY CREATE THE SCRATCHPAD AND UPDATE THE TASK FILE.
记录:
- 暂存文件路径(例如,
.specs/scratchpad/<hex-id>.md) - 实现步骤数量
- 子任务总数
- 关键路径步骤
- 高优先级风险数量
评审 4:验证分解
模型: opus
Agent: sdd:tech-lead
依赖: 第 4 阶段完成
目的: 验证实现步骤的质量和完整性
启动评审:
-
描述:"评审分解质量"
-
提示词:
CLAUDE_PLUGIN_ROOT=${CLAUDE_PLUGIN_ROOT} Read @${CLAUDE_PLUGIN_ROOT}/prompts/judge.md for evaluation methodology and execute. ### Artifact Path {path to task file after Phase 4} ### Context This is decomposition output. The Implementation Process section should contain ordered steps with success criteria, subtasks, blockers, and risks. ### Rubric 1. Step Quality (weight: 0.30) - Each step has clear goal, output, success criteria? - Steps ordered by dependency? - No step too large (>Large estimate)? - 1=Vague/missing, 2=Basic, 3=Adequate, 4=Good, 5=Excellent 2. Success Criteria Testability (weight: 0.25) - Criteria specific and verifiable? - Use actual file paths, function names? - Subtasks clearly defined with actionable descriptions? - 1=Vague, 2=Partially testable, 3=Adequate, 4=Good, 5=All testable 3. Risk Coverage (weight: 0.25) - Blockers identified with resolutions? - Risks identified with mitigations? - High-risk tasks identified with decomposition recommendations? - 1=None, 2=Basic, 3=Adequate, 4=Good, 5=Comprehensive 4. Completeness (weight: 0.20) - All architecture components have corresponding steps? - Implementation summary table present? - Definition of Done included? - Phases organized: Setup → Foundational → User Stories → Polish? - 1=Incomplete, 2=Partial, 3=Adequate, 4=Good, 5=Complete
关键:必须原样使用提示词,不要添加任何其他内容。包括实现 Agent 的输出!!!
决策逻辑:
- PASS(得分 >=
THRESHOLD):分解完成,继续进入第 5 阶段 - FAIL(得分 <
THRESHOLD):根据反馈重新启动第 4 阶段 - 达到 MAX_ITERATIONS:无论得分如何,都继续进入第 5 阶段(记录警告)
等待 PASS 后再进入第 5 阶段。
第 5 阶段:并行化步骤
模型: opus
Agent: sdd:team-lead
依赖: 第 4 阶段 + 评审 4 PASS
目的: 重新组织实现步骤,以实现最大程度的并行执行
启动 Agent:
-
描述:"并行化实现步骤"
-
提示词:
CLAUDE_PLUGIN_ROOT=${CLAUDE_PLUGIN_ROOT} Task File: <TASK_FILE> Use agents only from this list: {list ALL available agents with plugin prefix if available, e.g. sdd:developer, code-review:bug-hunter. Also include general agents: opus, sonnet, haiku} CRITICAL: DO NOT OUTPUT YOUR PARALLELIZATION, ONLY CREATE THE SCRATCHPAD AND UPDATE THE TASK FILE.
记录:
- 暂存文件路径(例如,
.specs/scratchpad/<hex-id>.md) - 重新组织的步骤数量
- 最大并行化深度
- Agent 分配摘要
评审 5:验证并行化
模型: opus
Agent: sdd:team-lead
依赖: 第 5 阶段完成
目的: 验证依赖关系的准确性和并行化优化效果
启动评审:
-
描述:"评审并行化质量"
-
提示词:
CLAUDE_PLUGIN_ROOT=${CLAUDE_PLUGIN_ROOT} Read @${CLAUDE_PLUGIN_ROOT}/prompts/judge.md for evaluation methodology and execute. ### Artifact Path {path to parallelized task file from Phase 5} ### Context This is the output of Phase 5: Parallelize Steps. The artifact should contain implementation steps reorganized for maximum parallel execution with explicit dependencies, agent assignments, and parallelization diagram. Use agents only from this list: {list ALL available agents with plugin prefix if available, e.g. sdd:developer, code-review:bug-hunter. Also include general agents: opus, sonnet, haiku} ### Rubric 1. Dependency Accuracy (weight: 0.35) - Are step dependencies correctly identified? - No false dependencies (steps marked dependent when they're not)? - No missing dependencies (steps that actually depend on others)? - 1=Major dependency errors, 2=Mostly correct, 3=Acceptable, 5=Precise dependencies 2. Parallelization Maximized (weight: 0.30) - Are parallelizable steps correctly marked with "Parallel with:"? - Is the parallelization diagram logical? - 1=No parallelization/wrong, 2=Some optimization, 3=Acceptable, 5=Maximum parallelization 3. Agent Selection Correctness (weight: 0.20) - Are agent types appropriate for outputs (opus by default, haiku for trivial, sonnet for simple but high in volume)? - Does selection follow the Agent Selection Guide? - Are only agents from the provided available agents list used? - 1=Wrong agents, 2=Mostly appropriate, 3=Acceptable, 4=Optimal selection, 5=Perfect selection 4. Execution Directive Present (weight: 0.15) - Is the sub-agent execution directive present? - Are "MUST" requirements for parallel execution clear? - 1=Missing directive, 2=Partial, 3=Acceptable, 4=Complete directive, 5=Perfect directive
关键:必须原样使用提示词,不要添加任何其他内容。包括实现 Agent 的输出!!!
决策逻辑:
- PASS(得分 >=
THRESHOLD):继续进入第 6 阶段 - FAIL(得分 <
THRESHOLD):根据反馈重新启动第 5 阶段 - 达到 MAX_ITERATIONS:无论得分如何,都继续进入第 6 阶段(记录警告)
等待 PASS 后再进入第 6 阶段。
第 6 阶段:定义验证
模型: opus
Agent: sdd:qa-engineer
依赖: 第 5 阶段 + 评审 5 PASS
目的: 添加 LLM-as-Judge 验证部分及评分标准
启动 Agent:
-
描述:"定义验证评分标准"
-
提示词:
CLAUDE_PLUGIN_ROOT=${CLAUDE_PLUGIN_ROOT} Task File: <TASK_FILE> CRITICAL: DO NOT OUTPUT YOUR VERIFICATIONS, ONLY CREATE THE SCRATCHPAD AND UPDATE THE TASK FILE.
记录:
- 暂存文件路径(例如,
.specs/scratchpad/<hex-id>.md) - 包含验证的步骤数量
- 定义的评估总数
- 验证明细(面板/逐项/无)
评审 6:验证验证结果
模型: opus
Agent: sdd:qa-engineer
依赖: 第 6 阶段完成
目的: 验证验证规则和阈值
启动评审:
-
描述:"评审验证质量"
-
提示词:
CLAUDE_PLUGIN_ROOT=${CLAUDE_PLUGIN_ROOT} Read @${CLAUDE_PLUGIN_ROOT}/prompts/judge.md for evaluation methodology and execute. ### Artifact Path {path to task file with verifications from Phase 6} ### Context This is the output of Phase 6: Define Verifications. The artifact should contain LLM-as-Judge verification sections for each implementation step, including verification levels, custom rubrics, thresholds, and a verification summary table. ### Rubric 1. Verification Level Appropriateness (weight: 0.30) - Do verification levels match artifact criticality? - HIGH criticality → Panel, MEDIUM → Single/Per-Item, LOW/NONE → None? - 1=Mismatched levels, 2=Mostly appropriate, 3=Acceptable, 5=Precisely calibrated 2. Rubric Quality (weight: 0.30) - Are criteria specific to the artifact type (not generic)? - Do weights sum to 1.0? - Are descriptions clear and measurable? - 1=Generic/broken rubrics, 2=Adequate, 3=Acceptable, 5=Excellent custom rubrics 3. Threshold Appropriateness (weight: 0.20) - Are thresholds reasonable (typically 4.0/5.0)? - Higher for critical, lower for experimental? - 1=Wrong thresholds, 2=Standard applied, 3=Acceptable, 5=Context-appropriate 4. Coverage Completeness (weight: 0.20) - Does every step have a Verification section? - Is the Verification Summary table present? - 1=Missing verifications, 2=Most covered, 3=Acceptable, 5=100% coverage
重要:必须原样使用提示词,不要添加任何其他内容,包括实现 Agent 的输出!
决策逻辑:
- 通过(得分 >=
THRESHOLD):工作流完成,提升任务 - 失败(得分 <
THRESHOLD):根据反馈重新启动第 6 阶段 - 达到
MAX_ITERATIONS:无论得分如何,均完成工作流(记录警告)
第 7 阶段:提升任务
目的: 将完善后的任务从 draft 文件夹移至 todo 文件夹
所有阶段完成后:
-
将任务文件从 draft 移至 todo:
git mv <TASK_FILE> .specs/tasks/todo/ # Fallback if git not available: mv <TASK_FILE> .specs/tasks/todo/ -
如有需要,更新研究和分析文件中的任何引用
完成
所有执行阶段和评审完成后:
- 使用 git 工具暂存任务文件、技能文件、分析文件和临时工作区文件(仅限已创建的文件)
- 总结工作流结果并输出给用户:
### Task Refined
| Property | Value |
|----------|-------|
| **Original File** | `<original TASK_FILE path>` |
| **Final Location** | `.specs/tasks/todo/<filename>` (ready for implementation) |
| **Title** | `<task title>` |
| **Type** | `<feature/bug/refactor/test/docs/chore/ci>` (from filename) |
| **Skill** | `<skill file path or "Skipped">` |
| **Skill Action** | `<Created new / Updated existing / Skipped>` |
| **Analysis** | `<analysis file path or "Skipped">` |
| **Scratchpad** | `<scratchpad file path>` |
| **Implementation Steps** | `<count or "N/A">` |
| **Parallelization Depth** | `<max parallel agents or "N/A">` |
| **Total Verifications** | `<count or "N/A">` |
### Configuration Used
| Setting | Value |
|---------|-------|
| **Target Quality** | {THRESHOLD}/5.0 |
| **Max Iterations** | {MAX_ITERATIONS} |
| **Active Stages** | {ACTIVE_STAGES as comma-separated list} |
| **Skipped Stages** | {SKIP_STAGES or stages not in ACTIVE_STAGES} |
| **Human Checkpoints** | Phase {HUMAN_IN_THE_LOOP_PHASES as comma-separated} |
| **Skip Judges** | {SKIP_JUDGES} |
| **Refine Mode** | {REFINE_MODE} |
### Quality Gates Summary
| Phase | Judge Score | Verdict |
|-------|-------------|---------|
| Phase 2a: Research | X.X/5.0 | ✅ PASS / ⚠️ PROCEEDED (max iter) / ⏭️ SKIPPED |
| Phase 2b: Codebase Analysis | X.X/5.0 | ✅ PASS / ⚠️ PROCEEDED (max iter) / ⏭️ SKIPPED |
| Phase 2c: Business Analysis | X.X/5.0 | ✅ PASS / ⚠️ PROCEEDED (max iter) / ⏭️ SKIPPED |
| Phase 3: Architecture Synthesis | X.X/5.0 | ✅ PASS / ⚠️ PROCEEDED (max iter) / ⏭️ SKIPPED |
| Phase 4: Decomposition | X.X/5.0 | ✅ PASS / ⚠️ PROCEEDED (max iter) / ⏭️ SKIPPED |
| Phase 5: Parallelize | X.X/5.0 | ✅ PASS / ⚠️ PROCEEDED (max iter) / ⏭️ SKIPPED |
| Phase 6: Verify | X.X/5.0 | ✅ PASS / ⚠️ PROCEEDED (max iter) / ⏭️ SKIPPED |
**Threshold Used:** {THRESHOLD}/5.0 (or N/A if SKIP_JUDGES)
**Legend:**
- ✅ PASS - Score >= THRESHOLD
- ⚠️ PROCEEDED (max iter) - Score < THRESHOLD but MAX_ITERATIONS reached, proceeded anyway
- ⏭️ SKIPPED - Stage not in ACTIVE_STAGES
### Artifacts Generated
.claude/ └── skills/ └── / └── SKILL.md # 可复用的技能文档(如果执行了研究阶段)
.specs/ ├── tasks/ │ ├── draft/ # 草稿任务(来源——此任务现在为空) │ ├── todo/ │ │ └── ..md # 完整的任务规范(可供实现) │ ├── in-progress/ # 正在实现的任务(空) │ └── done/ # 已完成的任务(空) ├── analysis/ │ └── analysis-.md # 代码库影响分析(如果执行了代码库分析阶段) └── scratchpad/ └── .md # 架构思考临时工作区
### Task Status Management
Task status is managed by folder location:
- `draft/` - Tasks created but not yet refined
- `todo/` - Tasks ready for implementation
- `in-progress/` - Tasks currently being worked on
- `done/` - Completed tasks
### Next Steps
1. Review task: `.specs/tasks/todo/<filename>`
- Edit the task file directly to make corrections
- Add `//` comments to lines that need clarification or changes
- Run `/plan` again with `--refine` to incorporate your feedback — it detects changes against git and propagates updates **top-to-bottom** (editing a section only affects sections below it, not above)
2. If everything is fine, begin implementation: `/implement` (will auto-select the task from todo/)
错误处理
阶段 Agent 失败(异常/崩溃)
如果任何阶段 Agent 意外失败:
- 报告失败情况及 Agent 输出
- 向用户询问有助于解决问题的澄清问题
- 使用问题和答案重新启动阶段 Agent,以解决问题
评审返回失败
如果任何评审返回失败(得分 < THRESHOLD):
- 自动重试:根据评审反馈重新启动阶段 Agent
- 人工介入检查:如果阶段位于
HUMAN_IN_THE_LOOP_PHASES中,则在下次评审重试之前触发人工检查点(在实现重试之后,但在重新评审之前) - 达到
MAX_ITERATIONS后:自动继续下一阶段(除非--human-in-the-loop包含此阶段,否则不要询问用户) - 在完成摘要中记录警告:
⚠️ Phase X did not pass quality threshold (X.X/THRESHOLD) after MAX_ITERATIONS iterations
重试流程
Implementation → Judge FAIL → Implementation Retry → Judge Retry
↓
PASS → Continue to next stage
FAIL → Repeat until MAX_ITERATIONS
↓
MAX_ITERATIONS reached → Proceed to next stage (with warning)
人工介入重试流程
当阶段位于 HUMAN_IN_THE_LOOP_PHASES 中时:
Implementation → Judge FAIL → Implementation Retry
↓
🔍 Human Checkpoint (optional feedback)
↓
Judge Retry
↓
PASS → Continue | FAIL → Repeat until MAX_ITERATIONS
↓
MAX_ITERATIONS → 🔍 Final Human Checkpoint
↓
User confirms → Proceed to next stage