Dev Workflow — Orchestrated Coding Agent Dispatch
Structured 6-phase gated workflow for driving coding agents to implement requirements with quality control.
Prerequisites
- - Claude Code (
claude CLI) installed with INLINECODE1 - cc-plugin installed in Claude Code (provides llmdoc read/write, investigator/scout/recorder sub-agents)
- Global
~/.claude/CLAUDE.md configured with cc-plugin settings
Workflow Overview
CODEBLOCK0
Each phase must complete before moving to the next. Phase 2 and Phase 3 have explicit user confirmation gates.
Phase 1: Environment Check
Before any work, check the target project:
- 1.
llmdoc/ exists?
- Yes → read
llmdoc/index.md + overview files to understand project
- No → dispatch Claude Code with
/tr:initDoc to generate it first
- 2.
CLAUDE.md in project root? — verify cc-plugin config is present; fix if missing git status — ensure working tree is clean enough to work on
Phase 2: Spec
Generate a structured implementation spec using the spec-writer skill.
- 1. Activate
spec-writer skill — read its SKILL.md and follow its workflow - It will gather project context, draft a spec using its template, and present to the user
- The spec covers: objectives, user stories, technical plan, boundaries, verification criteria, and a preliminary task breakdown
- 🚫 Gate: Do not proceed until the user confirms the spec.
The confirmed spec replaces the old requirement-doc + verification-doc pair — everything is in one document now.
Fallback: If spec-writer skill is not installed, use the templates in references/ (requirement-template.md + verification-template.md) as before.
Phase 3: Task Planning
Refine the spec's preliminary task breakdown into a precise, executable task list. This is the bridge between "what to build" and "how to tell the agent."
3.1 Extract Tasks from Spec
Start from Section 10 (Task Breakdown) of the confirmed spec. For each task, expand it into a Task Card:
CODEBLOCK1
3.2 Scoping Rules
Each task should be:
- - Independently implementable — an agent can complete it without context from other incomplete tasks
- Independently verifiable — there is a concrete way to check it worked (test passes, endpoint responds, file exists)
- Small enough to review — aim for changes reviewable in one pass (rough guide: <300 lines changed)
- Large enough to be meaningful — don't split a 20-line function into 3 tasks
Splitting heuristics:
- - If a task touches >3 unrelated modules → split by module
- If a task has both "create infrastructure" and "implement logic" → split
- If a task requires multiple design decisions → split by decision boundary
- If you can describe two independent verification criteria → likely two tasks
3.3 Dependency Graph
After expanding all tasks, produce a dependency summary:
CODEBLOCK2
Identify:
- - Critical path — longest chain of dependent tasks
- Parallel groups — tasks that can run simultaneously
- Execution order — the sequence to dispatch agents
3.4 Context Budgeting
For each task, determine what context the agent needs:
- - Spec sections to include — only the relevant parts, not the full spec (avoid context overload)
- Existing code to reference — specific files, not "the whole src/"
- Boundaries to emphasize — the ✅/⚠️/🚫 rules most relevant to this task
Principle: feed the agent only what it needs for the current task. A well-fed agent is like a well-fed function — give it only the inputs for the job at hand.
3.5 User Confirmation
Present the task list to the user with:
- - All task cards (or a summary table + full cards on request)
- Dependency graph
- Estimated execution order (serial vs parallel)
- Highlight the critical path
🚫 Gate: Do not dispatch any agents until the user confirms the task plan.
Common discussion points:
- - Is the granularity right? (too fine → overhead; too coarse → risky)
- Are dependencies correct? Can anything be parallelized further?
- Any task missing from the spec's intent?
Phase 4: Agent Dispatch
Execute the confirmed task plan by dispatching coding agents.
4.1 Prompt Construction
For each task, construct the agent prompt from the task card:
CODEBLOCK3
Task prompt structure:
CODEBLOCK4
Use workdir to scope the agent to the project directory.
Use background: true for long-running tasks, monitor with process tool.
4.2 Execution Strategy
- - Serial tasks (has dependencies): wait for dependency to complete and verify before dispatching
- Parallel tasks (independent): dispatch simultaneously, use git worktrees if touching overlapping files
- After each task completes:
1. Check agent output for errors
2. Run the task's verification criteria
3. If verification fails → re-prompt the agent with the failure details (up to 2 retries)
4. If still fails → stop and report to user
4.3 Error Handling
| Situation | Action |
|---|
| Small error (syntax, typo, missing import) | Re-prompt agent to fix, no user interruption |
| Test failure on the current task |
Re-prompt with test output, up to 2 retries |
| Design-level issue or ambiguity |
Stop and ask the user |
| Agent produces output that contradicts spec | Stop, quote the spec conflict, ask user |
| Downstream task blocked by upstream failure | Pause dependent tasks, attempt to fix upstream first |
Phase 5: Verification
After all tasks complete, verify the whole against the spec's verification criteria (Section 9):
- 1. Automated checks (§9.1) — run tests, build, lint, type check
- Functional verification (§9.2) — execute each test scenario step by step
- Edge cases & error handling (§9.3) — verify each edge case
- Regression (§9.4) — confirm existing functionality unaffected
- Code quality — style consistency, no stray files, no hardcoded secrets
If any verification fails:
- - Identify which task(s) caused the issue
- Re-dispatch agent to fix, providing the failure context
- Re-verify after fix
Phase 6: Delivery
Present results to the user with:
- 1. All changed files — every file touched, including llmdoc updates, config changes, everything
- Suggested commit message — conventional commits format
- Task completion summary — which tasks passed, any retries needed
- Verification results — what passed, any caveats
- Items for human review — what needs the user's attention
Never commit. The user handles all git commits.
Agent Selection
Default: Claude Code (claude --permission-mode bypassPermissions --print)
| Agent | Use when |
|---|
| Claude Code | Default for all tasks; complex reasoning, architecture |
| Codex |
User explicitly requests; batch/parallel tasks (
pty:true,
--full-auto) |
| OpenCode/Pi | User explicitly requests |
Key Constraints
- - Never commit — code changes only, user commits
- Never run agents in
~/.openclaw/ — agents will read soul/identity files - Always update llmdoc — every agent run should end with doc update
- Always list all changed files on delivery
- Always provide commit message on delivery
- Interrupt on design issues — don't let agents drift on wrong assumptions
- Feed minimal context — each agent gets only spec sections and files relevant to its task
开发工作流 — 编排式编码代理调度
结构化的六阶段门控工作流,用于驱动编码代理实现带有质量控制的开发需求。
前置条件
- - 已安装 Claude Code(claude CLI),并配置 --permission-mode bypassPermissions --print 参数
- 在 Claude Code 中安装 cc-plugin(提供 llmdoc 读写、investigator/scout/recorder 子代理功能)
- 全局 ~/.claude/CLAUDE.md 已配置 cc-plugin 设置
工作流概览
阶段 1:环境检查
↓
阶段 2:规格说明 ← 规格编写技能
↓ [用户确认]
阶段 3:任务规划
↓ [用户确认]
阶段 4:代理调度
↓
阶段 5:验证
↓
阶段 6:交付
每个阶段必须完成后才能进入下一阶段。阶段 2 和阶段 3 设有明确的用户确认门控。
阶段 1:环境检查
开始任何工作前,检查目标项目:
- 1. llmdoc/ 是否存在?
- 是 → 读取 llmdoc/index.md 及概览文件以了解项目
- 否 → 调度 Claude Code 使用 /tr:initDoc 先生成
- 2. 项目根目录下是否存在 CLAUDE.md? — 验证 cc-plugin 配置是否存在;缺失则修复
- git status — 确保工作树足够干净以开展工作
阶段 2:规格说明
使用 规格编写 技能生成结构化的实现规格说明。
- 1. 激活 spec-writer 技能 — 读取其 SKILL.md 并遵循其工作流
- 它将收集项目上下文,使用其模板起草规格说明,并呈现给用户
- 规格说明涵盖:目标、用户故事、技术方案、边界条件、验证标准以及初步任务分解
- 🚫 门控:在用户确认规格说明前不得继续。
确认后的规格说明将取代旧的 需求文档 + 验证文档 组合 — 现在所有内容都在一个文档中。
备用方案: 如果未安装规格编写技能,则使用 references/ 中的模板(requirement-template.md + verification-template.md),与之前相同。
阶段 3:任务规划
将规格说明中的初步任务分解细化为一组精确、可执行的任务列表。这是构建什么与如何告诉代理之间的桥梁。
3.1 从规格说明中提取任务
从已确认规格说明的第 10 节(任务分解)开始。对每个任务,将其扩展为一张 任务卡片:
markdown
任务 [#]:[标题]
目标: 此任务完成什么(一句话)
输入: 此任务开始前必须存在的内容(来自前置任务的文件、表、API)
输出: 此任务产生的内容(新建/修改的文件、通过的测试、可用的端点)
受影响的文件:
- - src/xxx.py — 创建 / 修改
- tests/test_xxx.py — 创建
代理指令:
- - [具体、可操作的指令 1]
- [具体、可操作的指令 2]
- 参考:[相关规格说明章节,例如参见规格说明 §4.2 了解设计决策]
验证:
- - [ ] [如何确认此任务完成 — 命令、测试、可观察的结果]
依赖: 任务 #X, #Y(或无)
复杂度: 低 / 中 / 高
可并行: 可与任务 #Z 并行执行(或否)
3.2 范围界定规则
每个任务应满足:
- - 可独立实现 — 代理无需其他未完成任务上下文即可完成
- 可独立验证 — 有具体方法检查其是否生效(测试通过、端点响应、文件存在)
- 足够小以便审查 — 目标是一次审查即可完成的变更(粗略指南:<300 行变更)
- 足够大以保证有意义 — 不要将一个 20 行的函数拆分为 3 个任务
拆分启发式规则:
- - 如果任务涉及超过 3 个不相关模块 → 按模块拆分
- 如果任务同时包含创建基础设施和实现逻辑 → 拆分
- 如果任务需要多个设计决策 → 按决策边界拆分
- 如果可以描述两个独立的验证标准 → 很可能是两个任务
3.3 依赖关系图
扩展所有任务后,生成依赖关系摘要:
任务 1(低) ─┐
任务 3(低) ─┤─→ 任务 5(中) ─→ 任务 7(中)
任务 2(中) ─→ 任务 4(中) ─┤
任务 6(高) ────────────────────────┘─→ 任务 8(中)
识别:
- - 关键路径 — 最长的依赖任务链
- 并行组 — 可同时运行的任务
- 执行顺序 — 调度代理的序列
3.4 上下文预算
对每个任务,确定代理所需的上下文:
- - 需包含的规格说明章节 — 仅相关部分,而非完整规格说明(避免上下文过载)
- 需引用的现有代码 — 特定文件,而非整个 src/
- 需强调的边界条件 — 与此任务最相关的 ✅/⚠️/🚫 规则
原则:只给代理提供当前任务所需的内容。一个喂饱的代理就像一个喂饱的函数——只给它当前工作所需的输入。
3.5 用户确认
向用户呈现任务列表,包含:
- - 所有任务卡片(或摘要表格 + 按需提供完整卡片)
- 依赖关系图
- 预估执行顺序(串行 vs 并行)
- 突出关键路径
🚫 门控:在用户确认任务计划前不得调度任何代理。
常见讨论点:
- - 粒度是否合适?(过细 → 开销大;过粗 → 风险高)
- 依赖关系是否正确?是否可以进一步并行化?
- 是否有规格说明意图中遗漏的任务?
阶段 4:代理调度
通过调度编码代理执行已确认的任务计划。
4.1 提示词构建
对每个任务,从任务卡片构建代理提示词:
bash
claude --permission-mode bypassPermissions --print <任务提示词> 2>&1
任务提示词结构:
任务:[标题]
目标
[来自任务卡片]
上下文
[相关规格说明章节 — 仅复制所需部分]
[相关现有代码片段或文件引用]
指令
[来自任务卡片的代理指令]
约束条件
- - 不要 git commit
- 完成后执行 /update-doc 更新 llmdoc
- [来自规格说明 §7 的相关边界条件]
验证
完成后确认:
使用 workdir 将代理限定在项目目录范围内。
对长时间运行的任务使用 background: true,通过 process 工具监控。
4.2 执行策略
- - 串行任务(有依赖关系):等待依赖任务完成并验证后再调度
- 并行任务(独立任务):同时调度,如果涉及重叠文件则使用 git worktrees
- 每个任务完成后:
1. 检查代理输出是否有错误
2. 运行任务的验证标准
3. 如果验证失败 → 将失败详情重新提示给代理(最多重试 2 次)
4. 如果仍然失败 → 停止并向用户报告
4.3 错误处理
| 情况 | 操作 |
|---|
| 小错误(语法、拼写、缺少导入) | 重新提示代理修复,无需中断用户 |
| 当前任务的测试失败 |
重新提示并提供测试输出,最多重试 2 次 |
| 设计层面的问题或歧义 |
停止并向用户询问 |
| 代理输出与规格说明矛盾 | 停止,引用规格说明冲突,向用户询问 |
| 下游任务因上游失败受阻 | 暂停依赖任务,先尝试修复上游 |
阶段 5:验证
所有任务完成后,对照规格说明的验证标准(第 9 节)进行整体验证:
- 1. 自动化检查(§9.1) — 运行测试、构建、代码检查、类型检查
- 功能验证(§9.2) — 逐步执行每个测试场景
- 边界情况与错误处理(§9.3) — 验证每个边界情况
- 回归测试(§9.4) — 确认现有功能不受影响
- 代码质量 — 风格一致性、无残留文件、无硬编码密钥
如果任何验证失败: