ClawSquad is a TypeScript CLI for provisioning multi-agent squads into an existing OpenClaw home.
It treats a squad as data:
- a squad template is just a directory
clawsquad.jsondefines roles and runtime settingsvars/*.jsonprovide role dataroles/*/*.template.mddefine prompt filesapplyrenders and syncs that project into OpenClaw
ClawSquad is a team compiler and provisioner, not a second runtime.
Example one-shot page built through the squad after about 100 minutes of running:
Prompt sent to the lead agent for that run:
ClawSquad ships with built-in templates:
task-squadexample-team
task-squad is the default and is intended for the integrated ClawSquad + ClawTask + Clawco flow on an existing OpenClaw host.
It uses:
leadas the internal coordinatordeveloperas the coding workerrevieweras the verification gate
The template bakes in a stricter role contract:
leadcoordinates only: plans, delegates throughclawtask, checks work against the plan, and queues retries throughclawtaskinstead of coding directlyleadmust never start Codex ACP, open a direct implementation run, or otherwise step into the developer lane, even when implementation is blockeddeveloperalone owns implementation and is instructed to use Codex through ACP whenever coding work is requiredreviewerdecides approve or reject based on plan fit, regressions, and evidence, records an explicit review verdict, and sends work back when the handoff is weakreviewerusesclawtask status --set completedonly for approval, andclawtask status --set failedfor changes requested or any non-approval outcome- every role is instructed to use
clawtask --project <squad-dir>so the human-facing prompt path and background listeners stay on the same runtime DB
That means the intended loop is:
leadplans and creates the implementation taskdeveloperimplements and closes the task withclawtaskreviewerrecords areview_verdictevent and closes the review task withcompletedonly for approval orfailedfor changes requested- if rejected,
leadopens the next retry task inclawtaskinstead of taking over implementation work
example-team remains available as a smaller example setup with:
leaddeveloper
The intended flow is:
leadtalks to the user, plans, and reviewsdeveloperimplements and self-verifiesleadreports progress and decides whether the result is ready
initshould copy from a real template directory, not from hardcoded strings in the CLI- built-in templates and user templates follow the same project shape
- role ids are not special;
mainis not reserved by ClawSquad - the default integrated squad avoids
mainso it does not collide with a user's human-facing entry agent - if you want a role to target
workspace, setworkspaceDirexplicitly - if you want no
agentDir, set"agentDir": null
- Node.js 22+
pnpmrecommended- OpenClaw installed if you want to run
doctororapply
pnpm install
pnpm buildRun from source:
pnpm dev -- helpRun the built CLI:
node dist/cli.js helpCreate a new squad from the built-in template:
pnpm dev -- init ~/Documents/my-squad
cd ~/Documents/my-squadRender role templates:
pnpm --dir /path/to/clawsquad dev -- render .Validate the project and target OpenClaw home:
pnpm --dir /path/to/clawsquad dev -- doctor .Inspect the exported machine-readable topology:
pnpm --dir /path/to/clawsquad dev -- topology .Run a safe sandbox apply in /tmp:
pnpm --dir /path/to/clawsquad dev -- apply . --dry-runApply to the configured OpenClaw home without restarting the gateway:
pnpm --dir /path/to/clawsquad dev -- apply . --no-restartYou can initialize from your own template directory instead of a built-in one:
pnpm dev -- init ~/Documents/my-team --template /path/to/team-templateA template directory is just a complete ClawSquad project skeleton that already contains:
clawsquad.jsonvars/*.jsonroles/*/*.template.md
init copies that directory into the target location.
Copies a new squad project from a built-in or custom template.
Notes:
- built-in templates live under
templates/ --forceoverwrites files that exist in the target template copyinitdoes not generate templates in code
Renders all role templates into the configured render directory.
Default:
.clawsquad/rendered/
Behavior:
- files ending in
.template.mdare rendered - legacy
.tplfiles are still supported - non-template files are copied as-is
- the rendered role directory is cleaned before each render
Checks:
- the manifest can be loaded
- the target OpenClaw home exists
openclaw.jsonexists- each role has template files
openclaw config validatesucceeds against the configured target home
Performs the full provisioning flow:
- render templates
- merge role settings into
openclaw.json - optionally validate with
openclaw config validate - sync rendered files into each target workspace
- write
.clawsquad/runtime/topology.jsonfor downstream tooling - optionally restart the OpenClaw gateway
Defaults:
- validation is on
- gateway restart is off
- config backup is on
During apply, ClawSquad also keeps the OpenClaw ACP / agent-to-agent allowlists in sync with the squad's role ids so newly provisioned agents can coordinate immediately.
With --dry-run, ClawSquad:
- creates a sandbox OpenClaw home under
/tmp/clawsquad-dryrun-* - copies the current config and any referenced workspaces or agent dirs into that sandbox
- rewrites OpenClaw-home-relative absolute paths to point at the sandbox copy
- runs the normal apply flow there
- never restarts the live gateway
Prints the machine-readable topology JSON used by downstream tooling such as clawtask snapshot and clawco.
The same payload is written to:
.clawsquad/runtime/topology.json
whenever apply succeeds.
For the integrated stack, your OpenClaw instance should have:
- ACP enabled
- agent-to-agent tools enabled
- a running gateway
ClawSquad apply will keep the per-agent allowlists aligned with the squad roles, but it does not replace first-time OpenClaw onboarding. If your host has never enabled ACP or gateway services, run the normal OpenClaw onboarding/configuration flow first.
If you enable ACP, install the acpx runtime plugin, or change ACP plugin permissions on an already-running host, restart the gateway before testing delegated coding work:
openclaw gateway restartThe default integrated template lives at templates/task-squad.
Its shape is:
task-squad/
├── clawsquad.json
├── vars/
│ ├── shared.json
│ ├── lead.json
│ ├── developer.json
│ └── reviewer.json
└── roles/
├── lead/
│ ├── AGENTS.template.md
│ ├── HEARTBEAT.template.md
│ ├── IDENTITY.template.md
│ ├── SOUL.template.md
│ ├── TOOLS.template.md
│ └── USER.template.md
└── developer/
├── AGENTS.template.md
├── HEARTBEAT.template.md
├── IDENTITY.template.md
├── SOUL.template.md
├── TOOLS.template.md
└── USER.template.md
└── reviewer/
├── AGENTS.template.md
├── HEARTBEAT.template.md
├── IDENTITY.template.md
├── SOUL.template.md
├── TOOLS.template.md
└── USER.template.md
Minimal example:
{
"name": "my-team",
"roles": [
{
"id": "main",
"templatesDir": "./roles/main"
}
]
}Example with two roles:
{
"name": "example-team",
"description": "Lead coordinates the work, developer implements and self-verifies.",
"openclawHome": "~/.openclaw",
"sharedVarsFile": "./vars/shared.json",
"apply": {
"renderedDir": ".clawsquad/rendered",
"backupConfig": true,
"validateConfig": true,
"restartGateway": false
},
"roles": [
{
"id": "lead",
"templatesDir": "./roles/lead",
"varsFile": "./vars/lead.json",
"workspaceDir": "workspace-lead",
"agentDir": "agents/lead/agent",
"subagents": ["developer", "reviewer"],
"lane": "command"
},
{
"id": "developer",
"templatesDir": "./roles/developer",
"varsFile": "./vars/developer.json",
"lane": "execution"
},
{
"id": "reviewer",
"templatesDir": "./roles/reviewer",
"varsFile": "./vars/reviewer.json",
"lane": "quality"
}
]
}Top-level fields:
name: required squad namedescription: optional squad descriptionopenclawHome: optional OpenClaw home; defaults to~/.openclawsharedVarsFile: optional JSON vars merged into every rolelane: optional Clawco visualization lane (command,planning,research,execution, orquality)apply: optional apply-time settingsroles: required list of role definitions
Role fields:
id: required unique role idname: optional display namedescription: optional role summarytemplatesDir: required template directoryvarsFile: optional role-specific vars JSONworkspaceDir: optional workspace path relative toopenclawHomeagentDir: optional agent directory path relative toopenclawHome; setnullto disable itsubagents: optional list written tosubagents.allowAgentsbindings: optional list of bindings managed by this roleruntime.model: optional model hint written intoopenclaw.jsonruntime.toolsProfile: optional tools profile written intoopenclaw.json
Default path behavior:
- if
workspaceDiris omitted, ClawSquad usesworkspace-<role-id> - if
agentDiris omitted, ClawSquad usesagents/<role-id>/agent - no role id gets special treatment
Bindings are defined per role, and apply materializes them with agentId = role.id.
Example:
{
"id": "lead",
"templatesDir": "./roles/lead",
"bindings": [
{
"comment": "lead inbox",
"match": {
"channel": "discord",
"peer": {
"kind": "direct",
"id": "user-123"
}
}
}
]
}Supported binding fields:
type: optional,"route"or"acp"comment: optional labelmatch.channel: required channel idmatch.accountId: optional account idmatch.peer: optional peer selectormatch.guildId: optional guild scopematch.teamId: optional team scopematch.roles: optional role ids for role-based routingacp: optional ACP config whentypeis"acp"
Available token roots:
team.*role.*vars.*openclaw.*paths.*
Example:
# AGENTS.md
You are {{role.name}} in {{team.name}}.
- Mission: {{vars.mission}}
- Workspace: {{paths.workspace}}Behavior:
- missing template tokens are treated as errors
- arrays and objects are rendered as JSON
- rendered output is deterministic from manifest + vars + templates
ClawSquad updates three kinds of state:
It upserts entries under agents.list in openclaw.json.
Managed fields today:
idnameworkspaceagentDirmodeltools.profilesubagents.allowAgentsbindings
It syncs rendered files into each target workspace and tracks managed files with:
.clawsquad-managed.json
It also writes:
.clawsquad-state.json
inside the target OpenClaw home so stale managed bindings can be replaced safely.
Build:
pnpm buildTest:
pnpm testCurrent tests cover:
- built-in template initialization
- custom template initialization
- manifest loading
- template rendering and var merging
- missing template token failures
- OpenClaw config merging
- stale managed workspace file cleanup during apply
- dry-run sandbox apply

