AI agent swarm orchestration for production codebases.
A shell-first toolkit for spawning coding agents into isolated git worktrees, tracking their progress, automating PR reviews, and driving a safe human-in-the-loop merge loop. Zero LLM cost when idle — monitoring scripts only wake the orchestrator when something needs attention.
task/prompt
│
▼
spawn-agent.sh ─────────────────────────────────────┐
│ │
├── create worktree from integration branch │
├── write prompt + inject AGENTS.md │
└── start agent in tmux session │
│
agent codes → tests → commits → pushes → opens PR │
│
┌─────────────────────────────────────────────────┘
▼
swarm-monitor.sh (*/3 cron) ──── check-agents.sh
│
├── CI failed? → wake orchestrator to fix
├── PR ready? → wake orchestrator to notify
├── conflict? → wake orchestrator to rebase
└── nothing changed? → exit silently (zero cost)
pr-manager.sh (*/5 cron)
│
├── auto-merge safe integration PRs
├── wake Sparky with structured JSON when a PR has unresolved review comments
├── wake Sparky with failed-job logs when CI is red
└── open integration→main sync PRs when queue drains
Sparky (the OpenClaw orchestrator) then aggregates, plans, and decides
whether to fix inline or delegate to a swarm agent. Bash never spawns
fix agents directly.
human reviews and merges main-targeted PRs
- OpenClaw — installed and authenticated
git— version controlgh— GitHub CLI, authenticated with repo + PR permissionstmux— agent sessions run herejq— JSON processing- Node.js — managed via NVM
- At least one coding agent CLI:
Clone directly into ~/.clawdbot — the repo IS the runtime directory:
git clone git@github.com:YOUR_USER/clawdbot.git ~/.clawdbot
cd ~/.clawdbot
cp .env.example .env
# Edit .env with your repos, GitHub owner, paths, etc.Coding agents need access to their provider's API. There are two ways to authenticate:
Option A: CLI OAuth login (recommended — no keys to manage)
Log in once on your machine, and all spawned agents inherit the session:
codex auth # OpenAI / Codex CLI
claude login # Anthropic / Claude Code
gemini auth # Google / Gemini CLICredentials are stored in your home directory (~/.codex/, ~/.claude/, etc.). Since spawn-agent.sh runs tmux as the same user, agents pick them up automatically.
Option B: API keys (for headless servers or CI environments)
Set keys in ~/.clawdbot/.env — only the ones you use:
OPENAI_API_KEY="sk-..." # Codex CLI
ANTHROPIC_API_KEY="sk-ant-..." # Claude Code
GEMINI_API_KEY="AIza..." # Gemini CLIspawn-agent.sh sources .env before launching agents, so keys are automatically available. .env is gitignored and never committed.
You can also set keys in your shell profile (~/.bashrc) — same effect.
Create the runtime directories:
mkdir -p logs prompts runners memorySet up crontab:
crontab -e# Agent pre-check (validate GitHub API, repos accessible)
*/10 * * * * /home/YOU/.clawdbot/agent-precheck.sh >> /home/YOU/.clawdbot/logs/precheck.log 2>&1
# PR manager (merge, notify Sparky on comments / CI failures, sync PRs)
*/5 * * * * /home/YOU/.clawdbot/pr-manager.sh >> /home/YOU/.clawdbot/logs/pr-manager.log 2>&1
# Swarm monitor (zero-LLM, wakes orchestrator only on events)
*/3 * * * * /home/YOU/.clawdbot/swarm-monitor.shclawdbot is the infrastructure — your OpenClaw agent is the brain that drives it. You need to tell your agent that ~/.clawdbot/ exists and how to use it.
Add this to your workspace AGENTS.md (or HEARTBEAT.md):
## Coding Agent Swarm
~/.clawdbot/ contains the swarm orchestration toolkit.
- Spawn agents: `~/.clawdbot/spawn-agent.sh <task-id> <repo-path> <branch-name> <agent: codex|claude|gemini> <model> <thinking: low|medium|high|xhigh> "<prompt>"`
- Check status: `~/.clawdbot/check-agents.sh`
- Clean up: `~/.clawdbot/cleanup-task.sh <task-id>`
- PR status: watch `~/.clawdbot/logs/pr-manager.log` (emitted every 5 minutes by `pr-manager.sh`).clawdbot ships two skills under skills/ that give your OpenClaw agent structured knowledge of the full lifecycle:
skills/swarm/SKILL.md— the swarm skill: spawning coding agents, choosing the right model, monitoring tmux sessions, delegating work.skills/pr-review-hygiene/SKILL.md— the pr-review-hygiene skill: how the orchestrator should consumepr-manager.sh's wake events, the triage → fix → push → verify → reply → resolve loop, and the rules for when NOT to resolve a thread.
Install both with a single loop that preserves each skill's directory name:
for skill in ~/.clawdbot/skills/*/; do
name=$(basename "$skill")
mkdir -p "$HOME/.openclaw/skills/$name"
cp "$skill/SKILL.md" "$HOME/.openclaw/skills/$name/SKILL.md"
doneOr install individually:
mkdir -p ~/.openclaw/skills/swarm ~/.openclaw/skills/pr-review-hygiene
cp ~/.clawdbot/skills/swarm/SKILL.md ~/.openclaw/skills/swarm/SKILL.md
cp ~/.clawdbot/skills/pr-review-hygiene/SKILL.md ~/.openclaw/skills/pr-review-hygiene/SKILL.mdWith the skills installed, you can just say "spawn a Codex agent to fix the auth bug in my-backend" (swarm) or let pr-manager.sh wake your agent with a structured review envelope (pr-review-hygiene). The agent loads the relevant skill and handles the full loop — worktree creation, prompt injection, thread replies + resolves, and reporting back.
You (chat with your OpenClaw agent)
↓
"Fix the auth bug and add the dashboard feature"
↓
OpenClaw agent reads swarm skill → calls spawn-agent.sh (×2)
↓
Coding agents work in isolated worktrees → push → open PRs
↓
swarm-monitor.sh (cron) detects CI failure / PR ready
↓
`openclaw cron wake` → wakes your agent
↓
Agent auto-fixes CI, resolves reviews, notifies you when ready
↓
You review and merge to main
The cron jobs (swarm-monitor.sh, pr-manager.sh) are the glue — they run pure bash with zero LLM cost, and only wake your OpenClaw agent when something actually needs attention.
AGENTS.md is injected into every spawned agent's worktree. This is where you encode your team's standards:
- TDD requirements
- Code style and conventions
- Git commit format
- PR description template
- Which skills to load
- What NOT to do
Edit it to match your workflow. The default covers TDD, conventional commits, and clean code.
All config lives in .env (gitignored). Copy .env.example and fill in your values:
# Required
CLAWDBOT_REPOS="owner/backend owner/frontend" # Space-separated repos
CLAWDBOT_GITHUB_OWNER="owner" # GitHub org or user
CLAWDBOT_PROJECTS_ROOT="$HOME/Projects" # Where repos are cloned
# Branch strategy
CLAWDBOT_INTEGRATION_BRANCH="development" # Agents target this
CLAWDBOT_MAIN_BRANCH="main" # Humans merge here
# Paths
CLAWDBOT_HOME="$HOME/.clawdbot" # This directory
CLAWDBOT_NODE_PATH="$HOME/.nvm/versions/node/v24.13.0/bin"
# Notifications (via OpenClaw)
CLAWDBOT_NOTIFY_CHANNEL="telegram"
CLAWDBOT_NOTIFY_TARGET="YOUR_CHAT_ID"
# Agent defaults
CLAWDBOT_DEFAULT_AGENT="codex"
CLAWDBOT_CODEX_MODEL="gpt-5.4"
CLAWDBOT_CLAUDE_MODEL="claude-opus-4-7"
CLAWDBOT_GEMINI_MODEL="gemini-2.5-pro"
# Optional
CLAWDBOT_SKILLS_PATH="$CLAWDBOT_PROJECTS_ROOT/antigravity-awesome-skills/skills"
CLAWDBOT_DEPENDABOT_REPO="owner/frontend" # Auto-merge dependabot PRs hereEvery script sources .env on startup with safe fallbacks, so existing env vars also work.
~/.clawdbot/
├── .env # Local config (gitignored)
├── .env.example # Template for .env
├── AGENTS.md # Instructions injected into every agent
├── README.md
├── LICENSE
├── spawn-agent.sh # Spawn a coding agent in a worktree
├── check-agents.sh # Check status of all tracked tasks (swarm)
├── cleanup-task.sh # Clean up finished task worktree
├── finalize-task.sh # Auto-called on agent exit
├── agent-precheck.sh # Validate GitHub API + repo access (swarm)
│
├── pr-manager.sh # GitHub PR watchdog — merges, notifies Sparky
├── pr-review-collector.sh # Emit unresolved review threads as JSON
├── swarm-monitor.sh # Zero-LLM swarm monitor (cron, 3 min)
│
├── skills/ # Orchestrator skills (copy into ~/.openclaw/skills/)
│ ├── swarm/SKILL.md # Spawning and orchestrating coding agents
│ └── pr-review-hygiene/SKILL.md # Consuming pr-manager wakes: triage, fix, reply, resolve
│
├── logs/ # Cron output (gitignored)
├── prompts/ # Agent prompt files (gitignored)
├── runners/ # tmux session metadata (gitignored)
├── memory/ # Agent memory files (gitignored)
└── *.json # State files (gitignored)
~/.clawdbot/spawn-agent.sh \
<task-id> \
<repo-path> \
<branch-name> \
<agent: codex|claude|gemini> \
<model> \
<thinking: low|medium|high|xhigh> \
"<prompt>"Example:
~/.clawdbot/spawn-agent.sh \
fix-auth-bug \
~/Projects/my-backend \
fix/auth-bug \
codex \
gpt-5.4 \
xhigh \
"Fix the auth refresh token race condition. Add tests. Open a PR against development."~/.clawdbot/check-agents.sh | jq .Returns JSON with task IDs, statuses, PR numbers, CI state, and recommended actions.
pr-manager.sh runs every 5 minutes via crontab and emits the current state
of every open PR to ~/.clawdbot/logs/pr-manager.log. For an on-demand
snapshot of just unresolved review threads, run the collector directly:
~/.clawdbot/pr-review-collector.sh | jq .Or trigger pr-manager.sh ahead of schedule:
~/.clawdbot/pr-manager.sh 2>&1 | tail -50~/.clawdbot/cleanup-task.sh <task-id>Removes the worktree, deletes the branch (if merged), and removes the task from the registry.
Two cron jobs form the core automation:
swarm-monitor.sh (every 3 min) — Pure bash, zero LLM cost. Reads check-agents.sh output and only wakes the OpenClaw orchestrator when:
- A PR's CI failed and needs a fix agent
- A PR is ready for merge/review
- A branch has merge conflicts
pr-manager.sh (every 10 min) — Handles repo-wide PR lifecycle:
- Auto-merges integration PRs when CI is green and reviews are approved
- Blocks merges if a release PR (integration→main) is already open
- Spawns isolated agents to fix unresolved review threads
- Spawns agents to fix CI failures
- Opens integration→main sync PRs when the dev queue is clear
- Notifies via OpenClaw when PRs need human attention
The result: agents code, push, get reviewed, fix review feedback, and re-push — all without human involvement until the final merge to main.
- Runtime
ghwrapper —spawn-agent.shgenerates aghshim in a temp dir that rejects PRs not targeting the integration branch - Worktree isolation — each task gets its own worktree; no cross-contamination
- Human-only main merges — PRs to main are never auto-merged
- State files — all automation state is in readable JSON files
- Cron announces deltas — only notifies when something changes, not on every run
- No direct pushes to main — enforced by convention and the gh wrapper
| Agent | CLI | Default flags |
|---|---|---|
| Codex | codex exec |
--dangerously-bypass-approvals-and-sandbox, configurable model + reasoning |
| Claude Code | claude |
--dangerously-skip-permissions, configurable model |
| Gemini | gemini |
--yolo, configurable model |
Adjust defaults in spawn-agent.sh or override via .env.
Coding agents perform better with domain-specific knowledge. We use Antigravity Awesome Skills — 883+ agentic skills for AI coding assistants.
git clone https://github.com/sickn33/antigravity-awesome-skills.git \
"$CLAWDBOT_PROJECTS_ROOT/antigravity-awesome-skills"Skills are referenced in AGENTS.md and loaded by agents at startup. Examples:
tdd-workflow— RED→GREEN→REFACTOR cycleclean-code— naming, readability, function designfastapi-pro— async Python + FastAPI patternsnextjs-best-practices— App Router conventionsdocker-expert— multi-stage builds, securitycode-reviewer— review guidelines, security scanning
Create your own skills too — it's just a SKILL.md file with instructions.
Browse the full catalog: sickn33/antigravity-awesome-skills
Since ~/.clawdbot is the repo itself:
cd ~/.clawdbot
git pull origin mainYour .env and state files are gitignored, so pulls are clean.
This project is inspired by @elvissun's article OpenClaw + Codex/ClaudeCode Agent Swarm: The One-Person Dev Team — the original write-up on using OpenClaw as an orchestration layer for parallel coding agents. Elvis described the architecture and workflow but didn't release the source code, so we built clawdbot as the open-source implementation.
MIT — see LICENSE.



