A complete, ready-to-clone template for setting up an agentic coding environment on a VPS. This system enables AI-orchestrated software development through:
- Multi-agent task decomposition and parallel execution
- Autonomous coding agents (Claude Code, Codex)
- Automated monitoring and quality gates
- Structured state tracking for continuous improvement
You → Coordinator AI → Dispatch Agents → Monitor → Verify → Report Results
- You describe what needs to be built
- Coordinator (Athena) decomposes work into discrete tasks (beads)
- Agents work autonomously in isolated environments
- Watchers monitor progress without blocking
- Verifiers check quality automatically
- System learns from structured execution history
┌─────────────────────────────────────────────┐
│ User Interface (Telegram/SSH/Web) │
└────────────────┬────────────────────────────┘
│
┌────────────────▼────────────────────────────┐
│ OpenClaw Gateway (Orchestration Hub) │
│ + MCP Agent Mail (Agent Messaging) │
└────────────────┬────────────────────────────┘
│
┌────────────────▼────────────────────────────┐
│ Agent Swarm (dispatch.sh) │
│ • Claude Code agents │
│ • Codex agents │
│ • Isolated tmux sessions │
└────────────────┬────────────────────────────┘
│
┌────────────────▼────────────────────────────┐
│ Monitoring (Argus + Watchers) │
│ • Service health checks │
│ • Agent completion detection │
│ • Automated recovery │
└─────────────────────────────────────────────┘
See docs/architecture.md for detailed architecture documentation.
git clone https://github.com/your-username/vps-setup.git
cd vps-setup
chmod +x setup.sh
./setup.shThis installs:
- Core system tools (git, jq, tmux, node)
- OpenClaw + MCP Agent Mail
- Claude Code CLI
- Agent dispatch system
- Workspace templates
- Recommended utilities
# GitHub
gh auth login
# Git identity
git config --global user.name "Your Name"
git config --global user.email "your@email.com"
# Claude Code
claude login
# Tailscale VPN (optional but recommended)
sudo tailscale up
# OpenClaw
openclaw onboard# Edit identity files
nano ~/.openclaw/workspace/SOUL.md # AI coordinator identity
nano ~/.openclaw/workspace/USER.md # Your profile
nano ~/.openclaw/workspace/TOOLS.md # Server info# OpenClaw Gateway
sudo cp services/openclaw-gateway.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now openclaw-gateway
# MCP Agent Mail
sudo cp services/mcp-agent-mail.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now mcp-agent-mail
# Argus (optional ops watchdog)
cd ~/argus
cp argus.env.example argus.env
nano argus.env # Add TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID
./install.sh# Create a test task
br create --title "Test agent dispatch" --priority 1
# Get the bead ID from output (e.g., "abc123")
BEAD_ID="abc123"
# Dispatch an agent
cd ~/.openclaw/workspace
./scripts/dispatch.sh $BEAD_ID ~/your-repo claude "Create a simple hello world script"
# Monitor agents
./scripts/poll-agents.sh
# View results
cat state/results/$BEAD_ID.json | jqvps-setup/
├── README.md # This file
├── setup.sh # Main installation script
├── .gitignore # Excludes secrets and logs
│
├── services/ # systemd service unit files
│ ├── openclaw-gateway.service
│ ├── mcp-agent-mail.service
│ ├── athena-web.service
│ └── argus.service
│
├── argus/ # Ops watchdog (AI-powered monitoring)
│ ├── argus.sh
│ ├── collectors.sh
│ ├── actions.sh
│ ├── prompt.md
│ ├── install.sh
│ ├── argus.env.example
│ └── README.md
│
├── swarm/ # Agent dispatch system
│ ├── scripts/
│ │ ├── dispatch.sh # Core agent launcher
│ │ ├── verify.sh # Quality verification
│ │ ├── agent-preflight.sh # Environment checks
│ │ └── poll-agents.sh # Status monitoring
│ ├── templates/ # Prompt templates
│ │ ├── feature.md
│ │ ├── bug-fix.md
│ │ ├── refactor.md
│ │ └── ...
│ └── README.md
│
├── workspace/ # Workspace template files
│ ├── AGENTS.md # Entry point for AI
│ ├── TOOLS.md # Server reference
│ ├── SOUL.md.example # AI identity template
│ ├── USER.md.example # User profile template
│ └── memory/.gitkeep
│
├── skills/ # Reusable AI workflows
│ ├── coding-agents/SKILL.md # Swarm orchestration skill
│ └── README.md
│
├── tools/ # CLI tool installation
│ └── README.md # Tool descriptions
│
└── docs/ # Documentation
├── architecture.md # System architecture
├── orchestration.md # Existing docs
├── services.md
├── tooling.md
└── multi-agent.md
Beads are structured task records tracked by the br tool:
br create --title "Add user authentication" --priority 1
br list
br show <bead-id>
br update <bead-id> --status doneThe dispatch.sh script handles the full agent lifecycle:
./scripts/dispatch.sh <bead-id> <repo-path> <agent-type> "<prompt>" [template-name]Parameters:
bead-id: Unique task identifierrepo-path: Absolute path to repositoryagent-type:claudeorcodexprompt: Task instructionstemplate-name: (optional) Template identifier
What it does:
- Validates environment (preflight checks)
- Creates tmux session on shared socket
- Launches agent with prompt
- Starts background watcher
- Detects completion (status file / markers / prompt)
- Writes run and result records
- Runs verification
- Cleans up session
- Notifies coordinator
All execution state is stored as JSON in ~/.openclaw/workspace/state/:
state/
├── runs/<bead-id>.json # Full execution metadata
├── results/<bead-id>.json # Terminal status + verification
└── watch/<bead-id>.* # Runtime files (temporary)
Run record includes:
- Agent type and model
- Timing information
- Exit codes
- Verification results
- Full prompt
Result record includes:
- Terminal status (done/failed/timeout)
- Reason for completion
- Retry information
- Output summary
Active agent monitoring:
./scripts/poll-agents.sh
tmux -S /tmp/openclaw-coding-agents.sock list-sessionsService monitoring (Argus):
- Runs every 5 minutes
- AI-powered decision making (Claude Haiku)
- Can restart services, kill orphans, send alerts
- Logs all observations
System logs:
journalctl -u openclaw-gateway -f
journalctl -u mcp-agent-mail -f
journalctl -u argus -f-
Create a task (bead)
br create --title "Implement feature X" --priority 1 -
Dispatch agent
./scripts/dispatch.sh abc123 ~/my-project claude "$(cat swarm/templates/feature.md)"
-
Monitor progress
./scripts/poll-agents.sh
-
Check results
cat state/results/abc123.json | jq -
Review and close
br update abc123 --status done
The coordinator (Athena) can dispatch multiple agents in parallel:
- Decompose work into independent tasks
- Create beads for each task
- Dispatch all agents (non-blocking)
- Schedule single check after expected duration
- Collect results when check runs
- Report back to user
Key principle: Never poll in a loop. Fire and forget, with one delayed check.
Templates are pre-written prompts for common task types:
PROMPT=$(cat swarm/templates/bug-fix.md)
./scripts/dispatch.sh abc123 ~/project claude "$PROMPT" bug-fixAvailable templates:
feature.md- New feature implementationbug-fix.md- Bug fixingrefactor.md- Code refactoringdocs.md- Documentationscript.md- Script creationcode-review.md- Code review
The verify.sh script runs automatic quality checks:
./scripts/verify.sh ~/project abc123Checks:
- Lint changed files
- Run tests (npm/cargo)
- Run bug scanner (ubs)
Results are included in the run record's verification field.
Argus is an independent AI-powered monitoring service:
What it monitors:
- Service health (openclaw-gateway, mcp-agent-mail)
- System resources (memory, disk, CPU)
- Orphaned processes
- Agent activity
- Athena web API
What it can do:
- Restart failed services
- Kill stuck processes
- Send Telegram alerts
- Log observations
How it works:
- Runs every 5 minutes
- Collects metrics
- Sends to Claude Haiku
- LLM decides actions
- Executes allowlisted operations only
See argus/README.md for full documentation.
Service isolation:
- Each systemd service runs as dedicated user
- Minimal filesystem access via systemd hardening
- No network access except required ports
Agent sandboxing:
- Agents run in tmux sessions (process isolation)
- Limited to specified repository paths
- No sudo/root access
Secret management:
- API keys in
.envfiles (not in git) - Service environment files in
/etc/or~/ - Systemd
EnvironmentFilefor secure loading
Network:
- OpenClaw exposed only on Tailscale VPN
- Other services localhost-only
- SSH access via Tailscale
See tools/README.md for installation instructions.
Core:
br/bv- Work trackingclaude- Claude Code CLIopenclaw- OpenClaw CLIjq- JSON processingtmux- Terminal multiplexer
Optional:
cass- Agent session searchntm- Named tmux managerubs- Bug scannerrtk- Token reduction proxydcg- Destructive command guard
- Architecture - System design and data flow
- Swarm System - Agent dispatch details
- Skills - Reusable workflows
- Tools - CLI tool reference
- Argus - Ops watchdog documentation
- Multi-Agent - Multi-agent architecture research
Agents won't start:
./scripts/agent-preflight.sh claude ~/projectServices not running:
sudo systemctl status openclaw-gateway
sudo systemctl status mcp-agent-mail
journalctl -u openclaw-gateway -n 50Orphaned sessions:
tmux -S /tmp/openclaw-coding-agents.sock list-sessions
tmux -S /tmp/openclaw-coding-agents.sock kill-session -t agent-abc123Argus issues:
sudo journalctl -u argus -n 50
cat ~/argus/logs/argus.log
cat ~/argus/logs/last_response.json | jqThis is a template repository. To adapt for your own use:
- Fork this repository
- Update placeholders in service files (your-user, your-hostname)
- Customize workspace files (SOUL.md, USER.md, TOOLS.md)
- Add project-specific templates to
swarm/templates/ - Extend verification checks in
verify.sh - Document your customizations
MIT
Build faster. Think clearer. Let the swarm handle the details.