hydra-swarm
Skill1 starsChanged 5 months agoMITView on GitHub
Distributed Claude Code coordination v2 — autonomous multi-instance orchestration via NFS + git. Agent registry with heartbeat, priority work queue with capability matching, event bus for cross-agent context, auto git sync, GPU slot management, session lifecycle protocol. Replaces OpenClaw for self-hosted agent coordination.
In this repository32 other files it gives its agents.
- ansible-hardeningSkill
- budi-analyticsSkill
- claude-to-cursorSkill
- code-consistencySkill
- code-qualitySkill
- config-auditorSkill
- container-sandboxSkill
- cost-optimizerSkill
- cpa-tax-specialistSkill
- database-designSkill
- differential-reviewSkill
- fleet-managerSkill
- grill-meSkill
- inbound-syncSkill
- infosec-architectSkill
- insecure-defaultsSkill
- model-evaluationSkill
- modern-pythonSkill
- ms-office-suiteSkill
- openclaw-opsSkill
- prd-to-planSkill
- project-managementSkill
- property-based-testingSkill
- session-miserSkill
- session-miserSkill
- skill-updaterSkill
- supply-chain-risk-auditorSkill
- systematic-debuggingSkill
- tddSkill
- token-miserSkill
- verification-before-completionSkill
- write-a-prdSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 119
Create a large task: tasks create "Generate 50 CPA questions across all sections"
- Distinctive: line 123
When ALL subtasks complete, parent auto-completes
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
hydra-swarm — Multi-Instance Coordination
What This Does
Coordinates multiple Claude Code instances across the Swarm cluster using NFS-backed shared state at /opt/swarm/. Provides awareness of what other instances are doing, task queuing, messaging, artifact sharing, task decomposition, worktree isolation, and session summary context sharing.
Quick Reference
Check swarm status before starting work
python3 <coordination-tool-root>/src/swarm_cli.py statusCreate a task for another instance
python3 <coordination-tool-root>/src/swarm_cli.py tasks create "Task title" \
--desc "Description" --project <your-project-path> --priority high \
--requires gpu --minutes 30Claim a task
python3 <coordination-tool-root>/src/swarm_cli.py tasks claim task-001Claim with worktree isolation (conflict-free editing)
python3 <coordination-tool-root>/src/swarm_cli.py tasks claim task-001 --isolate --project <your-project-path>Complete a task
python3 <coordination-tool-root>/src/swarm_cli.py tasks complete task-001 --artifact results.mdComplete + merge worktree to main
python3 <coordination-tool-root>/src/swarm_cli.py tasks complete task-001 --merge --project <your-project-path>Complete + push branch only (another instance merges)
python3 <coordination-tool-root>/src/swarm_cli.py tasks complete task-001 --branch --project <your-project-path>Task Decomposition — suggest splitting a large task
python3 <coordination-tool-root>/src/swarm_cli.py tasks decompose task-001Task Decomposition — apply the suggested split
python3 <coordination-tool-root>/src/swarm_cli.py tasks decompose task-001 --applySend a message to another instance
python3 <coordination-tool-root>/src/swarm_cli.py message <gpu-host> "Need the RAG results from <your-project>"
python3 <coordination-tool-root>/src/swarm_cli.py message --broadcast "Deploying v2 in 5 min"Check inbox
python3 <coordination-tool-root>/src/swarm_cli.py inboxShare an artifact
python3 <coordination-tool-root>/src/swarm_cli.py artifacts share /path/to/results.mdList active worktrees across fleet
python3 <coordination-tool-root>/src/swarm_cli.py worktrees --project <your-project-path>View session summaries
python3 <coordination-tool-root>/src/swarm_cli.py summaries
python3 <coordination-tool-root>/src/swarm_cli.py summaries --project <repo-path>/aShow what the last instance left for you
python3 <coordination-tool-root>/src/swarm_cli.py context --project <repo-path>/aHealth check
python3 <coordination-tool-root>/src/swarm_cli.py healthForce git sync
python3 <coordination-tool-root>/src/swarm_cli.py syncTask Decomposition Workflow
- Create a large task:
tasks create "Generate 50 CPA questions across all sections" - Suggest decomposition:
tasks decompose task-001— shows subtasks based on rules - Apply if acceptable:
tasks decompose task-001 --apply— creates subtask files, parent moves todecomposedstate - Subtasks can be claimed independently by different nodes
- When ALL subtasks complete, parent auto-completes
Decomposition rules:
- "all sections" or "across" + CPA sections -> split per FAR/AUD/REG/BAR + validation
- "generate AND validate" -> split into generate + validate phases
- Multiple project names mentioned -> split per project
- Capabilities auto-inferred: ollama/gpu/docker keywords tag subtasks for routing
Worktree Isolation
--isolateon claim creates a git worktree branchswarm/<hostname>/<task-id>- Each instance works in its own branch, no merge conflicts
- On completion:
--mergemerges to main,--branchpushes branch only - Worktree paths and branches recorded in task YAML and artifacts
Session Summaries for Context Continuity
- On session end, a summary is auto-generated with files changed, decisions, context
- On session start, the hook loads the last relevant summary and injects into systemMessage
- This gives the new instance immediate context without re-exploring the project
contextcommand shows what the previous instance left for you
v2 Autonomous Behavior Rules
- Agents auto-register on session start, deregister on end
- Heartbeat every 60s — stale after 5 min, tasks auto-released
- Auto-claim highest-priority matching task (by capability)
- Emit events on commit, test, task completion — other agents consume
- Auto git pull when commit events arrive from other hosts
- GPU slot claiming prevents model contention
- Session summaries auto-generated from event stream
- Conflict detection: warn if two agents editing same project
- This is NOT advisory — agents act autonomously within the priority framework
v2 Modules (in <coordination-tool-root>/src/)
| Module | Purpose |
registry.py | Agent presence, heartbeat, capability detection |
orchestrator.py | Work queue, claim/release, priority matching, plan scanning |
events.py | Event bus (NFS JSON), query by time/type/project |
sync_engine.py | Auto git pull/push, config sync, dirty repo detection |
conflicts.py | Project/file conflict detection, GPU slot management |
session.py | Full lifecycle: start → heartbeat → work → events → end |
Session Protocol
from session import start_session, end_session
# On session start:
info = start_session(model="opus-4.6", project="<repo-path>")
# → registers agent, starts heartbeat, pulls repos, reads event catchup
# During work: events auto-emitted on commit/test/task completion
# On session end:
result = end_session()
# → pushes repos, syncs config, writes summary, deregistersNode Map
| Host | IP | Role | Capabilities |
| gpu-host | <internal-ip-1> | NFS primary | docker, gpu, ollama, vpn |
| primary-host | <internal-ip-2> | NFS replica | docker, vpn |
| worker-host-1 | <internal-ip-3> | client | custom |
| worker-host-2 | <internal-ip-4> | client | custom |
Task States
pending— available for claimingclaimed— being worked on by a specific hostcompleted— donedecomposed— split into subtasks (auto-completes when all subtasks done)
Node States
active— instance running, available for coordinationidle— no active sessionoffline— no heartbeat for >5 minutesbusy— active but do not interrupt
File Locations
- Project:
<coordination-tool-root>/ - NFS share:
<shared-coordination-root>/(mounted from primary or replica host) - Config:
<coordination-tool-root>/config/swarm.yaml - CLI:
<coordination-tool-root>/src/swarm_cli.py
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

