원클릭으로
swarm
N coordinated agents on shared task list with SQLite-based atomic claiming
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
N coordinated agents on shared task list with SQLite-based atomic claiming
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Configure HUD display options (layout, presets, display elements)
Setup and configure oh-my-droid (the ONLY command you need to learn)
Set up and manage local skills for automatic matching and invocation
Manage local skills - list, add, remove, search, edit
Extract a learned skill from the current conversation
Manage isolated dev environments with git worktrees and tmux sessions
| name | swarm |
| description | N coordinated agents on shared task list with SQLite-based atomic claiming |
Spawn N coordinated agents working on a shared task list with SQLite-based atomic claiming. Like a dev team tackling multiple files in parallel—fast, reliable, and with full fault tolerance.
/swarm N:agent-type "task description"
/swarm 5:executor "fix all TypeScript errors"
/swarm 3:build-fixer "fix build errors in src/"
/swarm 4:designer "implement responsive layouts for all components"
/swarm 2:architect "analyze and document all API endpoints"
User: "/swarm 5:executor fix all TypeScript errors"
|
v
[SWARM ORCHESTRATOR]
|
+--+--+--+--+--+
| | | | |
v v v v v
E1 E2 E3 E4 E5
| | | | |
+--+--+--+--+
|
v
[SQLITE DATABASE]
┌─────────────────────┐
│ tasks table │
├─────────────────────┤
│ id, description │
│ status (pending, │
│ claimed, done, │
│ failed) │
│ claimed_by, claimed_at
│ completed_at, result│
│ error │
├─────────────────────┤
│ heartbeats table │
│ (agent monitoring) │
└─────────────────────┘
Key Features:
run_in_background: true for allWhen spawning swarm agents, ALWAYS wrap the task with the worker preamble to prevent recursive sub-agent spawning:
import { wrapWithPreamble } from '../droids/preamble.js';
// When spawning each agent:
const agentPrompt = wrapWithPreamble(`
Use mcp__t__swarm with cwd ${cwd}
Connect with action "connect"
Claim tasks with action "claim" and agentId "agent-${n}"
Complete work with action "complete" or "fail"
Send action "heartbeat" every 60 seconds
Exit when claim reports no pending tasks
`);
Task({
subagent_type: 'oh-my-droid:executor',
prompt: agentPrompt,
run_in_background: true
});
The worker preamble ensures agents:
Each agent follows this loop:
LOOP:
1. Call mcp__t__swarm({ action: "claim", cwd, agentId })
2. SQLite transaction:
- Find first pending task
- UPDATE status='claimed', claimed_by=agentId, claimed_at=now
- INSERT/UPDATE heartbeat record
- Atomically commit (only one agent succeeds)
3. Execute task
4. Call mcp__t__swarm with action "complete" or "fail"
5. GOTO LOOP until claim reports no pending tasks
Atomic Claiming Details:
IMMEDIATE transaction prevents race conditionsmcp__t__swarm with action heartbeat every 60 secondsstatus actionExit when ANY of:
status reports no pending or claimed tasks/cancel.omd/state/swarm.db)The swarm uses a single SQLite database stored at .omd/state/swarm.db. This provides:
tasks Table SchemaCREATE TABLE tasks (
id TEXT PRIMARY KEY,
description TEXT NOT NULL,
status TEXT NOT NULL DEFAULT 'pending',
-- pending: waiting to be claimed
-- claimed: claimed by an agent, in progress
-- done: completed successfully
-- failed: completed with error
claimed_by TEXT, -- agent ID that claimed this task
claimed_at INTEGER, -- Unix timestamp when claimed
completed_at INTEGER, -- Unix timestamp when completed
result TEXT, -- Optional result/output from task
error TEXT -- Error message if task failed
);
heartbeats Table SchemaCREATE TABLE heartbeats (
agent_id TEXT PRIMARY KEY,
last_heartbeat INTEGER NOT NULL, -- Unix timestamp of last heartbeat
current_task_id TEXT -- Task agent is currently working on
);
swarm_session Table SchemaCREATE TABLE swarm_session (
id INTEGER PRIMARY KEY CHECK (id = 1),
session_id TEXT NOT NULL,
active INTEGER NOT NULL DEFAULT 1,
agent_count INTEGER NOT NULL,
started_at INTEGER NOT NULL,
completed_at INTEGER
);
The implementation uses node:sqlite DatabaseSync and a shared
runImmediateTransaction() helper that issues BEGIN IMMEDIATE, COMMIT, and
ROLLBACK. Workers never access the database directly. They use
mcp__t__swarm, which serializes actions and returns retryable: true when
SQLite lock contention should be retried.
Stale claims are released by the connected project's cleanup timer and whenever
a project is reconnected. Coordinators can also invoke the cleanup action
explicitly.
Agents interact with the swarm through the shipped mcp__t__swarm tool:
Workers and coordinators interact with the swarm through the mcp__t__swarm MCP tool.
This tool is available to executor, executor-low, and executor-high agents.
// Orchestrator starts the swarm via the MCP tool
await mcp__t__swarm({
action: 'start',
cwd: process.cwd(),
agentCount: 5,
tasks: ['fix a.ts', 'fix b.ts', ...],
});
// Agents connect to the existing swarm
await mcp__t__swarm({ action: 'connect', cwd: process.cwd() });
// Claim a task
const claim = await mcp__t__swarm({ action: 'claim', cwd: process.cwd(), agentId: 'agent-1' });
// Complete the task
await mcp__t__swarm({
action: 'complete',
cwd: process.cwd(),
agentId: 'agent-1',
taskId: claim.taskId,
result: 'Fixed the bug',
});
const agentId = 'agent-1';
// Main work loop
while (true) {
const claim = await mcp__t__swarm({
action: 'claim',
cwd: process.cwd(),
agentId,
});
if (!claim.success) {
if (claim.retryable) {
await new Promise(resolve => setTimeout(resolve, 1000));
continue;
}
console.log('No tasks available:', claim.reason);
break;
}
const { taskId, description } = claim;
console.log(`Agent ${agentId} working on: ${description}`);
try {
// Do the work...
const result = await executeTask(description);
await mcp__t__swarm({
action: 'complete',
cwd: process.cwd(),
agentId,
taskId,
result,
});
console.log(`Agent ${agentId} completed task ${taskId}`);
} catch (error) {
await mcp__t__swarm({
action: 'fail',
cwd: process.cwd(),
agentId,
taskId,
error: error.message,
});
console.error(`Agent ${agentId} failed on ${taskId}:`, error);
}
// Send heartbeat every 60 seconds (while working on long tasks)
await mcp__t__swarm({
action: 'heartbeat',
cwd: process.cwd(),
agentId,
});
}
interface SwarmConfig {
agentCount: number; // Number of agents (1-5)
tasks: string[]; // Task descriptions
agentType?: string; // Agent type (default: 'executor')
leaseTimeout?: number; // Milliseconds (default: 5 min)
heartbeatInterval?: number; // Milliseconds (default: 60 sec)
cwd?: string; // Working directory
}
interface SwarmTask {
id: string;
description: string;
status: 'pending' | 'claimed' | 'done' | 'failed';
claimedBy: string | null;
claimedAt: number | null;
completedAt: number | null;
error?: string;
result?: string;
}
interface ClaimResult {
success: boolean;
taskId: string | null;
description?: string;
reason?: string;
}
interface SwarmStats {
totalTasks: number;
pendingTasks: number;
claimedTasks: number;
doneTasks: number;
failedTasks: number;
activeAgents: number;
elapsedTime: number;
}
heartbeat action at least this often.omd/state/swarm.db)
complete action but is no longer the ownerstart or connect action returns an error if initialization failsclaim action reports the database error without assigning a taskretryable: truestatus task and heartbeat countsclaim action returns success: false with a reasonUser can cancel via /cancel:
/swarm 5:executor "fix all TypeScript type errors"
Spawns 5 executors, each claiming and fixing individual files.
/swarm 3:designer "implement Material-UI styling for all components in src/components/"
Spawns 3 designers, each styling different component files.
/swarm 4:security-reviewer "review all API endpoints for vulnerabilities"
Spawns 4 security reviewers, each auditing different endpoints.
/swarm 2:writer "add JSDoc comments to all exported functions"
Spawns 2 writers, each documenting different modules.
mcp__t__swarm tool with action-specific inputsIMPORTANT: Stop the swarm through the MCP tool so the SQLite session, cleanup timer, marker, and connection are closed consistently.
When all tasks are done:
await mcp__t__swarm({
action: 'stop',
cwd: process.cwd(),
deleteDatabase: true,
});
The orchestrator (main skill handler) is responsible for:
start actionstatus actioncleanup action when an explicit sweep is neededEach agent is a standard Task invocation with:
run_in_background: truemcp__t__swarm (available to executor, executor-low, executor-high)mcp__t__swarm({ action: 'connect', cwd }) to join existing swarmmcp__t__swarm({ action: 'claim', ... }) → do work → mcp__t__swarm({ action: 'complete', ... }) or mcp__t__swarm({ action: 'fail', ... })