Skills.MD
# Swarm Coordination Skill
This skill provides guidance for effective multi-agent coordination in OpenCode swarm workflows.
**IMPORTANT:** This skill references global skills in `global-skills/`. Workers should load domain-specific skills based on their subtask type.
## MANDATORY: Swarm Mail
**ALL coordination MUST use `swarmmail_*` tools.** This is non-negotiable.
Swarm Mail is embedded (no external server needed) and provides:
- File reservations to prevent conflicts
- Message passing between agents
- Thread-based coordination tied to cells
## When to Use Swarm Coordination
Use swarm coordination when:
- A task has multiple independent subtasks that can run in parallel
- The task requires different specializations (e.g., frontend + backend + tests)
- Work can be divided by file/module boundaries
- Time-to-completion matters and parallelization helps
Do NOT use swarm coordination when:
- The task is simple and can be done by one agent
- Subtasks have heavy dependencies on each other
- The overhead of coordination exceeds the benefit
## Task Decomposition Strategy
### 1. Analyze the Task
Before decomposing, understand:
- What are the distinct units of work?
- Which parts can run in parallel vs sequentially?
- What are the file/module boundaries?
- Are there shared resources that need coordination?
### 2. Choose a Decomposition Strategy
**Parallel Strategy** - For independent subtasks:
```text
Parent Task: "Add user authentication"
├── Subtask 1: "Create auth API endpoints" (backend)
├── Subtask 2: "Build login/signup forms" (frontend)
├── Subtask 3: "Write auth integration tests" (testing)
└── Subtask 4: "Add auth documentation" (docs)
```
**Sequential Strategy** - When order matters:
```text
Parent Task: "Migrate database schema"
├── Step 1: "Create migration files"
├── Step 2: "Update model definitions"
├── Step 3: "Run migrations"
└── Step 4: "Verify data integrity"
```
**Hybrid Strategy** - Mixed dependencies:
```text
Parent Task: "Add feature X"
├── Phase 1 (parallel):
│ ├── Subtask A: "Design API"
│ └── Subtask B: "Design UI mockups"
├── Phase 2 (sequential, after Phase 1):
│ └── Subtask C: "Implement based on designs"
└── Phase 3 (parallel):
├── Subtask D: "Write tests"
└── Subtask E: "Update docs"
```
## File Reservation Protocol
When multiple agents work on the same codebase:
1. **Initialize Swarm Mail first** - Use `swarmmail_init` before any work
2. **Reserve files before editing** - Use `swarmmail_reserve` to claim files
3. **Respect reservations** - Don't edit files reserved by other agents
4. **Release when done** - Use `swarmmail_release` or let `swarm_complete` handle it
5. **Coordinate on shared files** - If you must edit a reserved file, send a message to the owning agent
```typescript
// Initialize first
await swarmmail_init({
project_path: "$PWD",
task_description: "Working on auth feature",
});
// Reserve files
await swarmmail_reserve({
paths: ["src/auth/**"],
reason: "bd-123: Auth implementation",
ttl_seconds: 3600,
});
// Work...
// Release when done
await swarmmail_release();
```
## Communication Patterns
### Broadcasting Updates
```typescript
swarmmail_send({
to: ["*"],
subject: "API Complete",
body: "Completed API endpoints, ready for frontend integration",
thread_id: epic_id,
});
```
### Direct Coordination
```typescript
swarmmail_send({
to: ["frontend-agent"],
subject: "Auth API Spec",
body: "Auth API is at /api/auth/*, here's the spec...",
thread_id: epic_id,
});
```
### Checking for Messages
```typescript
// Check inbox (max 5, no bodies for context safety)
const inbox = await swarmmail_inbox();
// Read specific message body
const message = await swarmmail_read_message({ message_id: N });
```
### Reporting Blockers
```typescript
swarmmail_send({
to: ["coordinator"],
subject: "BLOCKED: Need DB schema",
body: "Can't proceed without users table",
thread_id: epic_id,
importance: "urgent",
});
```
## Best Practices
1. **Initialize Swarm Mail first** - Always call `swarmmail_init` before any work
2. **Small, focused subtasks** - Each subtask should be completable in one agent session
3. **Clear boundaries** - Define exactly what files/modules each subtask touches
4. **Explicit handoffs** - When one task enables another, communicate clearly
5. **Graceful failures** - If a subtask fails, don't block the whole swarm
6. **Progress updates** - Use beads to track subtask status
7. **Load relevant skills** - Workers should call `skills_use()` based on their task type:
- Testing work → `skills_use(name="testing-patterns")`
- Architecture decisions → `skills_use(name="system-design")`
- CLI development → `skills_use(name="cli-builder")`
- Multi-agent coordination → `skills_use(name="swarm-coordination")`
## Common Patterns
### Feature Development
```yaml
decomposition:
strategy: hybrid
skills: [system-design, swarm-coordination]
phases:
- name: design
parallel: true
subtasks: [api-design, ui-design]
recommended_skills: [system-design]
- name: implement
parallel: true
subtasks: [backend, frontend]
recommended_skills: [system-design]
- name: validate
parallel: true
subtasks: [tests, docs, review]
recommended_skills: [testing-patterns]
```
### Bug Fix Swarm
```yaml
decomposition:
strategy: sequential
skills: [testing-patterns]
subtasks:
- reproduce-bug
- identify-root-cause
- implement-fix
- add-regression-test
recommended_skills: [testing-patterns]
```
### Refactoring
```yaml
decomposition:
strategy: parallel
skills: [testing-patterns, system-design]
subtasks:
- refactor-module-a
- refactor-module-b
- update-imports
- run-full-test-suite
recommended_skills: [testing-patterns, system-design]
```
## Skill Integration Workflow
**For Coordinators:**
1. Initialize Swarm Mail with `swarmmail_init`
2. Load `swarm-coordination` skill
3. Analyze task type
4. Load additional skills based on domain (testing, design, CLI)
5. Include skill recommendations in `shared_context` for workers
**For Workers:**
1. Initialize Swarm Mail with `swarmmail_init`
2. Read `shared_context` from coordinator
3. Load recommended skills with `skills_use(name="skill-name")`
4. Apply skill knowledge to subtask
5. Report progress via `swarmmail_send`
6. Complete with `swarm_complete`
**Example shared_context:**
```markdown
## Context from Coordinator
Past similar tasks: [CASS results]
Project learnings: [semantic-memory results]
## Recommended Skills
- skills_use(name="testing-patterns") - for test creation
- skills_use(name="system-design") - for module boundaries
## Task-Specific Notes
[Domain knowledge from coordinator]
```
## Swarm Mail Quick Reference
| Tool | Purpose |
| ------------------------ | ----------------------------------- |
| `swarmmail_init` | Initialize session (REQUIRED FIRST) |
| `swarmmail_send` | Send message to agents |
| `swarmmail_inbox` | Check inbox (max 5, no bodies) |
| `swarmmail_read_message` | Read specific message body |
| `swarmmail_reserve` | Reserve files for exclusive editing |
| `swarmmail_release` | Release file reservations |
| `swarmmail_ack` | Acknowledge message |
| `swarmmail_health` | Check database health |
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「swarm-coordination」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次