🐝 Swarm Coordination
/programmatic-usage/swarm-coordination
typescript
import { createSwarm } from '@claude-flow/swarm';
// Create a hierarchical swarm
const swarm = await createSwarm({
topology: 'hierarchical',
maxAgents: 8,
strategy: 'specialized'
});
// Spawn agents
await swarm.spawn('coder', { name: 'coder-1' });
await swarm.spawn('tester', { name: 'tester-1' });
await swarm.spawn('reviewer', { name: 'reviewer-1' });
// Coordinate a task
const result = await swarm.orchestrate({
task: 'Implement user authentication',
strategy: 'adaptive'
});
// Shutdown
await swarm.shutdown({ graceful: true });