spec-implement

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

spec-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

语言规则

  1. Auto-detect input language → output in the same language
  2. Japanese input → Japanese output, use
    references/implement-guide.ja.md
  3. English input → English output, use
    references/implement-guide.md
  4. Explicit override takes priority (e.g., "in English", "日本語で")
  1. 自动检测输入语言 → 输出与输入语言一致
  2. 日文输入 → 日文输出,使用
    references/implement-guide.ja.md
  3. 英文输入 → 英文输出,使用
    references/implement-guide.md
  4. 显式覆盖指令优先(例如:"in English"、"日本語で")

Critical First Steps

关键前置步骤

BEFORE any implementation, execute these checks in order:
  1. Verify environment:
    • Run
      pwd
      to confirm working directory
    • Run
      git status
      to confirm inside a git repository
    • Run
      gh auth status
      to confirm GitHub CLI access
  2. Parse user input for options:
    • --resume
      → resume from last uncompleted task
    • --issue {N}
      → specify GitHub Issue number
    • --spec {path}
      → specify
      .specs/
      directory path
    • --dry-run
      → show execution plan without making changes
    • --parallel
      → force parallel execution if environment is ready
    • --no-parallel
      → force sequential execution
  3. Locate spec directory:
    • If
      --spec
      provided → use that path
    • If issue body contains
      .specs/
      path → use that
    • Otherwise → scan
      .specs/
      and ask user to select:
      AskUserQuestion:
        question: "Which spec to implement?" / "どの仕様書を実装しますか?"
        options: [list discovered .specs/ directories]
  4. Locate and read project files (in this order):
    Workflow playbook — search in order, use first found:
    1. docs/development/issue-to-pr-workflow.md
    2. docs/issue-to-pr-workflow.md
    3. 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
    4. If not found → trigger fallback (see Phase 1)
    Coding rules — search in order, use first found:
    1. docs/development/coding-rules.md
    2. docs/coding-rules.md
    3. Fallback:
      find . -name "coding-rules.md" -not -path "*/node_modules/*" -not -path "*/.git/*" -not -path "*/vendor/*" -not -path "*/dist/*" -not -path "*/build/*" | head -1
    4. If not found → trigger fallback (see Phase 2)
    Project instruction files — read all that exist:
    • CLAUDE.md
      (project root)
    • src/CLAUDE.md
      (source-level rules)
    • test/CLAUDE.md
      (test-level rules)
    • AGENTS.md
      (agent definitions)
    Spec files:
    • .specs/{feature}/requirement.md
      → what to build
    • .specs/{feature}/design.md
      → how to build it
    • .specs/{feature}/tasks.md
      → task breakdown with checkboxes
  5. 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
    • 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:
        .codex/config.toml
        has
        [features] multi_agent = true
        and
        agents.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
        )
    • If any required condition is missing, continue in sequential mode
