Build with SwarmBuild guide

Build your own AI agent, step by step

With Swarm, your own AI agent is a worker: a name, a role (coder, finder, designer or reviewer) and standing instructions it follows on every job. Install Swarm on a Linux machine, connect a model, and tell your AI what the agent should do; it creates the worker with one call and hands it jobs. Each job comes back with a report, a diff if it changed code, and what it cost. We built one in about ten minutes on a fresh machine; its first job cost $0.02.

What you are building

An agent that does one kind of job well, every time, without you explaining it again. Ours is todo-triager: it reads a repository, finds every TODO and FIXME, says how big each fix is and which to do first, and changes nothing. Swap in your own: a release-notes writer, a dependency checker, an invoice reader, a site checker.

You need an Ubuntu 24.04 x86-64 machine (your PC, a VPS or a cloud VM) and a model: your ChatGPT plan, your Claude plan through Claude Code, or an API key. We used a fresh Google Cloud VM and a Gemini API key.

1. Install Swarm

One line, from your own account. On our fresh VM it took 70 seconds and installed Swarm v0.1.59, listening on 127.0.0.1 only.

Shell
curl -fsSL https://swarmagent.dev/install | sudo bash

Or skip the typing: paste "Read swarmagent.dev/llms.txt and set up Swarm on this machine for me" into Claude Code, Codex or ChatGPT, and it runs the install itself.

2. Connect your AI and a model

Your AI drives Swarm through its MCP tools. In Claude Code:

Shell
claude plugin marketplace add swarm-agent/swarm
claude plugin install swarm@swarm

Then connect a model. Your AI starts the ChatGPT sign-in or the Claude Code one for you; an API key you add yourself, so it never passes through chat:

Shell
sudo bash /var/lib/swarm-headless/install.sh key google < key-file

Swarm then picks a recommended model for each role. On our machine: Gemini 3.8 Flash for the coder, finder and designer, Gemini 4 Argon for the reviewer.

3. Tell Swarm where your work is

A project is a name and your folders. Nothing in them changes; Swarm reads them and writes a project.md that every job sees.

Say this to your AI

My code is in /srv/tally. Make a Swarm project for it.

  • swarm_create_project

Project "tally" created with /srv/tally.

4. Create the agent

Say what it does, in plain words. Your AI turns that into one call: a name, a role and standing instructions. The role decides what it may do: a finder reads and reports, a coder changes code on its own branch, a designer works on pages and copy, a reviewer checks other agents' work.

Say this to your AI

Make me an agent that triages the TODO and FIXME comments in my code: where each one is, what it asks for, how big the fix is and which to do first. It must not change anything. Keep it under $2 a day.

  • swarm_deploy_worker
swarm_deploy_worker
{
  "name": "todo-triager",
  "role": "finder",
  "instructions": "You triage TODO and FIXME comments. Find every TODO and FIXME in the repository. For each one, say where it is, what it asks for, how big the fix is (small, medium, large) and which one to do first. Change nothing. End with a short ranked list.",
  "budget": { "daily_usd": 2 }
}

Swarm answered with the new worker, active, on the finder's default model:

JSON
{"deployed": true, "worker": {"id": "worker_35fdf250…", "name": "todo-triager", "role": "finder",
  "lifecycle_state": "active", "model": {"provider": "google", "model": "gemini-3.8-flash", "thinking": "low"}}}

5. Give it a job

Say this to your AI

Have todo-triager go through the tally project.

  • swarm_give_job
  • swarm_get_job

The job starts at once and runs on its own branch, so your folder is never touched while it works. Your AI waits on it and reads the result. Ours came back with:

What came back
Statusneeds_review: done, waiting for you to read it
FindingsTwo, in tally.sh: a FIXME (a total line printed for a single file), ranked first as small; a TODO (skip binary files), ranked second as medium
Cost$0.024: 8,455 tokens over 8 model turns on Gemini 3.8 Flash

An excerpt of its report, unedited:

markdown
1. tally.sh:13 (FIXME: the total line is printed even for a single file)
   Small (Fix first: bug fix addressing incorrect output behavior).
2. tally.sh:8 (TODO: skip binary files instead of counting them)
   Medium (Fix second: feature addition requiring detection mechanism and test coverage).

6. Make it run without you

  • On a schedule: "Run todo-triager every Monday at 9." Your AI calls swarm_schedule_job with a cron and your timezone. See AI agents on a schedule.
  • With a reviewer: "After every coder job, have a reviewer check it and send it back if it is wrong." That is a workflow; see agentic workflows.
  • Changing code: give your agent the coder role and it works on its own branch; you merge what you like. See build an AI coding agent.
  • Inside your app: a support chat or an assistant for your customers is a different kind of agent, with only the tools your app gives it. See an AI agent for your website.

Keeping it safe and cheap

  • The budget stops the worker for the day once it reaches its limit. swarm_list_workers shows what it spent today.
  • A finder only reads and reports. Only a coder (or designer) changes files, and only on its own branch until you merge.
  • Keys stay out of chat: you type them into Swarm yourself, and agents see stand-ins.

Questions

How do I build my own AI agent?

Install Swarm on a Linux machine, connect a model, and ask your AI for a worker: a name, a role (coder, finder, designer or reviewer) and standing instructions. It creates it with swarm_deploy_worker and hands it jobs with swarm_give_job. Each job returns a report, a diff if code changed, and its cost.

Do I need to write code to build an AI agent?

No. With Swarm you describe the agent to your AI (Claude Code, Codex or ChatGPT) and it makes the calls. If you want to build an agent into your own program, the SDK and HTTP API do the same things in code.

What did the agent in this guide cost to run?

Its first job cost $0.024 (8,455 tokens on Gemini 3.8 Flash). Costs depend on the model and the job; every job reports its own.

Can I build an AI agent for free?

Swarm is free and open source. You pay only for the model: on a ChatGPT or Claude plan you already have, or per token with an API key.

What machine do I need?

An Ubuntu 24.04 x86-64 machine you can use sudo on: a PC, a VPS or a cloud VM. On a Mac, run Swarm on a server and drive it from the Mac.

Updated 28 October 2026