Loading...
Loading...
Compare original and translation side by side
Agentpromptdescriptionsubagent_type"Explore""Plan""general-purpose"run_in_backgroundtruemodel"sonnet""opus""haiku"Agentrun_in_background=truesubagent_type"superpowers:code-reviewer"Agentpromptdescriptionsubagent_type"Explore""Plan""general-purpose"run_in_backgroundtruemodel"sonnet""opus""haiku"Agentrun_in_background=truesubagent_type"superpowers:code-reviewer"/decompose/decompose| Criterion | Question | If NO |
|---|---|---|
| No shared files | Do any two agents write to the same file? | Serialize those tasks |
| No shared mutable state | Does any agent depend on a side effect of another? | Serialize dependent tasks |
| Self-contained context | Can each agent work with only its own inputs? | Provide more context or serialize |
| Independent verification | Can each agent's output be validated alone? | Combine into single task |
| 标准 | 验证问题 | 不满足时处理 |
|---|---|---|
| 无共享文件 | 是否有两个Agent会写入同一个文件? | 串行执行这些任务 |
| 无共享可变状态 | 某个Agent是否依赖另一个Agent的副作用输出? | 串行执行存在依赖的任务 |
| 上下文自包含 | 每个Agent是否仅靠自身输入即可完成工作? | 提供更多上下文或串行执行 |
| 可独立验证 | 每个Agent的输出是否可以单独校验? | 合并为单个任务 |
| Scenario | Parallelize? | Reason |
|---|---|---|
| Different files, different concerns | Yes | No conflict possible |
| Same module, different files | Yes (careful) | Verify no shared imports change |
| Same file, different sections | No | Merge conflicts inevitable |
| Task B uses Task A's output | No | Sequential dependency |
| Both read same files, write different | Yes | Reads are safe to parallelize |
| Both modify shared config file | No | Config conflicts |
| Independent test files | Yes | Tests are independent |
| One agent adds dep, another uses it | No | Package-level dependency |
| 场景 | 是否可以并行? | 原因 |
|---|---|---|
| 不同文件、不同业务域 | 是 | 不可能产生冲突 |
| 同一模块、不同文件 | 是(需谨慎) | 确认无共享的导入内容会被修改 |
| 同一文件、不同区块 | 否 | 合并冲突不可避免 |
| 任务B依赖任务A的输出 | 否 | 存在顺序依赖 |
| 均读取相同文件、写入不同文件 | 是 | 读取操作可安全并行 |
| 均修改共享配置文件 | 否 | 会产生配置冲突 |
| 独立的测试文件 | 是 | 测试用例互相独立 |
| 一个Agent添加依赖,另一个Agent使用该依赖 | 否 | 存在包级别依赖 |
AgentAgentSCOPE: Add structured JSON logging to all API route handlers in src/api/.
Replace console.log calls with the logger from src/utils/logger.ts.
Files to modify: src/api/users.ts, src/api/orders.ts, src/api/products.ts.SCOPE: Add structured JSON logging to all API route handlers in src/api/.
Replace console.log calls with the logger from src/utils/logger.ts.
Files to modify: src/api/users.ts, src/api/orders.ts, src/api/products.ts.CONTEXT:
- Logger API: logger.info(message, metadata), logger.error(message, error)
- Import: import { logger } from '../utils/logger'
- Current pattern in files: console.log('action', data)
- Target pattern: logger.info('action', { data, requestId: req.id })CONTEXT:
- Logger API: logger.info(message, metadata), logger.error(message, error)
- Import: import { logger } from '../utils/logger'
- Current pattern in files: console.log('action', data)
- Target pattern: logger.info('action', { data, requestId: req.id })OUTPUT: For each modified file, return:
1. The file path
2. A summary of changes made
3. Number of console.log calls replacedOUTPUT: For each modified file, return:
1. The file path
2. A summary of changes made
3. Number of console.log calls replacedCONSTRAINTS:
- Do NOT modify any files outside src/api/
- Do NOT change the logger utility itself
- Do NOT add new dependencies
- Do NOT refactor function signatures
- Do NOT modify test files
- If you encounter an issue outside your scope, report it but do not fix itCONSTRAINTS:
- Do NOT modify any files outside src/api/
- Do NOT change the logger utility itself
- Do NOT add new dependencies
- Do NOT refactor function signatures
- Do NOT modify test files
- If you encounter an issue outside your scope, report it but do not fix itYou are a focused agent with a single task.You are a focused agent with a single task.undefinedundefined| Check | Question |
|---|---|
| Scope is specific | Can the agent complete the task without guessing? |
| Context is complete | Does the agent need to explore the codebase? (should be no) |
| Output is defined | Will the agent return what you need to integrate? |
| Constraints are explicit | Are file boundaries and "do NOT" items clear? |
Agent| 检查项 | 验证问题 |
|---|---|
| 范围明确 | Agent无需猜测即可完成任务吗? |
| 上下文完整 | Agent不需要额外探索代码库吗?(应为否) |
| 输出定义清晰 | Agent返回的内容可直接用于整合吗? |
| 约束明确 | 文件边界和“禁止”项是否清晰? |
AgentAgentAgentAgentAgent| Agent | Task | Status | Files | Result |
|-------|------|--------|-------|--------|
| Agent 1 | Add logging to API | in_progress | src/api/*.ts | — |
| Agent 2 | Update unit tests | in_progress | tests/unit/*.ts | — |
| Agent 3 | Fix CSS layout | in_progress | src/styles/*.css | — || Agent | Task | Status | Files | Result |
|-------|------|--------|-------|--------|
| Agent 1 | Add logging to API | in_progress | src/api/*.ts | — |
| Agent 2 | Update unit tests | in_progress | tests/unit/*.ts | — |
| Agent 3 | Fix CSS layout | in_progress | src/styles/*.css | — || Scenario | Action |
|---|---|
| One agent fails, others succeed | Retry failed agent independently (via the |
| Multiple agents fail independently | Retry each independently (via the |
| Agent reports out-of-scope issue | Note for post-integration review |
| Agent exceeds scope (modifies wrong files) | Reject output, re-dispatch (via the |
| 场景 | 处理方式 |
|---|---|
| 一个Agent执行失败,其他成功 | 单独重试失败的Agent(通过 |
| 多个Agent独立执行失败 | 分别单独重试每个Agent(通过 |
| Agent上报范围外的问题 | 记录下来,留待集成后审核 |
| 超出执行范围(修改了错误的文件) | 拒绝输出,使用更严格的约束重新调度(通过 |
| Check | Command | Must Pass |
|---|---|---|
| No file conflicts | Diff outputs for shared files | Yes |
| Tests pass | Full test suite | Yes |
| Build passes | Build command | Yes |
| Lint passes | Lint command | Yes |
| No regressions | Compare test count before/after | Yes |
| 检查项 | 执行命令 | 必须通过 |
|---|---|---|
| 无文件冲突 | 对比共享文件的diff输出 | 是 |
| 测试通过 | 完整测试套件 | 是 |
| 构建通过 | 构建命令 | 是 |
| 语法检查通过 | Lint命令 | 是 |
| 无功能回退 | 对比变更前后的测试用例数量 | 是 |
| Failure Type | Diagnosis | Action |
|---|---|---|
| Test failure in Agent 1's files | Agent 1's changes have a bug | Re-dispatch Agent 1 (via the |
| Test failure in unrelated files | Cross-cutting regression | Identify root cause, fix manually or re-dispatch (via the |
| Build failure | Import/type issue | Check which agent's changes caused it, fix |
| Merge conflict | Agents touched same file (should not happen) | Rollback, serialize those tasks |
| 故障类型 | 诊断 | 处理方式 |
|---|---|---|
| Agent1负责的文件测试失败 | Agent1的变更存在bug | 携带测试失败上下文重新调度Agent1(通过 |
| 无关文件测试失败 | 跨域功能回退 | 定位根因,手动修复或重新调度(通过 |
| 构建失败 | 导入/类型问题 | 定位是哪个Agent的变更导致的,修复问题 |
| 合并冲突 | Agent修改了同一文件(本应避免) | 回滚变更,串行执行这些任务 |
| Pattern | When to Use | Example |
|---|---|---|
| By Module | Independent modules or packages | One |
| By Layer | Layers touch different files | API agent, service agent, data agent |
| By Feature Area | Independent vertical slices | Auth agent, profile agent, billing agent |
| By Task Type | Code, tests, docs touch different files | Code agent, test agent, docs agent |
| 模式 | 使用场景 | 示例 |
|---|---|---|
| 按模块拆分 | 独立模块或包 | 每个微服务对应一次 |
| 按层级拆分 | 不同层级操作不同文件 | API Agent、服务层Agent、数据层Agent |
| 按功能域拆分 | 独立的垂直业务切片 | 认证Agent、用户资料Agent、计费Agent |
| 按任务类型拆分 | 代码、测试、文档操作不同文件 | 编码Agent、测试Agent、文档Agent |
TASK: "Update the API to v2, add tests, and update OpenAPI spec"
AGENT 1 - API Routes:
Scope: Update route handlers in src/routes/v2/
Context: [v2 API spec, breaking changes list]
Output: Modified files list, breaking changes implemented
Constraints: Do NOT touch tests or docs
AGENT 2 - Tests:
Scope: Write tests in tests/v2/
Context: [v2 API spec, test conventions, existing v1 tests as reference]
Output: New test files, coverage summary
Constraints: Do NOT modify source code
AGENT 3 - OpenAPI Spec:
Scope: Update openapi/v2.yaml
Context: [v2 API spec, OpenAPI 3.1 format]
Output: Updated spec file
Constraints: Do NOT modify code or testsTASK: "Update the API to v2, add tests, and update OpenAPI spec"
AGENT 1 - API Routes:
Scope: Update route handlers in src/routes/v2/
Context: [v2 API spec, breaking changes list]
Output: Modified files list, breaking changes implemented
Constraints: Do NOT touch tests or docs
AGENT 2 - Tests:
Scope: Write tests in tests/v2/
Context: [v2 API spec, test conventions, existing v1 tests as reference]
Output: New test files, coverage summary
Constraints: Do NOT modify source code
AGENT 3 - OpenAPI Spec:
Scope: Update openapi/v2.yaml
Context: [v2 API spec, OpenAPI 3.1 format]
Output: Updated spec file
Constraints: Do NOT modify code or tests| Anti-Pattern | Why It Fails | Correct Approach |
|---|---|---|
| Two agents modifying the same file | Merge conflicts, data loss | One file owner per |
| Shared mutable state between agents | Race conditions, inconsistency | Eliminate shared state |
| Incomplete context in prompts | Agents explore and step on each other | Provide ALL needed context |
| Vague file boundaries | Agents guess scope, modify wrong files | Explicit file lists in constraints |
| No integration check after completion | Cross-cutting bugs go undetected | Full test suite after integration |
| Parallelizing sequential tasks | Agent B needs Agent A's output | Verify independence first |
| Not tracking which agent touched which file | Cannot diagnose integration failures | Maintain dispatch tracking table |
| Dispatching too many agents (10+) | Coordination overhead exceeds savings | 2-5 |
| Skipping rollback preparation | Cannot recover from integration failure | Keep pre-dispatch state recoverable |
| 反模式 | 失败原因 | 正确做法 |
|---|---|---|
| 两个Agent修改同一文件 | 合并冲突、数据丢失 | 每次 |
| Agent间共享可变状态 | 竞态条件、数据不一致 | 消除共享状态 |
| 提示词上下文不完整 | Agent探索时互相干扰 | 提供全部所需上下文 |
| 文件边界模糊 | Agent猜测范围,修改错误文件 | 在约束中明确列出文件清单 |
| 完成后不做集成检查 | 跨域bug未被发现 | 集成后运行完整测试套件 |
| 并行化有顺序依赖的任务 | AgentB需要AgentA的输出 | 先验证独立性 |
| 不跟踪Agent修改的文件 | 无法定位集成失败原因 | 维护调度跟踪表 |
| 调度过多Agent(10个以上) | 协调开销超过收益 | 每轮调度执行2-5次 |
| 未准备回滚方案 | 集成失败后无法恢复 | 确保调度前的状态可恢复 |
| Skill | Relationship | When |
|---|---|---|
| Upstream — identifies independent task clusters | Before dispatching |
| Complementary — provides review gates | Quality gates for agent output |
| Upstream — may delegate independent tasks | During plan execution |
| Downstream — verifies integrated result | After integration |
| Downstream — reviews integrated changes | After all agents complete |
| On failure — retries failed agents | When individual agents fail |
| 技能 | 关系 | 时机 |
|---|---|---|
| 上游技能 —— 识别独立任务集群 | 调度前 |
| 互补技能 —— 提供审核关卡 | Agent输出质量校验 |
| 上游技能 —— 可委托独立任务 | 计划执行期间 |
| 下游技能 —— 验证集成结果 | 集成后 |
| 下游技能 —— 审核集成后的变更 | 所有Agent执行完成后 |
| 故障处理技能 —— 重试失败的Agent | 单个Agent执行失败时 |
| Rule | Rationale |
|---|---|
| No two agents modify the same file | Prevents merge conflicts and race conditions |
| No shared mutable state | Eliminates data races |
| Each agent gets complete context | Prevents agents from exploring and stepping on each other |
| Define file boundaries explicitly | Makes ownership unambiguous |
| Review integration after completion | Catches cross-cutting issues |
| Atomic commit for all changes | All in or all out |
| Always have a rollback path | Keep pre-dispatch state recoverable |
| 规则 | 逻辑 |
|---|---|
| 禁止两个Agent修改同一文件 | 避免合并冲突和竞态条件 |
| 禁止共享可变状态 | 消除数据竞态 |
| 每个Agent获取完整上下文 | 避免Agent探索时互相干扰 |
| 明确定义文件边界 | 明确所有权 |
| 完成后审核集成结果 | 发现跨域问题 |
| 所有变更原子提交 | 要么全部生效要么全部回滚 |
| 始终保留回滚路径 | 确保调度前的状态可恢复 |