在开始任何实现之前,按顺序执行以下检查:
  1. 验证环境:
    • 运行
      pwd
      确认工作目录
    • 运行
      git status
      确认处于git仓库内
    • 运行
      gh auth status
      确认GitHub CLI已授权
  2. 解析用户输入的选项:
    • --resume
      → 从最后一个未完成的任务恢复执行
    • --issue {N}
      → 指定GitHub Issue编号
    • --spec {path}
      → 指定
      .specs/
      目录路径
    • --dry-run
      → 显示执行计划但不进行实际修改
    • --parallel
      → 若环境就绪则强制并行执行
    • --no-parallel
      → 强制串行执行
  3. 定位规范目录:
    • 若提供
      --spec
      参数 → 使用指定路径
    • 若Issue正文中包含
      .specs/
      路径 → 使用该路径
    • 否则 → 扫描
      .specs/
      并让用户选择:
      AskUserQuestion:
        question: "Which spec to implement?" / "どの仕様書を実装しますか?"
        options: [list discovered .specs/ directories]
  4. 定位并读取项目文件(按以下顺序):
    工作流手册 — 按顺序搜索,使用第一个找到的文件:
    1. docs/development/issue-to-pr-workflow.md
    2. docs/issue-to-pr-workflow.md
    3. 备选方案:
      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
    4. 若未找到 → 触发备选流程(见阶段1)
    编码规则 — 按顺序搜索,使用第一个找到的文件:
    1. docs/development/coding-rules.md
    2. docs/coding-rules.md
    3. 备选方案:
      find . -name "coding-rules.md" -not -path "*/node_modules/*" -not -path "*/.git/*" -not -path "*/vendor/*" -not -path "*/dist/*" -not -path "*/build/*" | head -1
    4. 若未找到 → 触发备选流程(见阶段2)
    项目指令文件 — 读取所有存在的文件:
    • CLAUDE.md
      (项目根目录)
    • src/CLAUDE.md
      (源码级规则)
    • test/CLAUDE.md
      (测试级规则)
    • AGENTS.md
      (Agent定义)
    规范文件:
    • .specs/{feature}/requirement.md
      → 实现目标
    • .specs/{feature}/design.md
      → 实现方案
    • .specs/{feature}/tasks.md
      → 带复选框的任务分解
  5. 检测支持并行的Agent环境(运行时感知):
    • 从当前执行环境确定活跃运行时(请勿仅通过仓库目录推断运行时)
    • 仅使用仓库文件验证运行时配置:
      • Codex验证:
        .codex/config.toml
      • Claude Code验证:
        .claude/agents/workflow-*.md
    • 若无法确定运行时,询问用户选择运行时
    • 检查工作流是否包含并行章节(
      Parallel Execution Strategy
      /
      Agent Roles
    • 解析可选的工作流章节以获取显式Agent文件路径:
      • Agent definition files:
        /
        エージェント定義ファイル:
      • 从列表项中提取实现者/审核者/测试者的路径
      • 将提取的路径作为验证和调度上下文的第一优先级
      • 若该章节不存在,回退到运行时默认值
    • 验证运行时特定的子Agent设置:
      • Codex:
        .codex/config.toml
        中包含
        [features] multi_agent = true
        agents.workflow-*
      • Claude Code: 工作流章节中的Agent文件存在;若不存在,使用默认文件(
        .claude/agents/workflow-implementer.md
        ,
        .claude/agents/workflow-reviewer.md
        ,
        .claude/agents/workflow-tester.md
    • 若任何必要条件缺失,继续使用串行模式

Execution Flow

执行流程

Phase 1: Workflow Loading

阶段1: 工作流加载

Read the workflow file (located in Step 4) and interpret each section as instructions to follow:
Workflow SectionAction
Development EnvironmentExtract setup commands, environment variables
Issue Analysis and SetupFollow branch naming convention, issue reading steps
Branch Strategy / PR TargetExtract base branch (e.g.,
develop
,
main
) and PR target branch
Phased ImplementationFollow implementation order and guidelines
Agent Roles / Sub-agentsExtract agent role definitions (if present)
Agent Definition Files (Optional)Extract explicit sub-agent definition file paths
TestingExtract test commands and coverage thresholds
PR Creation and Quality GatesExtract pre-PR checks and PR template
CI/CD MonitoringExtract CI verification commands
Commit Message RulesExtract commit message format and language requirements
Follow sections top-to-bottom. Replace
{variable}
placeholders with actual values (issue number, branch name, etc.). Treat "MUST" and "required" keywords as mandatory; treat "optional" and "if applicable" as conditional.
Base branch detection — determine
{base_branch}
from the workflow:
  1. Look for "branch strategy", "base branch", "PR target", "develop", "main" in the workflow
  2. If the workflow specifies a branch (e.g.,
    develop
    ), use it as
    {base_branch}
  3. 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
main
as
{base_branch}
.
读取步骤4中找到的工作流文件,并将每个章节解释为执行指令:
工作流章节操作
Development Environment提取设置命令、环境变量
Issue Analysis and Setup遵循分支命名规范、Issue读取步骤
Branch Strategy / PR Target提取基础分支(例如:
develop
,
main
)和PR目标分支
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提取提交消息格式和语言要求
按从上到下的顺序遵循章节内容。
{variable}
占位符替换为实际值(Issue编号、分支名称等)。将"MUST"和"required"关键字视为强制性要求;将"optional"和"if applicable"视为条件性要求。
基础分支检测 — 从工作流中确定
{base_branch}
:
  1. 在工作流中查找"branch strategy"、"base branch"、"PR target"、"develop"、"main"
  2. 若工作流指定了分支(例如:
    develop
    ),将其用作
    {base_branch}
  3. 默认回退值:
    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:
  1. Workflow includes a parallel section with role assignment
  2. Runtime-specific sub-agent configuration is valid
  3. User did not pass
    --no-parallel
    (or explicitly passed
    --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:
    .codex/config.toml
    with
    multi_agent = true
    and
    agents.workflow-*
  • Agent definition file paths:
    • First priority: paths declared in workflow
      Agent definition files
      section
    • Fallback: runtime defaults (from
      .codex/agents/
      conventions)
  • 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
      Agent definition files
      section
    • Fallback defaults:
      .claude/agents/workflow-implementer.md
      ,
      .claude/agents/workflow-reviewer.md
      ,
      .claude/agents/workflow-tester.md
  • Dispatch format: use Claude Code sub-agent call format with
    subagent_type
    set to workflow agent names (
    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.
仅当以下所有条件满足时,启用并行模式:
  1. 工作流包含带角色分配的并行章节
  2. 运行时特定的子Agent配置有效
  3. 用户未传递
    --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 = true
    agents.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调用格式,
    subagent_type
    设置为工作流Agent名称(
    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.md
,
src/CLAUDE.md
,
test/CLAUDE.md
,
AGENTS.md
).
These files contain project-specific conditional rules, environment constraints, and coding conventions. Apply them with the same enforcement level as
[MUST]
rules from coding-rules.md:
  • 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.md
,
src/CLAUDE.md
,
test/CLAUDE.md
,
AGENTS.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
--issue {N}
is provided or an issue number is found in context:
bash
gh issue view {N} --json title,body,labels,assignees
Extract from the issue:
  • Feature overview and requirements
  • Spec directory path (if referenced)
  • Phase/task checklists
  • Assignees and labels
若提供
--issue {N}
参数或在上下文中找到Issue编号:
bash
gh issue view {N} --json title,body,labels,assignees
从Issue中提取:
  • 功能概述和需求
  • 规范目录路径(若有引用)
  • 阶段/任务检查清单
  • 被分配人和标签

Phase 5: Branch Creation

阶段5: 分支创建

🚨 BLOCKING GATE — Feature branch is MANDATORY
Implementation MUST NOT proceed on
main
,
master
, or
develop
branches. This gate cannot be skipped. Violation = immediate stop.
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
{base_branch}
is the branch detected in Phase 1 (default:
main
).
Protected branch list — by default:
main
,
master
,
develop
. If the workflow file defines a "protected branches" or "branch protection" section, use that list instead.
If
--resume
is active and the branch already exists, switch to it instead.
Post-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
fi
This 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}
其中
{base_branch}
是阶段1中检测到的分支(默认:
main
)。
受保护分支列表 — 默认值:
main
,
master
,
develop
。 若工作流文件定义了"protected branches"或"branch protection"章节,使用该列表替代默认值。
--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:
  1. 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
  2. Parse the Role Assignment Table — find the Markdown table with columns like
    Role | Agent | Responsibility
    :
    • Extract each row's
      Agent
      column value → use as runtime sub-agent identifier (
      subagent_type
      )
    • Extract each row's
      Responsibility
      column value → use as context in the task prompt
  3. 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)
  4. 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)" / "シングルエージェント(順次)"
  5. If sub-agents selected, branch by runtime:
    • Codex runtime: spawn agents via Codex Task dispatch using parsed
      Agent
      names as
      subagent_type
    • Claude Code runtime: spawn agents via Claude Code sub-agent dispatch using parsed
      Agent
      names as
      subagent_type
    • Execute phases per strategy table (same-row roles run in parallel)
  6. 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.md
design.md
tasks.md
For each unchecked task in
tasks.md
:
1. 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:
feat: {task-id} complete — {brief description}
. See reference guide for details.
No specs fallback: If
.specs/
is missing, use Issue body as guide and generate a simple checklist. See reference guide for details.
循环前: Agent角色检测
若工作流文件包含"Agent Roles"、"Sub-agents"或"エージェントロール"章节:
  1. 解析显式Agent文件路径(若存在):
    • 读取工作流章节
      Agent definition files:
      /
      エージェント定義ファイル:
    • 构建角色→定义文件路径的映射(实现者/审核者/测试者)
    • 若该章节不存在,使用运行时默认值
  2. 解析角色分配表 — 查找包含
    Role | Agent | Responsibility
    等列的Markdown表:
    • 提取每行的
      Agent
      列值 → 用作运行时子Agent标识符(
      subagent_type
    • 提取每行的
      Responsibility
      列值 → 用作任务提示中的上下文
  3. 解析并行执行策略表(若存在) — 查找包含阶段行和角色列的表:
    • 每行 = 一个阶段(从上到下串行执行)
    • 包含
      -
      的单元格 = 该角色在该阶段空闲
    • -
      的单元格 = 角色的操作(同一行中的角色并行运行)
  4. 向用户呈现选项:
    AskUserQuestion:
      question: "Workflow defines agent roles. Use sub-agents for parallel execution?" /
                "ワークフローにエージェントロールが定義されています。サブエージェントで並列実行しますか?"
      options:
        - "Use sub-agents (parallel)" / "サブエージェント使用(並列)"
        - "Single agent (sequential)" / "シングルエージェント(順次)"
  5. 若选择使用子Agent,按运行时分支处理:
    • Codex运行时: 使用解析的
      Agent
      名称作为
      subagent_type
      ,通过Codex Task调度生成Agent
    • Claude Code运行时: 使用解析的
      Agent
      名称作为
      subagent_type
      ,通过Claude Code子Agent调度生成Agent
    • 按策略表执行阶段(同一行的角色并行运行)
  6. 若选择单Agent: 继续以下串行执行
有关表格式示例和运行时特定子Agent调用模式,请参阅参考指南。
按顺序读取规范文件:
requirement.md
design.md
tasks.md
针对
tasks.md
中的每个未勾选任务:
1. 读取任务详情(需求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}
。详情请参阅参考指南。
无规范文件备选方案:
.specs/
缺失,使用Issue正文作为指南并生成简单的检查清单。详情请参阅参考指南。

Phase 7: Final Quality Gate

阶段7: 最终质量关卡

After all tasks are complete:
  1. Run test commands from the workflow (or language-appropriate default)
  2. Run lint/typecheck commands from the workflow (if specified)
  3. Verify all
    [MUST]
    rules from coding-rules.md pass
  4. Verify all CLAUDE.md conditional rules pass
  5. If any check fails → fix → recheck
  6. All checks pass → proceed to PR creation
所有任务完成后:
  1. 运行工作流中的测试命令(或语言对应的默认命令)
  2. 运行工作流中的 lint/类型检查命令(若指定)
  3. 验证coding-rules.md中的所有
    [MUST]
    规则均通过
  4. 验证CLAUDE.md中的所有条件规则均通过
  5. 若任何检查失败 → 修复问题 → 重新检查
  6. 所有检查通过 → 进入PR创建阶段

Phase 8: PR Creation

阶段8: PR创建

Follow the workflow's PR template. Use
{base_branch}
detected in Phase 1:
bash
gh pr create \
  --title "{type}: {description} (closes #{N})" \
  --body "{PR body following workflow template}" \
  --base {base_branch}
Where
{base_branch}
comes from Phase 1 workflow detection (default:
main
).
Verify
--base {base_branch}
matches the workflow's branch strategy before creating the PR.
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}
其中
{base_branch}
来自阶段1的工作流检测(默认:
main
)。
创建PR前,验证
--base {base_branch}
是否与工作流的分支策略匹配。
安全防护:
  • 若测试失败,请勿创建PR
  • 请勿强制推送
  • 请勿直接推送到main/master分支
  • 请勿指定错误的基础分支(需与工作流验证)
  • 进行大规模代码删除前需询问用户确认
PR创建后,若工作流指定了CI验证命令,监控CI状态。

Options

选项

OptionDescription
--resume
Resume from last uncompleted task in tasks.md
--issue {N}
Specify GitHub Issue number for context
--spec {path}
Specify .specs/ directory path (default: auto-detect)
--dry-run
Show execution plan without making any changes (output format: see reference guide)
--parallel
Force parallel mode (requires valid runtime sub-agent setup for Codex or Claude Code)
--no-parallel
Disable parallel mode and run sequentially
选项描述
--resume
从tasks.md中最后一个未完成的任务恢复执行
--issue {N}
指定用于上下文的GitHub Issue编号
--spec {path}
指定.specs/目录路径(默认: 自动检测)
--dry-run
显示执行计划但不进行任何修改(输出格式: 请参阅参考指南)
--parallel
强制并行模式(需要Codex或Claude Code的有效运行时子Agent设置)
--no-parallel
禁用并行模式并串行运行

Error Handling

错误处理

SituationResponse
Not a git repositoryError: "Must be in a git repository" / "gitリポジトリ内で実行してください"
gh
CLI not available
Error: guide user to install/authenticate gh CLI
.specs/
not found
Warning: switch to Issue-only minimal mode
Parallel requested but runtime sub-agent config missing/invalidWarning: explain missing setup, fallback to sequential mode
Workflow-declared agent definition file path does not existWarning: explain missing file path, fallback to sequential mode
Workflow references sub-agent names that are not configured in selected runtimeWarning: explain missing agent definitions, fallback to sequential mode
Parallel file edit collisionWarning: stop parallel for current task, continue sequentially
requirement.md
missing
Warning: use Issue body as requirements source
tasks.md
missing
Warning: generate simple checklist from Issue
[MUST]
rule violation
Error: stop, fix, recheck before continuing
Tests failing before PRBlock PR creation, report failures
Branch already existsAsk: switch to it or create new
On protected branch (main/master/develop)🚨 BLOCKING: stop immediately, require feature branch
Workflow/rules file not at expected pathSearch alternate paths before declaring missing
场景响应
非git仓库错误: "Must be in a git repository" / "gitリポジトリ内で実行してください"
gh
CLI不可用
错误: 指导用户安装/授权gh CLI
.specs/
未找到
警告: 切换到仅Issue的最小化模式
请求并行但运行时子Agent配置缺失/无效警告: 说明缺失的设置,回退到串行模式
工作流声明的Agent定义文件路径不存在警告: 说明缺失的文件路径,回退到串行模式
工作流引用的子Agent名称在所选运行时中未配置警告: 说明缺失的Agent定义,回退到串行模式
并行文件编辑冲突警告: 停止当前任务的并行执行继续串行执行
requirement.md
缺失
警告: 使用Issue正文作为需求来源
tasks.md
缺失
警告: 从Issue生成简单的检查清单
[MUST]
规则违反
错误: 停止执行,修复问题后重新检查再继续
PR创建前测试失败阻止PR创建,报告失败情况
分支已存在询问: 切换到该分支或创建新分支
处于受保护分支(main/master/develop)🚨 阻塞: 立即停止执行,要求使用功能分支
工作流/规则文件不在预期路径搜索替代路径后再声明缺失

Usage Examples

使用示例

undefined
undefined

Full 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を実装して」
undefined

Post-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" / "完了"