agentleFS
scoobydont-666scoobydont-666/shared-claude-skills/skills/hydra-swarm/SKILL.md

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.

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
  1. Very specific:

    Create a large task: tasks create "Generate 50 CPA questions across all sections"

    line 119
  2. Distinctive:

    When ALL subtasks complete, parent auto-completes

    line 123

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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 status

Create 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 30

Claim a task

python3 <coordination-tool-root>/src/swarm_cli.py tasks claim task-001

Claim 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.md

Complete + 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-001

Task Decomposition — apply the suggested split

python3 <coordination-tool-root>/src/swarm_cli.py tasks decompose task-001 --apply

Send 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 inbox

Share an artifact

python3 <coordination-tool-root>/src/swarm_cli.py artifacts share /path/to/results.md

List 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>/a

Show what the last instance left for you

python3 <coordination-tool-root>/src/swarm_cli.py context --project <repo-path>/a

Health check

python3 <coordination-tool-root>/src/swarm_cli.py health

Force git sync

python3 <coordination-tool-root>/src/swarm_cli.py sync

Task Decomposition Workflow

  1. Create a large task: tasks create "Generate 50 CPA questions across all sections"
  2. Suggest decomposition: tasks decompose task-001 — shows subtasks based on rules
  3. Apply if acceptable: tasks decompose task-001 --apply — creates subtask files, parent moves to decomposed state
  4. Subtasks can be claimed independently by different nodes
  5. 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

  • --isolate on claim creates a git worktree branch swarm/<hostname>/<task-id>
  • Each instance works in its own branch, no merge conflicts
  • On completion: --merge merges to main, --branch pushes 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
  • context command 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/)

ModulePurpose
registry.pyAgent presence, heartbeat, capability detection
orchestrator.pyWork queue, claim/release, priority matching, plan scanning
events.pyEvent bus (NFS JSON), query by time/type/project
sync_engine.pyAuto git pull/push, config sync, dirty repo detection
conflicts.pyProject/file conflict detection, GPU slot management
session.pyFull 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, deregisters

Node Map

HostIPRoleCapabilities
gpu-host<internal-ip-1>NFS primarydocker, gpu, ollama, vpn
primary-host<internal-ip-2>NFS replicadocker, vpn
worker-host-1<internal-ip-3>clientcustom
worker-host-2<internal-ip-4>clientcustom

Task States

  • pending — available for claiming
  • claimed — being worked on by a specific host
  • completed — done
  • decomposed — split into subtasks (auto-completes when all subtasks done)

Node States

  • active — instance running, available for coordination
  • idle — no active session
  • offline — no heartbeat for >5 minutes
  • busy — 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

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.