Files
everything-claude-code/docs/zh-CN/commands/multi-backend.md
konstapukarifastnetfi 36bec90d45 docs: align command docs with shipped behavior (#2169)
- multi-{plan,execute,backend,frontend,workflow}.md: add an in-file
  prerequisite note for the external ccg-workflow runtime. README.md already
  warns these commands need codeagent-wrapper and the .ccg prompt tree, but
  users meeting them via the installed slash commands never see the README;
  the commands-core module still installs all five by default
- quality-gate.md: describe what scripts/hooks/quality-gate.js actually does.
  The doc advertised '/quality-gate [path] [--fix] [--strict]' with lint/type
  checks, but the script reads the file path from hook stdin JSON, toggles
  behavior via ECC_QUALITY_GATE_FIX / ECC_QUALITY_GATE_STRICT env vars, and
  runs formatters only (Biome/Prettier, gofmt, ruff format)
- claude-devfleet SKILL.md: add a Setup section pointing at the DevFleet
  server repository (github.com/LEC-AI/claude-devfleet, already disclosed in
  mcp-configs/mcp-servers.json) plus the SECURITY.md port-verification note;
  the skill previously assumed a running instance with no way to obtain one
- regenerate docs/COMMAND-REGISTRY.json for the quality-gate description
2026-06-07 13:25:58 +08:00

165 lines
5.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 后端 - 后端导向开发
后端导向的工作流程(研究 → 构思 → 规划 → 执行 → 优化 → 评审),由 Codex 主导。
> **前提条件:** 此命令需要外部的 `ccg-workflow` 运行时,它**不**包含在基础 ECC 安装中。请运行 `npx ccg-workflow` 进行初始化,以配置此命令所依赖的 `~/.claude/bin/codeagent-wrapper` 和 `~/.claude/.ccg/prompts/*` 角色文件。没有该运行时,此命令将无法正常运行。
## 使用方法
```bash
/backend <backend task description>
```
## 上下文
* 后端任务:$ARGUMENTS
* Codex 主导Gemini 作为辅助参考
* 适用场景API 设计、算法实现、数据库优化、业务逻辑
## 你的角色
你是 **后端协调者**,为服务器端任务协调多模型协作(研究 → 构思 → 规划 → 执行 → 优化 → 评审)。
**协作模型**
* **Codex** 后端逻辑、算法(**后端权威,可信赖**
* **Gemini** 前端视角(**后端意见仅供参考**
* **Claude (自身)** 协调、规划、执行、交付
***
## 多模型调用规范
**调用语法**
```
# 新会话调用
Bash({
command: "~/.claude/bin/codeagent-wrapper {{LITE_MODE_FLAG}}--backend codex - \"$PWD\" <<'EOF'
ROLE_FILE: <角色提示路径>
<TASK>
需求: <增强后的需求(若未增强则为 $ARGUMENTS>
上下文: <来自先前阶段的项目上下文与分析>
</TASK>
OUTPUT: 期望的输出格式
EOF",
run_in_background: false,
timeout: 3600000,
description: "简要描述"
})
# 恢复会话调用
Bash({
command: "~/.claude/bin/codeagent-wrapper {{LITE_MODE_FLAG}}--backend codex resume <SESSION_ID> - \"$PWD\" <<'EOF'
ROLE_FILE: <角色提示路径>
<TASK>
需求: <增强后的需求(若未增强则为 $ARGUMENTS>
上下文: <来自先前阶段的项目上下文与分析>
</TASK>
OUTPUT: 期望的输出格式
EOF",
run_in_background: false,
timeout: 3600000,
description: "简要描述"
})
```
**角色提示词**
| 阶段 | Codex |
|-------|-------|
| 分析 | `~/.claude/.ccg/prompts/codex/analyzer.md` |
| 规划 | `~/.claude/.ccg/prompts/codex/architect.md` |
| 评审 | `~/.claude/.ccg/prompts/codex/reviewer.md` |
**会话复用**:每次调用返回 `SESSION_ID: xxx`,在后续阶段使用 `resume xxx`。在第 2 阶段保存 `CODEX_SESSION`,在第 3 和第 5 阶段使用 `resume`
***
## 沟通准则
1. 在回复开头使用模式标签 `[Mode: X]`,初始值为 `[Mode: Research]`
2. 遵循严格序列:`Research → Ideation → Plan → Execute → Optimize → Review`
3. 需要时(例如确认/选择/批准)使用 `AskUserQuestion` 工具进行用户交互
***
## 核心工作流程
### 阶段 0提示词增强可选
`[Mode: Prepare]` - 如果 ace-tool MCP 可用,调用 `mcp__ace-tool__enhance_prompt`**将原始的 $ARGUMENTS 替换为增强后的结果,用于后续的 Codex 调用**。如果不可用,则按原样使用 `$ARGUMENTS`
### 阶段 1研究
`[Mode: Research]` - 理解需求并收集上下文
1. **代码检索**(如果 ace-tool MCP 可用):调用 `mcp__ace-tool__search_context` 来检索现有的 API、数据模型、服务架构。如果不可用则使用内置工具`Glob` 用于文件发现,`Grep` 用于符号/API 搜索,`Read` 用于上下文收集,`Task`(探索代理)用于更深入的探索。
2. 需求完整性评分0-10>=7 继续,<7 停止并补充
### 阶段 2构思
`[Mode: Ideation]` - Codex 主导的分析
**必须调用 Codex**(遵循上述调用规范):
* ROLE\_FILE`~/.claude/.ccg/prompts/codex/analyzer.md`
* 需求:增强后的需求(或未增强时的 $ARGUMENTS
* 上下文:来自阶段 1 的项目上下文
* 输出:技术可行性分析、推荐解决方案(至少 2 个)、风险评估
**保存 SESSION\_ID**`CODEX_SESSION`)以供后续阶段复用。
输出解决方案(至少 2 个),等待用户选择。
### 阶段 3规划
`[Mode: Plan]` - Codex 主导的规划
**必须调用 Codex**(使用 `resume <CODEX_SESSION>` 以复用会话):
* ROLE\_FILE`~/.claude/.ccg/prompts/codex/architect.md`
* 需求:用户选择的解决方案
* 上下文:阶段 2 的分析结果
* 输出:文件结构、函数/类设计、依赖关系
Claude 综合规划,在用户批准后保存到 `.claude/plan/task-name.md`
### 阶段 4实施
`[Mode: Execute]` - 代码开发
* 严格遵循已批准的规划
* 遵循现有项目的代码规范
* 确保错误处理、安全性、性能优化
### 阶段 5优化
`[Mode: Optimize]` - Codex 主导的评审
**必须调用 Codex**(遵循上述调用规范):
* ROLE\_FILE`~/.claude/.ccg/prompts/codex/reviewer.md`
* 需求:评审以下后端代码变更
* 上下文git diff 或代码内容
* 输出安全性、性能、错误处理、API 合规性问题列表
整合评审反馈,在用户确认后执行优化。
### 阶段 6质量评审
`[Mode: Review]` - 最终评估
* 对照规划检查完成情况
* 运行测试以验证功能
* 报告问题和建议
***
## 关键规则
1. **Codex 的后端意见是可信赖的**
2. **Gemini 的后端意见仅供参考**
3. 外部模型**对文件系统零写入权限**
4. Claude 处理所有代码写入和文件操作