Build with SwarmBuild guide

Build an AI coding agent that works on your own machine

Swarm is open source (Apache 2.0) and runs coding agents on your own Linux machine. Your own coding agent is a worker with the coder role and standing instructions: how to keep changes small, which tests to run, how to write commits. Every job runs on its own branch and comes back with a report, a diff and its cost; nothing reaches your code until you merge. Ours did a real TODO with tests and docs in one job, for $0.68.

Why build your own instead of using one as-is

Every codebase has its rules: run these tests, keep diffs small, update the docs, write commits this way. A general coding agent learns them again each session. A coding agent of your own carries them in its standing instructions, so every job starts from them.

1. Give it its rules

Say this to your AI

Make a coding agent for the tally project. It keeps changes small, matches the style, adds a test for whatever it changes, runs ./test.sh until it passes, updates the README when behavior changes, and writes short commit messages.

  • swarm_deploy_worker
swarm_deploy_worker
{
  "name": "tally-maintainer",
  "role": "coder",
  "instructions": "You maintain the tally CLI (bash). On every job: keep the change small and focused, match the existing style, add or update a check in test.sh for what you change, run ./test.sh until it prints ok, and update README.md when behavior changes. Commit with a short message that says what changed."
}

It runs on the coder role's model unless you pin another one (model on the same call). Ours used Gemini 3.8 Flash with high thinking.

2. Give it a job

Say this to your AI

Have tally-maintainer do the TODO in tally.sh: skip binary files instead of counting them, and name each skipped file on stderr.

  • swarm_give_job
  • swarm_get_job

It worked on its own branch for 101 model turns (83,617 tokens, $0.68), ran the tests until they passed, and came back with one commit, skip binary files with notice to stderr, touching three files. The heart of the change:

tally.sh
-  # TODO: skip binary files instead of counting them
+  if [ -s "$f" ] && [ "$(file -b -L --mime-encoding -- "$f")" = "binary" ]; then
+    echo "skipping binary file: $f" >&2
+    continue
+  fi

And, as its instructions require, the checks it added to test.sh:

test.sh
+printf 'bin\0data\n' > "$tmp/b.bin"
+err=$(./tally.sh "$tmp/b.bin" 2>&1 >/dev/null)
+echo "$err" | grep -q "b.bin" || { echo "FAIL: stderr should name skipped file"; exit 1; }
+out=$(./tally.sh "$tmp/a.txt" "$tmp/b.bin" 2>/dev/null)
+echo "$out" | grep -q 'b.bin' && { echo "FAIL: binary file should be skipped"; exit 1; }

3. Read it, then merge

Your AI shows you the report and the diff. When you are happy, one call merges it into your folder; Swarm never pushes on its own.

Say this to your AI

Looks good, merge it.

  • swarm_deliver_job

Merged into main.

Not right? Send a correction to the same job (swarm_message_job); it continues on the same branch. Want every job checked first? Add a reviewer workflow.

What it can and cannot touch

  • It runs as Swarm's own user, in a branch of your folder. Your files change only when you merge.
  • By default its commands run on the machine without a sandbox and without permission prompts. install.sh sandbox on runs each project's jobs in gVisor; an environment gives a folder its own container with its toolchain.
  • It never sees your API keys: secrets reach agents only inside an environment, as stand-ins that Swarm swaps for the real value on the way out.

Open source, on your own plan

Swarm is Apache 2.0 (source on GitHub). Your coding agent can run on your ChatGPT plan, your Claude plan through Claude Code, or an API key from OpenAI, Anthropic, Google, OpenRouter or Fireworks, and every job reports what it cost.

Questions

Is there an open-source AI coding agent I can run myself?

Yes. Swarm is open source (Apache 2.0) and runs coding agents on your own Ubuntu 24.04 machine. OpenHands is another open-source option with a web control center.

How is my own coding agent different from Swarm's built-in coder?

It is the same coder role with your standing instructions added to every job, and optionally its own model and daily budget. Use the built-in coder for one-off work and your own for work with rules you would otherwise repeat.

Can it break my code?

Each job runs on its own branch; your folder changes only when you merge. A reviewer workflow can check every job first.

What did the job in this guide cost?

$0.68: 101 model turns and 83,617 tokens on Gemini 3.8 Flash with high thinking, including writing tests and running them until they passed.

Which models can it use?

Any model your connected providers offer: through your ChatGPT plan, your Claude plan through Claude Code, or API keys for OpenAI, Anthropic, Google, OpenRouter or Fireworks.

Updated 28 October 2026