spec-implement
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesespec-implement — Spec-Driven Implementation to PR
spec-implement — 规范驱动的从需求到PR实现流程
Execute implementation from specifications to pull request, following project-specific workflows and enforcing coding rules.
遵循项目特定工作流,从规范文档执行到Pull Request的完整实现流程,并强制执行编码规则。
Language Rules
语言规则
- Auto-detect input language → output in the same language
- Japanese input → Japanese output, use
references/implement-guide.ja.md - English input → English output, use
references/implement-guide.md - Explicit override takes priority (e.g., "in English", "日本語で")
- 自动检测输入语言 → 输出与输入语言一致
- 日文输入 → 日文输出,使用
references/implement-guide.ja.md - 英文输入 → 英文输出,使用
references/implement-guide.md - 显式覆盖指令优先(例如:"in English"、"日本語で")
Critical First Steps
关键前置步骤
BEFORE any implementation, execute these checks in order:
-
Verify environment:
- Run to confirm working directory
pwd - Run to confirm inside a git repository
git status - Run to confirm GitHub CLI access
gh auth status
- Run
-
Parse user input for options:
- → resume from last uncompleted task
--resume - → specify GitHub Issue number
--issue {N} - → specify
--spec {path}directory path.specs/ - → show execution plan without making changes
--dry-run - → force parallel execution if environment is ready
--parallel - → force sequential execution
--no-parallel
-
Locate spec directory:
- If provided → use that path
--spec - If issue body contains path → use that
.specs/ - Otherwise → scan and ask user to select:
.specs/AskUserQuestion: question: "Which spec to implement?" / "どの仕様書を実装しますか?" options: [list discovered .specs/ directories]
- If
-
Locate and read project files (in this order):Workflow playbook — search in order, use first found:
docs/development/issue-to-pr-workflow.mddocs/issue-to-pr-workflow.md- Fallback:
find . -name "issue-to-pr-workflow.md" -not -path "*/node_modules/*" -not -path "*/.git/*" -not -path "*/vendor/*" -not -path "*/dist/*" -not -path "*/build/*" | head -1 - If not found → trigger fallback (see Phase 1)
Coding rules — search in order, use first found:docs/development/coding-rules.mddocs/coding-rules.md- Fallback:
find . -name "coding-rules.md" -not -path "*/node_modules/*" -not -path "*/.git/*" -not -path "*/vendor/*" -not -path "*/dist/*" -not -path "*/build/*" | head -1 - If not found → trigger fallback (see Phase 2)
Project instruction files — read all that exist:- (project root)
CLAUDE.md - (source-level rules)
src/CLAUDE.md - (test-level rules)
test/CLAUDE.md - (agent definitions)
AGENTS.md
Spec files:- → what to build
.specs/{feature}/requirement.md - → how to build it
.specs/{feature}/design.md - → task breakdown with checkboxes
.specs/{feature}/tasks.md
-
Detect parallel-capable agent environment (runtime-aware):
- Determine active runtime from the current execution environment (do NOT infer runtime solely from repository directories)
- Use repository files only for runtime setup validation:
- Codex validation:
.codex/config.toml - Claude Code validation:
.claude/agents/workflow-*.md
- Codex validation:
- If runtime cannot be determined, ask user to choose runtime
- Check whether workflow contains a parallel section (/
Parallel Execution Strategy)Agent Roles - Parse optional workflow section for explicit agent file paths:
- /
Agent definition files:エージェント定義ファイル: - Extract paths for implementer / reviewer / tester from list items
- Use extracted paths as first priority for validation and dispatch context
- If section is absent, fallback to runtime defaults
- Validate runtime-specific sub-agent setup:
- Codex: has
.codex/config.tomland[features] multi_agent = trueagents.workflow-* - Claude Code: agent files from workflow section exist; if absent, use defaults (,
.claude/agents/workflow-implementer.md,.claude/agents/workflow-reviewer.md).claude/agents/workflow-tester.md
- Codex:
- If any required condition is missing, continue in sequential mode
在开始任何实现之前,按顺序执行以下检查:
-
验证环境:
- 运行确认工作目录
pwd - 运行确认处于git仓库内
git status - 运行确认GitHub CLI已授权
gh auth status
- 运行
-
解析用户输入的选项:
- → 从最后一个未完成的任务恢复执行
--resume - → 指定GitHub Issue编号
--issue {N} - → 指定
--spec {path}目录路径.specs/ - → 显示执行计划但不进行实际修改
--dry-run - → 若环境就绪则强制并行执行
--parallel - → 强制串行执行
--no-parallel
-
定位规范目录:
- 若提供参数 → 使用指定路径
--spec - 若Issue正文中包含路径 → 使用该路径
.specs/ - 否则 → 扫描并让用户选择:
.specs/AskUserQuestion: question: "Which spec to implement?" / "どの仕様書を実装しますか?" options: [list discovered .specs/ directories]
- 若提供
-
定位并读取项目文件(按以下顺序):工作流手册 — 按顺序搜索,使用第一个找到的文件:
docs/development/issue-to-pr-workflow.mddocs/issue-to-pr-workflow.md- 备选方案:
find . -name "issue-to-pr-workflow.md" -not -path "*/node_modules/*" -not -path "*/.git/*" -not -path "*/vendor/*" -not -path "*/dist/*" -not -path "*/build/*" | head -1 - 若未找到 → 触发备选流程(见阶段1)
编码规则 — 按顺序搜索,使用第一个找到的文件:docs/development/coding-rules.mddocs/coding-rules.md- 备选方案:
find . -name "coding-rules.md" -not -path "*/node_modules/*" -not -path "*/.git/*" -not -path "*/vendor/*" -not -path "*/dist/*" -not -path "*/build/*" | head -1 - 若未找到 → 触发备选流程(见阶段2)
项目指令文件 — 读取所有存在的文件:- (项目根目录)
CLAUDE.md - (源码级规则)
src/CLAUDE.md - (测试级规则)
test/CLAUDE.md - (Agent定义)
AGENTS.md
规范文件:- → 实现目标
.specs/{feature}/requirement.md - → 实现方案
.specs/{feature}/design.md - → 带复选框的任务分解
.specs/{feature}/tasks.md
-
检测支持并行的Agent环境(运行时感知):
- 从当前执行环境确定活跃运行时(请勿仅通过仓库目录推断运行时)
- 仅使用仓库文件验证运行时配置:
- Codex验证:
.codex/config.toml - Claude Code验证:
.claude/agents/workflow-*.md
- Codex验证:
- 若无法确定运行时,询问用户选择运行时
- 检查工作流是否包含并行章节(/
Parallel Execution Strategy)Agent Roles - 解析可选的工作流章节以获取显式Agent文件路径:
- /
Agent definition files:エージェント定義ファイル: - 从列表项中提取实现者/审核者/测试者的路径
- 将提取的路径作为验证和调度上下文的第一优先级
- 若该章节不存在,回退到运行时默认值
- 验证运行时特定的子Agent设置:
- Codex: 中包含
.codex/config.toml和[features] multi_agent = trueagents.workflow-* - Claude Code: 工作流章节中的Agent文件存在;若不存在,使用默认文件(,
.claude/agents/workflow-implementer.md,.claude/agents/workflow-reviewer.md).claude/agents/workflow-tester.md
- Codex:
- 若任何必要条件缺失,继续使用串行模式
Execution Flow
执行流程
Phase 1: Workflow Loading
阶段1: 工作流加载
Read the workflow file (located in Step 4) and interpret each section as instructions to follow:
| Workflow Section | Action |
|---|---|
| Development Environment | Extract setup commands, environment variables |
| Issue Analysis and Setup | Follow branch naming convention, issue reading steps |
| Branch Strategy / PR Target | Extract base branch (e.g., |
| Phased Implementation | Follow implementation order and guidelines |
| Agent Roles / Sub-agents | Extract agent role definitions (if present) |
| Agent Definition Files (Optional) | Extract explicit sub-agent definition file paths |
| Testing | Extract test commands and coverage thresholds |
| PR Creation and Quality Gates | Extract pre-PR checks and PR template |
| CI/CD Monitoring | Extract CI verification commands |
| Commit Message Rules | Extract commit message format and language requirements |
Follow sections top-to-bottom. Replace placeholders with actual values (issue number, branch name, etc.). Treat "MUST" and "required" keywords as mandatory; treat "optional" and "if applicable" as conditional.
{variable}Base branch detection — determine from the workflow:
{base_branch}- Look for "branch strategy", "base branch", "PR target", "develop", "main" in the workflow
- If the workflow specifies a branch (e.g., ), use it as
develop{base_branch} - Default fallback:
main
Fallback (no workflow file):
If no workflow file is found:
AskUserQuestion:
question: "Workflow file not found. Generate it?" / "ワークフローファイルが見つかりません。生成しますか?"
options:
- "Run spec-workflow-init" / "spec-workflow-initを実行"
- "Continue without workflow" / "ワークフローなしで続行"If continuing without workflow, use minimal flow: Issue analysis → branch → implement → test → PR. Use as .
main{base_branch}读取步骤4中找到的工作流文件,并将每个章节解释为执行指令:
| 工作流章节 | 操作 |
|---|---|
| Development Environment | 提取设置命令、环境变量 |
| Issue Analysis and Setup | 遵循分支命名规范、Issue读取步骤 |
| Branch Strategy / PR Target | 提取基础分支(例如: |
| Phased Implementation | 遵循实现顺序和指南 |
| Agent Roles / Sub-agents | 提取Agent角色定义(若存在) |
| Agent Definition Files (Optional) | 提取显式子Agent定义文件路径 |
| Testing | 提取测试命令和覆盖率阈值 |
| PR Creation and Quality Gates | 提取PR前置检查和PR模板 |
| CI/CD Monitoring | 提取CI验证命令 |
| Commit Message Rules | 提取提交消息格式和语言要求 |
按从上到下的顺序遵循章节内容。 将占位符替换为实际值(Issue编号、分支名称等)。将"MUST"和"required"关键字视为强制性要求;将"optional"和"if applicable"视为条件性要求。
{variable}基础分支检测 — 从工作流中确定:
{base_branch}- 在工作流中查找"branch strategy"、"base branch"、"PR target"、"develop"、"main"
- 若工作流指定了分支(例如: ),将其用作
develop{base_branch} - 默认回退值:
main
备选方案(无工作流文件):
若未找到工作流文件:
AskUserQuestion:
question: "Workflow file not found. Generate it?" / "ワークフローファイルが見つかりません。生成しますか?"
options:
- "Run spec-workflow-init" / "spec-workflow-initを実行"
- "Continue without workflow" / "ワークフローなしで続行"若选择无工作流继续,使用最小化流程: Issue分析 → 创建分支 → 实现 → 测试 → PR。使用作为。
main{base_branch}Phase 1.5: Parallel Mode Resolution (Runtime-Aware)
阶段1.5: 并行模式解析(运行时感知)
Enable parallel mode only when ALL are true:
- Workflow includes a parallel section with role assignment
- Runtime-specific sub-agent configuration is valid
- User did not pass (or explicitly passed
--no-parallel)--parallel
If runtime cannot be determined from execution context, confirm runtime before dispatch:
AskUserQuestion:
question: "Which runtime should execute sub-agents?" / "どのランタイムでサブエージェント実行しますか?"
options:
- "Codex runtime" / "Codexで実行"
- "Claude Code runtime" / "Claude Codeで実行"If enabled:
- Run implementer and tester in parallel, then run reviewer after both complete.
- Use explicit runtime-specific dispatch instructions, not narrative role assignment only.
Codex path:
- Required config: with
.codex/config.tomlandmulti_agent = trueagents.workflow-* - Agent definition file paths:
- First priority: paths declared in workflow section
Agent definition files - Fallback: runtime defaults (from conventions)
.codex/agents/
- First priority: paths declared in workflow
- Dispatch format (example):
text
Task:
subagent_type: workflow-implementer
prompt: "Implement task T001 using design section 2.3. Edit implementation files only."
Task:
subagent_type: workflow-tester
prompt: "Create tests for task T001. Edit test files only."Claude Code path:
- Required files:
- First priority: paths declared in workflow section
Agent definition files - Fallback defaults: ,
.claude/agents/workflow-implementer.md,.claude/agents/workflow-reviewer.md.claude/agents/workflow-tester.md
- First priority: paths declared in workflow
- Dispatch format: use Claude Code sub-agent call format with set to workflow agent names (
subagent_type,workflow-implementer,workflow-tester).workflow-reviewer - Example (pseudocode):
text
SubAgent:
subagent_type: workflow-implementer
prompt: "Implement task T001 using design section 2.3. Edit implementation files only."If disabled:
- Continue with the existing single-agent sequential loop.
仅当以下所有条件满足时,启用并行模式:
- 工作流包含带角色分配的并行章节
- 运行时特定的子Agent配置有效
- 用户未传递参数(或显式传递
--no-parallel)--parallel
若无法从执行上下文确定运行时,在调度前确认运行时:
AskUserQuestion:
question: "Which runtime should execute sub-agents?" / "どのランタイムでサブエージェント実行しますか?"
options:
- "Codex runtime" / "Codexで実行"
- "Claude Code runtime" / "Claude Codeで実行"若启用并行模式:
- 并行运行实现者和测试者,两者完成后再运行审核者
- 使用显式的运行时特定调度指令,而非仅基于叙述性角色分配
Codex路径:
- 所需配置: 包含
.codex/config.toml和multi_agent = trueagents.workflow-* - Agent定义文件路径:
- 第一优先级: 工作流章节中声明的路径
Agent definition files - 回退值: 运行时默认值(来自约定)
.codex/agents/
- 第一优先级: 工作流
- 调度格式(示例):
text
Task:
subagent_type: workflow-implementer
prompt: "Implement task T001 using design section 2.3. Edit implementation files only."
Task:
subagent_type: workflow-tester
prompt: "Create tests for task T001. Edit test files only."Claude Code路径:
- 所需文件:
- 第一优先级: 工作流章节中声明的路径
Agent definition files - 回退默认值: ,
.claude/agents/workflow-implementer.md,.claude/agents/workflow-reviewer.md.claude/agents/workflow-tester.md
- 第一优先级: 工作流
- 调度格式: 使用Claude Code子Agent调用格式,设置为工作流Agent名称(
subagent_type,workflow-implementer,workflow-tester)workflow-reviewer - 示例(伪代码):
text
SubAgent:
subagent_type: workflow-implementer
prompt: "Implement task T001 using design section 2.3. Edit implementation files only."若禁用并行模式:
- 继续使用现有的单Agent串行循环
Phase 2: Quality Rules Loading
阶段2: 质量规则加载
Read the coding rules file (located in Step 4) and parse rule structure:
undefined读取步骤4中找到的编码规则文件,并解析规则结构:
undefined{Category}
{Category}
[{Severity}] {Rule Name}
[{Severity}] {Rule Name}
- {Rule detail}
Apply rules by severity:
| Severity | On Violation | Action |
|----------|-------------|--------|
| `[MUST]` | Error | Stop → fix → recheck before continuing |
| `[SHOULD]` | Warning | Log warning → continue |
| `[MAY]` | Info | Log info only |
**Check timing:**
- **Before task**: Review rules relevant to the task's category
- **During code generation**: Self-check against `[MUST]` rules
- **After task**: Verify completion criteria + rule compliance
- **Final gate**: Check all `[MUST]` rules across all changes
**Fallback (no rules file):**
If no coding rules file is found:AskUserQuestion:
question: "Coding rules not found. Generate them?" / "コーディングルールが見つかりません。生成しますか?"
options:
- "Run spec-rules-init" / "spec-rules-initを実行"
- "Continue without rules" / "ルールなしで続行"
If continuing without rules, use CLAUDE.md or AGENTS.md as fallback reference if available.- {Rule detail}
按严重程度应用规则:
| 严重程度 | 违反时 | 操作 |
|----------|-------------|--------|
| `[MUST]` | 错误 | 停止执行 → 修复问题 → 重新检查后再继续 |
| `[SHOULD]` | 警告 | 记录警告 → 继续执行 |
| `[MAY]` | 信息 | 仅记录信息 |
**检查时机:**
- **任务开始前**: 回顾与任务类别相关的规则
- **代码生成期间**: 自行检查是否符合`[MUST]`规则
- **任务完成后**: 验证完成标准 + 规则合规性
- **最终关卡**: 检查所有变更是否符合`[MUST]`规则
**备选方案(无规则文件):**
若未找到编码规则文件:AskUserQuestion:
question: "Coding rules not found. Generate them?" / "コーディングルールが見つかりません。生成しますか?"
options:
- "Run spec-rules-init" / "spec-rules-initを実行"
- "Continue without rules" / "ルールなしで続行"
若选择无规则继续,若存在CLAUDE.md或AGENTS.md则将其作为回退参考。Phase 3: Project Instruction Loading
阶段3: 项目指令加载
Read all project instruction files found in Step 4 (, , , ).
CLAUDE.mdsrc/CLAUDE.mdtest/CLAUDE.mdAGENTS.mdThese files contain project-specific conditional rules, environment constraints, and coding conventions. Apply them with the same enforcement level as rules from coding-rules.md:
[MUST]- Extract conditional rules: IF-THEN patterns, conditional instructions, and environment-specific constraints (e.g., "when using Docker...", "if the project has...") are mandatory action triggers
- Extract environment constraints: Docker requirements, package manager restrictions, etc.
- Extract commit conventions: Commit message language, format, co-author requirements
- Extract test patterns: Required test helpers, test structure conventions
- Merge with coding-rules.md: These rules supplement (not replace) coding-rules.md
If neither coding-rules.md nor any CLAUDE.md files exist, proceed with framework defaults only.
读取步骤4中找到的所有项目指令文件(, , , )。
CLAUDE.mdsrc/CLAUDE.mdtest/CLAUDE.mdAGENTS.md这些文件包含项目特定的条件规则、环境约束和编码约定。将其与coding-rules.md中的规则应用相同的强制执行级别:
[MUST]- 提取条件规则: IF-THEN模式、条件指令和环境特定约束(例如:"when using Docker...", "if the project has...")为强制性操作触发条件
- 提取环境约束: Docker要求、包管理器限制等
- 提取提交约定: 提交消息语言、格式、合著者要求
- 提取测试模式: 必需的测试助手、测试结构约定
- 与coding-rules.md合并: 这些规则是补充(而非替代)coding-rules.md
若既不存在coding-rules.md也不存在任何CLAUDE.md文件,仅使用框架默认值继续执行。
Phase 4: Issue Analysis
阶段4: Issue分析
If is provided or an issue number is found in context:
--issue {N}bash
gh issue view {N} --json title,body,labels,assigneesExtract from the issue:
- Feature overview and requirements
- Spec directory path (if referenced)
- Phase/task checklists
- Assignees and labels
若提供参数或在上下文中找到Issue编号:
--issue {N}bash
gh issue view {N} --json title,body,labels,assignees从Issue中提取:
- 功能概述和需求
- 规范目录路径(若有引用)
- 阶段/任务检查清单
- 被分配人和标签
Phase 5: Branch Creation
阶段5: 分支创建
🚨 BLOCKING GATE — Feature branch is MANDATORYImplementation MUST NOT proceed on,main, ormasterbranches. This gate cannot be skipped. Violation = immediate stop.develop
Follow the workflow's branch naming convention:
bash
git checkout {base_branch} && git pull origin {base_branch}
git checkout -b feature/issue-{N}-{brief-description}Where is the branch detected in Phase 1 (default: ).
{base_branch}mainProtected branch list — by default: , , .
If the workflow file defines a "protected branches" or "branch protection" section, use that list instead.
mainmasterdevelopIf is active and the branch already exists, switch to it instead.
--resumePost-creation verification:
bash
current_branch=$(git branch --show-current)
if [ "$current_branch" = "main" ] || [ "$current_branch" = "master" ] || [ "$current_branch" = "develop" ]; then
echo "🚨 ERROR: Cannot implement on protected branch: $current_branch"
echo "Create a feature branch first."
exit 1
fiThis check MUST pass before proceeding to Phase 6. If it fails, stop and ask the user for guidance.
🚨 阻塞关卡 — 必须使用功能分支严禁在、main或master分支上进行实现。 此关卡无法跳过。违反将立即停止执行。develop
遵循工作流的分支命名规范:
bash
git checkout {base_branch} && git pull origin {base_branch}
git checkout -b feature/issue-{N}-{brief-description}其中是阶段1中检测到的分支(默认: )。
{base_branch}main受保护分支列表 — 默认值: , , 。
若工作流文件定义了"protected branches"或"branch protection"章节,使用该列表替代默认值。
mainmasterdevelop若激活且分支已存在,切换到该分支即可。
--resume创建后验证:
bash
current_branch=$(git branch --show-current)
if [ "$current_branch" = "main" ] || [ "$current_branch" = "master" ] || [ "$current_branch" = "develop" ]; then
echo "🚨 ERROR: Cannot implement on protected branch: $current_branch"
echo "Create a feature branch first."
exit 1
fi此检查必须通过才能进入阶段6。若检查失败,停止执行并询问用户指导。
Phase 6: Spec-Driven Task Loop
阶段6: 规范驱动的任务循环
Pre-loop: Agent role detection
If the workflow file contains an "Agent Roles", "Sub-agents", or "エージェントロール" section:
-
Parse explicit agent file paths (if present):
- Read workflow section /
Agent definition files:エージェント定義ファイル: - Build a map of role → definition file path (implementer/reviewer/tester)
- If no section exists, use runtime defaults
- Read workflow section
-
Parse the Role Assignment Table — find the Markdown table with columns like:
Role | Agent | Responsibility- Extract each row's column value → use as runtime sub-agent identifier (
Agent)subagent_type - Extract each row's column value → use as context in the task prompt
Responsibility
- Extract each row's
-
Parse the Parallel Execution Strategy Table (if present) — find the table with phase rows and role columns:
- Each row = a phase (execute sequentially, top to bottom)
- Cells with = role is idle in that phase
- - Non-cells = role's action (roles active in the same row run in parallel)
-
-
Present options to the user:
AskUserQuestion: question: "Workflow defines agent roles. Use sub-agents for parallel execution?" / "ワークフローにエージェントロールが定義されています。サブエージェントで並列実行しますか?" options: - "Use sub-agents (parallel)" / "サブエージェント使用(並列)" - "Single agent (sequential)" / "シングルエージェント(順次)" -
If sub-agents selected, branch by runtime:
- Codex runtime: spawn agents via Codex Task dispatch using parsed names as
Agentsubagent_type - Claude Code runtime: spawn agents via Claude Code sub-agent dispatch using parsed names as
Agentsubagent_type - Execute phases per strategy table (same-row roles run in parallel)
- Codex runtime: spawn agents via Codex Task dispatch using parsed
-
If single agent selected: proceed with sequential execution below
See reference guide for table format examples and runtime-specific sub-agent invocation patterns.
Read specs in order: → →
requirement.mddesign.mdtasks.mdFor each unchecked task in :
tasks.md1. Read task details (requirements ID, design reference, target files, completion criteria)
2. Reference the corresponding design.md section
3. Implement: create or modify target files
4. 🔍 Implementation Review:
a. Self-review generated code against design.md specifications
b. Verify coding-rules.md [MUST] rules for generated code
c. Verify CLAUDE.md conditional rules for generated code
d. If review finds issues → fix before proceeding
5. If task includes test implementation:
a. Write tests following project test patterns (from CLAUDE.md / coding-rules.md)
b. Run tests to verify they pass
c. 🔍 Test Review:
- Verify test coverage matches completion criteria
- Verify test patterns match project conventions
- If review finds issues → fix before proceeding
6. Update tasks.md: mark completion criteria (- [ ] → - [x])
7. When all criteria pass: mark top-level task checkbox (- [x])
8. Commit progress:
git add .specs/{feature}/tasks.md [+ implementation files]
git commit -m "{commit message following project conventions}"Commit messages: Follow format/language from coding-rules.md or CLAUDE.md. Default: . See reference guide for details.
feat: {task-id} complete — {brief description}No specs fallback: If is missing, use Issue body as guide and generate a simple checklist. See reference guide for details.
.specs/循环前: Agent角色检测
若工作流文件包含"Agent Roles"、"Sub-agents"或"エージェントロール"章节:
-
解析显式Agent文件路径(若存在):
- 读取工作流章节/
Agent definition files:エージェント定義ファイル: - 构建角色→定义文件路径的映射(实现者/审核者/测试者)
- 若该章节不存在,使用运行时默认值
- 读取工作流章节
-
解析角色分配表 — 查找包含等列的Markdown表:
Role | Agent | Responsibility- 提取每行的列值 → 用作运行时子Agent标识符(
Agent)subagent_type - 提取每行的列值 → 用作任务提示中的上下文
Responsibility
- 提取每行的
-
解析并行执行策略表(若存在) — 查找包含阶段行和角色列的表:
- 每行 = 一个阶段(从上到下串行执行)
- 包含的单元格 = 该角色在该阶段空闲
- - 非的单元格 = 角色的操作(同一行中的角色并行运行)
-
-
向用户呈现选项:
AskUserQuestion: question: "Workflow defines agent roles. Use sub-agents for parallel execution?" / "ワークフローにエージェントロールが定義されています。サブエージェントで並列実行しますか?" options: - "Use sub-agents (parallel)" / "サブエージェント使用(並列)" - "Single agent (sequential)" / "シングルエージェント(順次)" -
若选择使用子Agent,按运行时分支处理:
- Codex运行时: 使用解析的名称作为
Agent,通过Codex Task调度生成Agentsubagent_type - Claude Code运行时: 使用解析的名称作为
Agent,通过Claude Code子Agent调度生成Agentsubagent_type - 按策略表执行阶段(同一行的角色并行运行)
- Codex运行时: 使用解析的
-
若选择单Agent: 继续以下串行执行
有关表格式示例和运行时特定子Agent调用模式,请参阅参考指南。
按顺序读取规范文件: → →
requirement.mddesign.mdtasks.md针对中的每个未勾选任务:
tasks.md1. 读取任务详情(需求ID、设计参考、目标文件、完成标准)
2. 参考对应的design.md章节
3. 实现: 创建或修改目标文件
4. 🔍 实现审核:
a. 对照design.md规范自行审核生成的代码
b. 验证生成的代码是否符合coding-rules.md中的`[MUST]`规则
c. 验证生成的代码是否符合CLAUDE.md中的条件规则
d. 若审核发现问题 → 修复后再继续
5. 若任务包含测试实现:
a. 遵循项目测试模式(来自CLAUDE.md / coding-rules.md)编写测试
b. 运行测试以验证通过
c. 🔍 测试审核:
- 验证测试覆盖率是否符合完成标准
- 验证测试模式是否符合项目约定
- 若审核发现问题 → 修复后再继续
6. 更新tasks.md: 标记完成标准(- [ ] → - [x])
7. 当所有标准通过时: 标记顶级任务复选框(- [x])
8. 提交进度:
git add .specs/{feature}/tasks.md [+ implementation files]
git commit -m "{commit message following project conventions}"提交消息: 遵循coding-rules.md或CLAUDE.md中的格式/语言要求。默认格式: 。详情请参阅参考指南。
feat: {task-id} complete — {brief description}无规范文件备选方案: 若缺失,使用Issue正文作为指南并生成简单的检查清单。详情请参阅参考指南。
.specs/Phase 7: Final Quality Gate
阶段7: 最终质量关卡
After all tasks are complete:
- Run test commands from the workflow (or language-appropriate default)
- Run lint/typecheck commands from the workflow (if specified)
- Verify all rules from coding-rules.md pass
[MUST] - Verify all CLAUDE.md conditional rules pass
- If any check fails → fix → recheck
- All checks pass → proceed to PR creation
所有任务完成后:
- 运行工作流中的测试命令(或语言对应的默认命令)
- 运行工作流中的 lint/类型检查命令(若指定)
- 验证coding-rules.md中的所有规则均通过
[MUST] - 验证CLAUDE.md中的所有条件规则均通过
- 若任何检查失败 → 修复问题 → 重新检查
- 所有检查通过 → 进入PR创建阶段
Phase 8: PR Creation
阶段8: PR创建
Follow the workflow's PR template. Use detected in Phase 1:
{base_branch}bash
gh pr create \
--title "{type}: {description} (closes #{N})" \
--body "{PR body following workflow template}" \
--base {base_branch}Where comes from Phase 1 workflow detection (default: ).
{base_branch}mainVerify matches the workflow's branch strategy before creating the PR.
--base {base_branch}Safety guards:
- Do NOT create PR if tests are failing
- Do NOT force push
- Do NOT push directly to main/master
- Do NOT target wrong base branch (verify against workflow)
- Ask for user confirmation before large-scale code deletions
After PR creation, monitor CI status if the workflow specifies CI verification commands.
遵循工作流的PR模板。使用阶段1中检测到的:
{base_branch}bash
gh pr create \
--title "{type}: {description} (closes #{N})" \
--body "{PR body following workflow template}" \
--base {base_branch}其中来自阶段1的工作流检测(默认: )。
{base_branch}main创建PR前,验证是否与工作流的分支策略匹配。
--base {base_branch}安全防护:
- 若测试失败,请勿创建PR
- 请勿强制推送
- 请勿直接推送到main/master分支
- 请勿指定错误的基础分支(需与工作流验证)
- 进行大规模代码删除前需询问用户确认
PR创建后,若工作流指定了CI验证命令,监控CI状态。
Options
选项
| Option | Description |
|---|---|
| Resume from last uncompleted task in tasks.md |
| Specify GitHub Issue number for context |
| Specify .specs/ directory path (default: auto-detect) |
| Show execution plan without making any changes (output format: see reference guide) |
| Force parallel mode (requires valid runtime sub-agent setup for Codex or Claude Code) |
| Disable parallel mode and run sequentially |
| 选项 | 描述 |
|---|---|
| 从tasks.md中最后一个未完成的任务恢复执行 |
| 指定用于上下文的GitHub Issue编号 |
| 指定.specs/目录路径(默认: 自动检测) |
| 显示执行计划但不进行任何修改(输出格式: 请参阅参考指南) |
| 强制并行模式(需要Codex或Claude Code的有效运行时子Agent设置) |
| 禁用并行模式并串行运行 |
Error Handling
错误处理
| Situation | Response |
|---|---|
| Not a git repository | Error: "Must be in a git repository" / "gitリポジトリ内で実行してください" |
| Error: guide user to install/authenticate gh CLI |
| Warning: switch to Issue-only minimal mode |
| Parallel requested but runtime sub-agent config missing/invalid | Warning: explain missing setup, fallback to sequential mode |
| Workflow-declared agent definition file path does not exist | Warning: explain missing file path, fallback to sequential mode |
| Workflow references sub-agent names that are not configured in selected runtime | Warning: explain missing agent definitions, fallback to sequential mode |
| Parallel file edit collision | Warning: stop parallel for current task, continue sequentially |
| Warning: use Issue body as requirements source |
| Warning: generate simple checklist from Issue |
| Error: stop, fix, recheck before continuing |
| Tests failing before PR | Block PR creation, report failures |
| Branch already exists | Ask: switch to it or create new |
| On protected branch (main/master/develop) | 🚨 BLOCKING: stop immediately, require feature branch |
| Workflow/rules file not at expected path | Search alternate paths before declaring missing |
| 场景 | 响应 |
|---|---|
| 非git仓库 | 错误: "Must be in a git repository" / "gitリポジトリ内で実行してください" |
| 错误: 指导用户安装/授权gh CLI |
| 警告: 切换到仅Issue的最小化模式 |
| 请求并行但运行时子Agent配置缺失/无效 | 警告: 说明缺失的设置,回退到串行模式 |
| 工作流声明的Agent定义文件路径不存在 | 警告: 说明缺失的文件路径,回退到串行模式 |
| 工作流引用的子Agent名称在所选运行时中未配置 | 警告: 说明缺失的Agent定义,回退到串行模式 |
| 并行文件编辑冲突 | 警告: 停止当前任务的并行执行继续串行执行 |
| 警告: 使用Issue正文作为需求来源 |
| 警告: 从Issue生成简单的检查清单 |
| 错误: 停止执行,修复问题后重新检查再继续 |
| PR创建前测试失败 | 阻止PR创建,报告失败情况 |
| 分支已存在 | 询问: 切换到该分支或创建新分支 |
| 处于受保护分支(main/master/develop) | 🚨 阻塞: 立即停止执行,要求使用功能分支 |
| 工作流/规则文件不在预期路径 | 搜索替代路径后再声明缺失 |
Usage Examples
使用示例
undefinedundefinedFull implementation from spec
从规范文件完整实现
"Implement from spec for auth-feature"
「auth-featureの仕様書から実装して」
"Implement from spec for auth-feature"
「auth-featureの仕様書から実装して」
With issue number
指定Issue编号
"Implement spec --issue 42"
「Issue #42の仕様を実装して」
"Implement spec --issue 42"
「Issue #42の仕様を実装して」
Resume after interruption
中断后恢复
"Resume implementation --resume --spec .specs/auth-feature/"
「実装を再開 --resume」
"Resume implementation --resume --spec .specs/auth-feature/"
「実装を再開 --resume」
Dry run to preview plan
试运行预览计划
"Show implementation plan --dry-run --spec .specs/auth-feature/"
「実装計画を表示 --dry-run」
"Show implementation plan --dry-run --spec .specs/auth-feature/"
「実装計画を表示 --dry-run」
Force parallel mode (runtime-aware)
强制并行模式(运行时感知)
"Implement from spec --spec .specs/auth-feature/ --parallel"
「仕様書から並列実行で実装 --parallel」
"Implement from spec --spec .specs/auth-feature/ --parallel"
「仕様書から並列実行で実装 --parallel」
Minimal mode (no specs)
最小化模式(无规范文件)
"Implement issue 42"
「Issue 42を実装して」
undefined"Implement issue 42"
「Issue 42を実装して」
undefinedPost-Completion Actions
完成后操作
After PR is created:
AskUserQuestion:
question: "PR created. What's next?" / "PRを作成しました。次は?"
options:
- "Monitor CI status" / "CIステータスを監視"
- "Review the PR diff" / "PR差分を確認"
- "Done" / "完了"PR创建后:
AskUserQuestion:
question: "PR created. What's next?" / "PRを作成しました。次は?"
options:
- "Monitor CI status" / "CIステータスを監視"
- "Review the PR diff" / "PR差分を確認"
- "Done" / "完了"