计划执行工作流知识库,包含计划格式规范、任务解析、依赖分析和执行策略
解析和执行结构化任务计划,自动处理依赖关系和批次执行。当检测到 Markdown 或 YAML 格式的计划文件时触发,用于管理复杂开发任务的执行顺序。
/plugin marketplace add penkzhou/swiss-army-knife-plugin/plugin install swiss-army-knife@swiss-army-knife-pluginThis skill inherits all available tools. When active, it can use any tool Claude has access to.
本 Skill 提供计划执行工作流的核心知识,包括计划格式规范、任务解析规则、依赖分析算法和批次执行策略。
| 格式 | 文件扩展名 | 检测方式 |
|---|---|---|
| Markdown | .md | 文件扩展名 + 任务模式检测 |
| YAML | .yaml, .yml | 文件扩展名 + tasks: 键检测 |
任务标记模式(按优先级检测):
## Task 1: 实现用户认证模块
描述:实现基于 JWT 的用户认证...
## Task 2: 添加数据库迁移
描述:...
### 1. 创建 API 端点
描述:...
### 2. 添加单元测试
描述:...
- [ ] 重构认证中间件
- [ ] 添加错误处理
- [ ] 更新文档
1. **创建用户服务**
- 文件: `src/services/user.ts`
- 描述: ...
2. **添加数据验证**
- 文件: `src/validators/user.ts`
- 描述: ...
title: "用户认证系统实现"
description: "实现完整的用户认证流程"
tasks:
- id: T-001
title: "创建用户模型"
description: "定义 User 数据模型和相关类型"
files:
- src/models/user.ts
- src/types/user.ts
dependencies: []
complexity: low
- id: T-002
title: "实现认证服务"
description: "实现登录、注册、Token 刷新逻辑"
files:
- src/services/auth.ts
dependencies:
- T-001
complexity: medium
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
id | 否 | string | 任务 ID(自动生成如 T-001) |
title | 是 | string | 任务标题 |
description | 否 | string | 任务描述 |
files | 否 | string[] | 涉及的文件列表 |
dependencies | 否 | string[] | 依赖的任务 ID |
complexity | 否 | enum | low/medium/high |
test_files | 否 | string[] | 相关测试文件 |
解析优先级:
## Task N: 模式### N. 模式- [ ] 模式N. **xxx** 模式示例解析:
## Task 1: 创建用户服务
实现用户 CRUD 操作的服务层。
**文件**:
- `src/services/user.ts`
- `src/types/user.ts`
**依赖**:无
**测试**:
- `tests/services/user.test.ts`
解析结果:
{
"id": "T-001",
"title": "创建用户服务",
"description": "实现用户 CRUD 操作的服务层。",
"files": ["src/services/user.ts", "src/types/user.ts"],
"dependencies": [],
"test_files": ["tests/services/user.test.ts"],
"complexity": "medium"
}
如果计划未显式指定复杂度,根据以下规则推断:
| 条件 | 复杂度 |
|---|---|
| 涉及文件 ≤ 2 且无依赖 | low |
| 涉及文件 3-5 或有 1-2 个依赖 | medium |
| 涉及文件 > 5 或有 > 2 个依赖 | high |
如果任务无 ID,按顺序生成:
T-001, T-002, T-003, ...计划中通过 dependencies 字段声明的依赖关系。
自动检测以下隐式依赖:
使用 Kahn 算法进行拓扑排序:
def topological_sort(tasks, dependencies):
in_degree = {t.id: 0 for t in tasks}
for deps in dependencies.values():
for dep in deps:
in_degree[dep] += 1
queue = [t for t in tasks if in_degree[t.id] == 0]
result = []
while queue:
task = queue.pop(0)
result.append(task)
for t in tasks:
if task.id in dependencies.get(t.id, []):
in_degree[t.id] -= 1
if in_degree[t.id] == 0:
queue.append(t)
if len(result) != len(tasks):
raise CyclicDependencyError("检测到循环依赖")
return result
如果检测到循环依赖:
batch_sizedef generate_batches(sorted_tasks, batch_size, max_parallel):
batches = []
current_batch = []
completed = set()
for task in sorted_tasks:
# 检查依赖是否已完成
deps_satisfied = all(d in completed for d in task.dependencies)
# 检查是否可以并行(无同文件修改)
can_parallel = not any(
set(task.files) & set(t.files)
for t in current_batch
)
if deps_satisfied and can_parallel and len(current_batch) < batch_size:
current_batch.append(task)
else:
if current_batch:
batches.append(current_batch)
completed.update(t.id for t in current_batch)
current_batch = [task]
if current_batch:
batches.append(current_batch)
return batches
同一批次内的任务可以并行执行,条件:
max_parallel每个任务的置信度基于以下因素:
| 因素 | 权重 | 评分标准 |
|---|---|---|
| 文件存在性 | 30% | 目标文件/目录是否存在或可创建 |
| 描述清晰度 | 25% | 任务描述是否明确可执行 |
| 依赖可满足 | 25% | 依赖任务是否已定义且无循环 |
| 复杂度合理 | 20% | 复杂度评估是否合理 |
整体置信度 = 所有任务置信度的加权平均
权重:
| 整体置信度 | 行为 |
|---|---|
| ≥ 80 | 自动继续执行 |
| 60-79 | 展示验证结果,询问用户是否继续 |
| 40-59 | 建议调整计划后重试 |
| < 40 | 停止,报告计划无法执行 |
1. RED Phase
├─ 识别或创建测试文件
├─ 编写失败的测试用例
└─ 运行测试确认失败
2. GREEN Phase
├─ 实现最小代码使测试通过
└─ 运行测试确认通过
3. REFACTOR Phase
├─ 重构代码(保持测试通过)
├─ 运行 lint 检查
└─ 运行类型检查
以下情况可跳过 TDD:
症状:无法识别任务列表
解决:
症状:拓扑排序失败
解决:
症状:多个任务修改同一文件且无法确定顺序
解决:
症状:整体置信度 < 40
可能原因:
解决:
{
"config": {
"test_command": "make test",
"lint_command": "make lint",
"typecheck_command": "make typecheck",
"batch_size": 3,
"docs": {
"bugfix_dir": "docs/bugfix",
"best_practices_dir": "docs/best-practices"
}
},
"plan_info": {
"source": "file",
"path": "docs/plans/feature-auth.md",
"title": "用户认证系统实现",
"format": "markdown",
"total_tasks": 5
},
"tasks": [...],
"project_info": {
"plugin_root": "/path/to/project",
"git": {
"branch": "feature/auth",
"modified_files": []
},
"detected_stack": "mixed"
}
}
{
"validation_results": [...],
"execution_order": ["T-001", "T-002", "T-003"],
"batches": [
{
"batch_id": 1,
"tasks": ["T-001", "T-002"],
"can_parallel": true
}
],
"overall_confidence": 85,
"recommendation": "proceed"
}
{
"execution_results": [
{
"task_id": "T-001",
"status": "completed",
"tdd_cycles": 1,
"changes": [...],
"duration_seconds": 120
}
],
"summary": {
"total": 5,
"completed": 4,
"skipped": 1,
"failed": 0
},
"review_results": {...},
"knowledge_extracted": [...]
}
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems. Create original algorithmic art rather than copying existing artists' work to avoid copyright violations.
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.
Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.