Skip to content

Swarm (worktree workers)

The swarm subcommand runs several workers in parallel, each in its own git worktree on its own branch. Because every worker gets an isolated checkout, they cannot step on each other’s files. The results come back as JSON.

Give the swarm a worker count and a command to run in each worktree:

Terminal window
wayland-core swarm --workers 4 --worker-command "wayland-core --force 'Fix the failing test in this crate'"

The worker command is argv-style: it is split on whitespace, the first token is the program (resolved against PATH), the rest are arguments. There is no shell interpretation, so quoting and pipes are not expanded.

Terminal window
wayland-core swarm \
--workers 4 \
--worker-command "<cmd>" \
--repo /path/to/repo \
--base-branch main \
--branch-prefix swarm/cli \
--timeout 5m \
--task "refactor-pass"
FlagMeaningDefault
--workersNumber of parallel workers (minimum 1)required
--worker-commandargv-style command run in each worktreerequired unless --brief
--repoRepository root the swarm operates oncurrent directory
--base-branchBranch each worktree is created frommain
--branch-prefixPrefix for each worker’s branchswarm/cli
--timeoutPer-worker wall-clock limit (humantime, e.g. 30s, 5m)1h
--taskFree-form telemetry labelcli-swarm

Instead of individual flags, a TOML brief can describe the whole run. The brief overrides all the individual flags:

task = "refactor-pass"
base_branch = "main"
worker_branch_prefix = "swarm/cli"
worker_command = ["wayland-core", "--force", "Apply the lint fixes"]
timeout = "5m"
env = [["RUST_LOG", "info"]]
Terminal window
wayland-core swarm --workers 4 --brief swarm.toml

Each worker runs on its own branch under the prefix you set. When the swarm finishes it prints the collected results as pretty JSON to stdout, then cleans up the worktrees. Review the branches to see what each worker produced.