task-decomposition
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTask Decomposition
任务拆解
Enable effective planning and execution by decomposing high-level objectives into manageable, testable sub-tasks.
通过将高层目标拆解为可管理、可测试的子任务,实现高效规划与执行。
When to Use
适用场景
- Complex user requests with multiple components
- Multi-phase projects requiring coordination
- Tasks that could benefit from parallel execution
- When planning agent coordination strategies
- 包含多个组件的复杂用户请求
- 需要协调的多阶段项目
- 可从并行执行中获益的任务
- 规划Agent协调策略时
Decomposition Framework
拆解框架
1. Requirements Analysis
1. 需求分析
Extract Information:
- Primary objective (what user wants to achieve)
- Implicit requirements (quality, performance, documentation)
- Constraints (time, resources, compatibility)
- Success criteria (how to measure completion)
Questions to Ask:
- What is the core goal?
- What are the sub-goals that contribute to the main goal?
- What are the dependencies between sub-goals?
- What could go wrong and how to prevent it?
提取信息:
- 核心目标(用户想要实现的内容)
- 隐含需求(质量、性能、文档)
- 约束条件(时间、资源、兼容性)
- 成功标准(如何衡量完成度)
需询问的问题:
- 核心目标是什么?
- 哪些子目标有助于实现主目标?
- 子目标之间的依赖关系是什么?
- 可能出现哪些问题,如何预防?
2. Goal Hierarchy
2. 目标层级
Top-Down Decomposition:
Main Goal: [High-level objective]
├─ Sub-goal 1: [Component 1]
│ ├─ Task 1.1: [Atomic action]
│ └─ Task 1.2: [Atomic action]
├─ Sub-goal 2: [Component 2]
│ ├─ Task 2.1: [Atomic action]
│ └─ Task 2.2: [Atomic action]
└─ Sub-goal 3: [Component 3]
└─ Task 3.1: [Atomic action]Atomic Task Criteria:
- Single, clear action
- Well-defined inputs and outputs
- Can be completed by one agent
- Testable/verifiable completion
- Time-bounded (estimable duration)
自上而下拆解:
Main Goal: [High-level objective]
├─ Sub-goal 1: [Component 1]
│ ├─ Task 1.1: [Atomic action]
│ └─ Task 1.2: [Atomic action]
├─ Sub-goal 2: [Component 2]
│ ├─ Task 2.1: [Atomic action]
│ └─ Task 2.2: [Atomic action]
└─ Sub-goal 3: [Component 3]
└─ Task 3.1: [Atomic action]原子任务标准:
- 单一、明确的动作
- 输入输出定义清晰
- 可由单个Agent完成
- 完成情况可测试/验证
- 有时间限制(可估算时长)
3. Dependency Mapping
3. 依赖关系映射
Dependency Types:
Sequential Dependencies:
Task A → Task B → Task C
(B requires A's output, C requires B's output)Parallel Independent:
Task A ─┐
Task B ─┼─ [All can run simultaneously]
Task C ─┘Converging Dependencies:
Task A ─┐
Task B ─┼─> Task D (requires A, B, C)
Task C ─┘Resource Dependencies:
Task A (needs resource X)
Task B (needs resource X)
→ Sequential or resource pooling required依赖类型:
顺序依赖:
Task A → Task B → Task C
(B requires A's output, C requires B's output)并行独立:
Task A ─┐
Task B ─┼─ [All can run simultaneously]
Task C ─┘汇聚依赖:
Task A ─┐
Task B ─┼─> Task D (requires A, B, C)
Task C ─┘资源依赖:
Task A (needs resource X)
Task B (needs resource X)
→ Sequential or resource pooling required4. Success Criteria Definition
4. 成功标准定义
For each task, define:
Input Requirements:
- What data/state is needed to start
- What resources must be available
- What preconditions must be met
Output Expectations:
- What artifacts will be produced
- What state changes will occur
- What metrics define success
Quality Standards:
- Performance requirements
- Code quality standards (from AGENTS.md)
- Testing requirements
- Documentation requirements
为每个任务定义:
输入要求:
- 启动所需的数据/状态
- 必须可用的资源
- 必须满足的前置条件
输出预期:
- 将生成的工件
- 将发生的状态变化
- 定义成功的指标
质量标准:
- 性能要求
- 代码质量标准(来自AGENTS.md)
- 测试要求
- 文档要求
Decomposition Process
拆解流程
Step 1: Understand the Goal
步骤1:理解目标
markdown
User Request: [Original request]
Analysis:
- Primary Goal: [Main objective]
- Type: [Implementation/Debug/Refactor/Analysis]
- Domain: [Specific area of codebase]
- Complexity: [Simple/Medium/Complex]markdown
用户请求: [原始请求]
分析:
- 核心目标: [主要目标]
- 类型: [实现/调试/重构/分析]
- 领域: [代码库的特定领域]
- 复杂度: [简单/中等/复杂]Step 2: Identify Major Components
步骤2:识别主要组件
Break main goal into 3-7 major components:
markdown
Main Goal: Implement batch pattern update feature
Major Components:
1. Database layer (Turso + redb)
2. API layer (public interface)
3. Business logic (batch processing)
4. Testing (unit + integration)
5. Documentation (API docs + examples)将主目标拆解为3-7个主要组件:
markdown
主目标: 实现批量模式更新功能
主要组件:
1. 数据库层 (Turso + redb)
2. API层 (公共接口)
3. 业务逻辑 (批量处理)
4. 测试 (单元测试 + 集成测试)
5. 文档 (API文档 + 示例)Step 3: Decompose Each Component
步骤3:拆解每个组件
For each component, identify atomic tasks:
markdown
Component: Database layer
Tasks:
1. Design batch schema/structure
- Input: Pattern data structures
- Output: Schema definition
- Success: Supports efficient batch operations
2. Implement Turso batch operations
- Input: Schema, patterns array
- Output: Batch insert/update functions
- Success: Atomic transaction, proper error handling
3. Implement redb batch caching
- Input: Schema, patterns array
- Output: Batch cache update functions
- Success: Fast writes, consistency maintained为每个组件识别原子任务:
markdown
组件: 数据库层
任务:
1. 设计批量模式/结构
- 输入: 模式数据结构
- 输出: 模式定义
- 成功标准: 支持高效批量操作
2. 实现Turso批量操作
- 输入: 模式、模式数组
- 输出: 批量插入/更新函数
- 成功标准: 原子事务、正确的错误处理
3. 实现redb批量缓存
- 输入: 模式、模式数组
- 输出: 批量缓存更新函数
- 成功标准: 快速写入、保持一致性Step 4: Map Dependencies
步骤4:映射依赖关系
markdown
Dependency Graph:
[Design schema] ──┬──> [Implement Turso batch] ──┐
│ ├──> [Write tests]
└──> [Implement redb batch] ───┘
[Write tests] ──> [Write documentation]markdown
依赖关系图:
[设计模式] ──┬──> [实现Turso批量操作] ──┐
│ ├──> [编写测试]
└──> [实现redb批量缓存] ───┘
[编写测试] ──> [编写文档]Step 5: Assign Priorities
步骤5:分配优先级
Priority Levels:
- P0 (Critical): Must complete for goal achievement
- P1 (Important): Significantly improves quality/functionality
- P2 (Nice-to-have): Enhances but not essential
Prioritization Factors:
- Blocks other tasks (critical path)
- High user value
- Risk reduction (address unknowns early)
- Quick wins (early validation)
优先级等级:
- P0(关键): 实现目标必须完成的任务
- P1(重要): 显著提升质量/功能的任务
- P2(锦上添花): 增强体验但非必需的任务
优先级考量因素:
- 阻塞其他任务(关键路径)
- 高用户价值
- 风险降低(尽早解决未知问题)
- 快速见效(早期验证)
Step 6: Estimate Complexity
步骤6:估算复杂度
For each task:
markdown
Task: [Name]
- Complexity: [Low/Medium/High]
- Effort: [Small/Medium/Large]
- Risk: [Low/Medium/High]
- Dependencies: [List]为每个任务:
markdown
任务: [名称]
- 复杂度: [低/中/高]
- 工作量: [小/中/大]
- 风险: [低/中/高]
- 依赖项: [列表]Decomposition Patterns
拆解模式
Pattern 1: Layer-Based Decomposition
模式1:基于分层的拆解
For architectural changes:
1. Data/Storage layer
2. Business logic layer
3. API/Interface layer
4. Testing layer
5. Documentation layer针对架构变更:
1. 数据/存储层
2. 业务逻辑层
3. API/接口层
4. 测试层
5. 文档层Pattern 2: Feature-Based Decomposition
模式2:基于功能的拆解
For new features:
1. Core functionality (MVP)
2. Error handling & edge cases
3. Performance optimization
4. Integration with existing system
5. Testing & validation
6. Documentation & examples针对新功能:
1. 核心功能 (MVP)
2. 错误处理与边缘情况
3. 性能优化
4. 与现有系统集成
5. 测试与验证
6. 文档与示例Pattern 3: Phase-Based Decomposition
模式3:基于阶段的拆解
For large projects:
Phase 1: Research & Design
Phase 2: Foundation & Infrastructure
Phase 3: Core Implementation
Phase 4: Integration & Testing
Phase 5: Optimization & Polish
Phase 6: Documentation & Release针对大型项目:
阶段1: 研究与设计
阶段2: 基础与基础设施
阶段3: 核心实现
阶段4: 集成与测试
阶段5: 优化与打磨
阶段6: 文档与发布Pattern 4: Problem-Solution Decomposition
模式4:基于问题-解决方案的拆解
For debugging/fixing:
1. Reproduce issue
2. Diagnose root cause
3. Design solution
4. Implement fix
5. Verify fix
6. Prevent regression (tests)针对调试/修复:
1. 复现问题
2. 诊断根本原因
3. 设计解决方案
4. 实施修复
5. 验证修复
6. 防止回归(测试)Example Decompositions
示例拆解
Example 1: Simple Task
示例1:简单任务
markdown
Request: "Fix failing test in pattern extraction"
Analysis: Simple, focused task
Decomposition:
1. Run test to observe failure
2. Identify failure cause
3. Apply fix
4. Verify test passes
5. Check for similar issues
Dependencies: Sequential (1→2→3→4→5)
Complexity: Low
Strategy: Single agent, sequential executionmarkdown
请求: "修复模式提取中失败的测试"
分析: 简单、聚焦的任务
拆解:
1. 运行测试以观察失败情况
2. 确定失败原因
3. 应用修复
4. 验证测试通过
5. 检查是否存在类似问题
依赖关系: 顺序执行 (1→2→3→4→5)
复杂度: 低
策略: 单个Agent,顺序执行Example 2: Medium Task
示例2:中等任务
markdown
Request: "Add caching to episode retrieval"
Analysis: Medium complexity, multiple components
Decomposition:
1. Design cache strategy
2. Implement cache layer
3. Integrate with retrieval
4. Add tests
5. Measure performance
Dependencies:
- 1 → 2 → 3 (sequential)
- 4 depends on 3
- 5 depends on 3
Strategy: Sequential with parallel testingmarkdown
请求: "为剧集检索添加缓存"
分析: 中等复杂度,多组件
拆解:
1. 设计缓存策略
2. 实现缓存层
3. 与检索功能集成
4. 添加测试
5. 衡量性能
依赖关系:
- 1 → 2 → 3 (顺序)
- 4 依赖于3
- 5 依赖于3
策略: 顺序执行 + 并行测试Example 3: Complex Task
示例3:复杂任务
markdown
Request: "Refactor storage layer to support multiple backends"
Analysis: High complexity, architectural change
Major Components:
1. Storage abstraction layer
2. Turso backend implementation
3. redb backend implementation
4. Backend factory & configuration
5. Migration utilities
6. Testing infrastructure
7. Documentation
Strategy: Multi-phase hybrid execution
Coordination: GOAP agent + multiple specialized agentsmarkdown
请求: "重构存储层以支持多种后端"
分析: 高复杂度,架构变更
主要组件:
1. 存储抽象层
2. Turso后端实现
3. redb后端实现
4. 后端工厂与配置
5. 迁移工具
6. 测试基础设施
7. 文档
策略: 多阶段混合执行
协调: GOAP Agent + 多个专业AgentQuality Checklist
质量检查清单
Good Decomposition Characteristics
优秀拆解的特征
✓ Each task is atomic and actionable
✓ Dependencies are clearly identified
✓ Success criteria are measurable
✓ Complexity is appropriately estimated
✓ All requirements are covered
✓ No task is too large (>4 hours work)
✓ Parallelization opportunities identified
✓ 每个任务都是原子化且可执行的
✓ 依赖关系明确识别
✓ 成功标准可衡量
✓ 复杂度估算合理
✓ 覆盖所有需求
✓ 没有过大的任务(>4小时工作量)
✓ 识别出并行执行的机会
Common Pitfalls
常见陷阱
✗ Tasks too large or vague
✗ Missing dependencies
✗ Unclear success criteria
✗ Over-decomposition (too granular)
✗ Missing quality/testing tasks
✗ No consideration for error handling
✗ Forgetting documentation tasks
✗ 任务过大或模糊
✗ 遗漏依赖关系
✗ 成功标准不明确
✗ 过度拆解(过于细化)
✗ 遗漏质量/测试任务
✗ 未考虑错误处理
✗ 忘记文档任务
Integration with GOAP Agent
与GOAP Agent的集成
The GOAP agent uses task decomposition as its first phase:
- Receive user request
- Apply decomposition framework (this skill)
- Create execution plan (agent-coordination skill)
- Execute with monitoring (parallel-execution skill)
- Report results
GOAP Agent将任务拆解作为第一阶段:
- 接收用户请求
- 应用拆解框架(本技能)
- 创建执行计划(Agent协调技能)
- 执行与监控(并行执行技能)
- 汇报结果
Tips for Effective Decomposition
高效拆解的技巧
1. Start with Why
1. 从“为什么”开始
- Understand the true goal behind the request
- Identify implicit requirements
- Consider broader context
- 理解请求背后的真实目标
- 识别隐含需求
- 考虑更广泛的上下文
2. Think Top-Down
2. 自上而下思考
- Start with high-level components
- Decompose each component separately
- Stop at appropriate granularity
- 从高层组件开始
- 单独拆解每个组件
- 在合适的粒度停止
3. Consider the User
3. 以用户为中心
- What value does each task provide?
- Can tasks be reordered for faster feedback?
- What's the minimum viable solution?
- 每个任务能提供什么价值?
- 任务是否可以重新排序以获得更快的反馈?
- 最小可行解决方案是什么?
4. Plan for Quality
4. 为质量做规划
- Include testing tasks
- Include documentation tasks
- Include review/validation tasks
- 包含测试任务
- 包含文档任务
- 包含评审/验证任务
5. Anticipate Issues
5. 预判问题
- What could go wrong?
- What are the unknowns?
- Where are the risks?
- 可能会出现什么问题?
- 未知因素有哪些?
- 风险点在哪里?
6. Enable Parallelization
6. 支持并行化
- Identify truly independent tasks
- Break dependencies where possible
- Consider resource constraints
- 识别真正独立的任务
- 尽可能打破依赖关系
- 考虑资源约束
Summary
总结
Good task decomposition is the foundation of effective planning and coordination. By breaking complex goals into atomic, well-defined tasks with clear dependencies, you enable:
- Optimal execution strategies (parallel/sequential)
- Clear success criteria and validation
- Effective agent coordination
- Better progress tracking
- Higher quality outcomes
Use this skill as the first step in any complex task planning workflow.
优秀的任务拆解是高效规划与协调的基础。通过将复杂目标拆解为原子化、定义清晰且具有明确依赖关系的任务,你可以实现:
- 最优执行策略(并行/顺序)
- 明确的成功标准与验证方式
- 高效的Agent协调
- 更好的进度跟踪
- 更高质量的成果
在任何复杂任务规划工作流中,将该技能作为第一步使用。