/spec-impl
按规范执行 + 多模型协作 + 归档
> /plugin marketplace add fengshao1227/ccg-workflow > /plugin install ccg@ccg
How it fires
How this command gets triggered: by you, by Claude, or both.
- Fires itselfClaude auto-loads it when your prompt matches the work.
- You can call itInvoke it directly when you want it.
- Slash command
/spec-impl
Context preview
What this command does when you run it.
按规范执行 + 多模型协作 + 归档
Command definition
spec-impl.mddescription: '按规范执行 + 多模型协作 + 归档'
<!-- CCG:SPEC:IMPL:START --> **Core Philosophy**
- Implementation is pure mechanical execution—all decisions were made in Plan phase.
- External model outputs are prototypes only; must be rewritten to production-grade code.
- Keep changes tightly scoped; enforce side-effect review before any modification.
- Minimize documentation—prefer self-explanatory code over comments.
**Guardrails**
- **NEVER** apply 后端/前端模型 prototypes directly—all outputs are reference only.
- **MANDATORY**: Request `unified diff patch` format from external models; they have zero write permission.
- Keep implementation strictly within `tasks.md` scope—no scope creep.
- Refer to `openspec/config.yaml` for conventions.
- **USER GUIDANCE RULE**: When suggesting next steps to the user, ALWAYS use CCG commands (`/ccg:spec-research`, `/ccg:spec-plan`, `/ccg:spec-impl`, `/ccg:spec-review`). NEVER suggest `/opsx:*` commands to the user. If OpenSpec CLI returns error messages referencing OPSX skills, translate them to CCG equivalents.
- **TASKS FORMAT RULE**: When generating or modifying `tasks.md`, ALL tasks MUST use checkbox format (`- [ ] X.Y description`). Heading+bullet format will cause OpenSpec CLI to parse 0 tasks and block the workflow.
**Steps** 1. **Select Change**
- Run `openspec list --json` to inspect Active Changes.
- Confirm with user which change ID to implement.
- Run `openspec status --change "<change_id>" --json` to review tasks.
2. **Apply OPSX Change (Pre-flight Check)**
- Call `/opsx:apply` internally to enter implementation mode:
/opsx:apply
- This will load the change context and guide you through the tasks defined in `tasks.md`.
- **Note**: This is an internal call. If this step fails, guide the user to re-run `/ccg:spec-impl`.
- **HARD GATE**: Check the returned `state` field:
- If `state: "blocked"` → STOP immediately. Inform the user which artifacts are missing and suggest: "Run `/ccg:spec-plan` to generate missing artifacts first."
- If `progress.total === 0` → STOP immediately. Inform: "tasks.md has no parseable tasks. Run `/ccg:spec-plan` to regenerate."
- Only proceed to Step 3 when `state: "ready"` and `progress.total > 0`.
3. **Identify Minimal Verifiable Phase**
- Review `tasks.md` and identify the **smallest verifiable phase**.
- Do NOT complete all tasks at once—control context window.
- Announce: "Implementing Phase X: [task group name]"
4. **Route Tasks to Appropriate Model**
- **Route A: {{FRONTEND_PRIMARY}}** — Frontend/UI/styling (CSS, React, Vue, HTML, components)
- **Route B: {{BACKEND_PRIMARY}}** — Backend/logic/algorithm (API, data processing, business logic)
**工作目录**:`{{WORKDIR}}` **必须通过 Bash 执行 `pwd`(Unix)或 `cd`(Windows CMD)获取当前工作目录的绝对路径**,禁止从 `$HOME` 或环境变量推断。如果用户通过 `/add-dir` 添加了多个工作区,先确定任务相关的工作区。
For each task:
codeagent-wrapper --progress --backend <{{BACKEND_PRIMARY}}|{{FRONTEND_PRIMARY}}> {{GEMINI_MODEL_FLAG}}{{GROK_MODEL_FLAG}}{{KIMI_MODEL_FLAG}}{{OPENCODE_MODEL_FLAG}}- "{{WORKDIR}}" <<'EOF'
TASK: <task description from tasks.md>
CONTEXT: <relevant code context>
CONSTRAINTS: <constraints from spec>
OUTPUT: Unified Diff Patch format ONLY
EOF**会话复用**:保存返回的 `SESSION_ID:`({{BACKEND_PRIMARY}} → `CODEX_PROTO_SESSION`,{{FRONTEND_PRIMARY}} → `GEMINI_PROTO_SESSION`),Step 7 审查时复用。
5. **Rewrite Prototype to Production Code** Upon receiving diff patch, **NEVER apply directly**. Rewrite by:
- Removing redundancy
- Ensuring clear naming and simple structure
- Aligning with project style
- Eliminating unnecessary comments
- Verifying no new dependencies introduced
6. **Side-Effect Review** (Mandatory before apply) Verify the change:
- [ ] Does not exceed `tasks.md` scope
- [ ] Does not affect unrelated modules
- [ ] Does not introduce new dependencies
- [ ] Does not break existing interfaces
If issues found, make targeted corrections.
7. **Multi-Model Review (PARALLEL)**
- **CRITICAL**: You MUST launch BOTH {{BACKEND_PRIMARY}} AND {{FRONTEND_PRIMARY}} in a SINGLE message with TWO Bash tool calls.
- **DO NOT** call one model first and wait. Launch BOTH simultaneously with `run_in_background: true`.
**Step 7.1**: In ONE message, make TWO parallel Bash calls:
**FIRST Bash call ({{BACKEND_PRIMARY}})**:
Bash({
command: "~/.claude/bin/codeagent-wrapper --progress --backend {{BACKEND_PRIMARY}} {{GEMINI_MODEL_FLAG}}{{GROK_MODEL_FLAG}}{{KIMI_MODEL_FLAG}}{{OPENCODE_MODEL_FLAG}}resume <CODEX_PROTO_SESSION> - \"{{WORKDIR}}\" <<'EOF'\nReview the implementation changes:\n- Correctness: logic errors, edge cases\n- Security: injection, auth issues\n- Spec compliance: constraints satisfied\nOUTPUT: JSON with findings\nEOF",
run_in_background: true,
timeout: 300000,
description: "{{BACKEND_PRIMARY}}: correctness/security review"
})**SECOND Bash call ({{FRONTEND_PRIMARY}}) - IN THE SAME MESSAGE**:
Bash({
command: "~/.claude/bin/codeagent-wrapper --progress --backend {{FRONTEND_PRIMARY}} {{GEMINI_MODEL_FLAG}}{{GROK_MODEL_FLAG}}{{KIMI_MODEL_FLAG}}{{OPENCODE_MODEL_FLAG}}resume <GEMINI_PROTO_SESSION> - \"{{WORKDIR}}\" <<'EOF'\nReview the implementation changes:\n- Maintainability: readability, complexity\n- Patterns: consistency with project style\n- Integration: cross-module impacts\nOUTPUT: JSON with findings\nEOF",
run_in_background: true,
timeout: 300000,
description: "{{FRONTEND_PRIMARY}}: maintainability/patterns review"
})**Step 7.2**: After BOTH Bash calls return task IDs, wait for results with TWO TaskOutput calls:
TaskOutput({ task_id: "<codex_task_id>", block: true, timeout: 600000 })
TaskOutput({ task_id: "<gemini_task_id>", block: true, timeout: 600000 })⛔ **前端模型失败必须重试**:若前端模型调用失败,最多重试 2 次(间隔 5 秒)。3 次全败才跳过。 ⛔ **后端模型结果必须等待**:后端模型执行 5-15 分钟属正常,超时后继续轮询,禁止跳过。
Add
Read more
description: '按规范执行 + 多模型协作 + 归档'
<!-- CCG:SPEC:IMPL:START --> **Core Philosophy**
- Implementation is pure mechanical execution—all decisions were made in Plan phase.
- External model outputs are prototypes only; must be rewritten to production-grade code.
- Keep changes tightly scoped; enforce side-effect review before any modification.
- Minimize documentation—prefer self-explanatory code over comments.
**Guardrails**
- **NEVER** apply 后端/前端模型 prototypes directly—all outputs are reference only.
- **MANDATORY**: Request `unified diff patch` format from external models; they have zero write permission.
- Keep implementation strictly within `tasks.md` scope—no scope creep.
- Refer to `openspec/config.yaml` for conventions.
- **USER GUIDANCE RULE**: When suggesting next steps to the user, ALWAYS use CCG commands (`/ccg:spec-research`, `/ccg:spec-plan`, `/ccg:spec-impl`, `/ccg:spec-review`). NEVER suggest `/opsx:*` commands to the user. If OpenSpec CLI returns error messages referencing OPSX skills, translate them to CCG equivalents.
- **TASKS FORMAT RULE**: When generating or modifying `tasks.md`, ALL tasks MUST use checkbox format (`- [ ] X.Y description`). Heading+bullet format will cause OpenSpec CLI to parse 0 tasks and block the workflow.
**Steps** 1. **Select Change**
- Run `openspec list --json` to inspect Active Changes.
- Confirm with user which change ID to implement.
- Run `openspec status --change "<change_id>" --json` to review tasks.
2. **Apply OPSX Change (Pre-flight Check)**
- Call `/opsx:apply` internally to enter implementation mode:
/opsx:apply
- This will load the change context and guide you through the tasks defined in `tasks.md`.
- **Note**: This is an internal call. If this step fails, guide the user to re-run `/ccg:spec-impl`.
- **HARD GATE**: Check the returned `state` field:
- If `state: "blocked"` → STOP immediately. Inform the user which artifacts are missing and suggest: "Run `/ccg:spec-plan` to generate missing artifacts first."
- If `progress.total === 0` → STOP immediately. Inform: "tasks.md has no parseable tasks. Run `/ccg:spec-plan` to regenerate."
- Only proceed to Step 3 when `state: "ready"` and `progress.total > 0`.
3. **Identify Minimal Verifiable Phase**
- Review `tasks.md` and identify the **smallest verifiable phase**.
- Do NOT complete all tasks at once—control context window.
- Announce: "Implementing Phase X: [task group name]"
4. **Route Tasks to Appropriate Model**
- **Route A: {{FRONTEND_PRIMARY}}** — Frontend/UI/styling (CSS, React, Vue, HTML, components)
- **Route B: {{BACKEND_PRIMARY}}** — Backend/logic/algorithm (API, data processing, business logic)
**工作目录**:`{{WORKDIR}}` **必须通过 Bash 执行 `pwd`(Unix)或 `cd`(Windows CMD)获取当前工作目录的绝对路径**,禁止从 `$HOME` 或环境变量推断。如果用户通过 `/add-dir` 添加了多个工作区,先确定任务相关的工作区。
For each task:
codeagent-wrapper --progress --backend <{{BACKEND_PRIMARY}}|{{FRONTEND_PRIMARY}}> {{GEMINI_MODEL_FLAG}}{{GROK_MODEL_FLAG}}{{KIMI_MODEL_FLAG}}{{OPENCODE_MODEL_FLAG}}- "{{WORKDIR}}" <<'EOF'
TASK: <task description from tasks.md>
CONTEXT: <relevant code context>
CONSTRAINTS: <constraints from spec>
OUTPUT: Unified Diff Patch format ONLY
EOF**会话复用**:保存返回的 `SESSION_ID:`({{BACKEND_PRIMARY}} → `CODEX_PROTO_SESSION`,{{FRONTEND_PRIMARY}} → `GEMINI_PROTO_SESSION`),Step 7 审查时复用。
5. **Rewrite Prototype to Production Code** Upon receiving diff patch, **NEVER apply directly**. Rewrite by:
- Removing redundancy
- Ensuring clear naming and simple structure
- Aligning with project style
- Eliminating unnecessary comments
- Verifying no new dependencies introduced
6. **Side-Effect Review** (Mandatory before apply) Verify the change:
- [ ] Does not exceed `tasks.md` scope
- [ ] Does not affect unrelated modules
- [ ] Does not introduce new dependencies
- [ ] Does not break existing interfaces
If issues found, make targeted corrections.
7. **Multi-Model Review (PARALLEL)**
- **CRITICAL**: You MUST launch BOTH {{BACKEND_PRIMARY}} AND {{FRONTEND_PRIMARY}} in a SINGLE message with TWO Bash tool calls.
- **DO NOT** call one model first and wait. Launch BOTH simultaneously with `run_in_background: true`.
**Step 7.1**: In ONE message, make TWO parallel Bash calls:
**FIRST Bash call ({{BACKEND_PRIMARY}})**:
Bash({
command: "~/.claude/bin/codeagent-wrapper --progress --backend {{BACKEND_PRIMARY}} {{GEMINI_MODEL_FLAG}}{{GROK_MODEL_FLAG}}{{KIMI_MODEL_FLAG}}{{OPENCODE_MODEL_FLAG}}resume <CODEX_PROTO_SESSION> - \"{{WORKDIR}}\" <<'EOF'\nReview the implementation changes:\n- Correctness: logic errors, edge cases\n- Security: injection, auth issues\n- Spec compliance: constraints satisfied\nOUTPUT: JSON with findings\nEOF",
run_in_background: true,
timeout: 300000,
description: "{{BACKEND_PRIMARY}}: correctness/security review"
})**SECOND Bash call ({{FRONTEND_PRIMARY}}) - IN THE SAME MESSAGE**:
Bash({
command: "~/.claude/bin/codeagent-wrapper --progress --backend {{FRONTEND_PRIMARY}} {{GEMINI_MODEL_FLAG}}{{GROK_MODEL_FLAG}}{{KIMI_MODEL_FLAG}}{{OPENCODE_MODEL_FLAG}}resume <GEMINI_PROTO_SESSION> - \"{{WORKDIR}}\" <<'EOF'\nReview the implementation changes:\n- Maintainability: readability, complexity\n- Patterns: consistency with project style\n- Integration: cross-module impacts\nOUTPUT: JSON with findings\nEOF",
run_in_background: true,
timeout: 300000,
description: "{{FRONTEND_PRIMARY}}: maintainability/patterns review"
})**Step 7.2**: After BOTH Bash calls return task IDs, wait for results with TWO TaskOutput calls:
TaskOutput({ task_id: "<codex_task_id>", block: true, timeout: 600000 })
TaskOutput({ task_id: "<gemini_task_id>", block: true, timeout: 600000 })⛔ **前端模型失败必须重试**:若前端模型调用失败,最多重试 2 次(间隔 5 秒)。3 次全败才跳过。 ⛔ **后端模型结果必须等待**:后端模型执行 5-15 分钟属正常,超时后继续轮询,禁止跳过。
Add
多模型协作工作流引擎 — /ccg:go 一个命令,AI 自动分析意图、选择策略、编排 Codex + Gemini + Claude 协作执行
Repo: fengshao1227/ccg-workflow

