---
name: agent-fleet
description: Run a self-healing software factory of cheap AI agents on a laptop plus one box, with one task board as the only truth, one integration train as the only door to main, oracles before edits, and a watch loop that rates and improves itself. Use when setting up, auditing, or scaling multi-agent coding fleets.
---

# minifleet: a software factory your agent builds for you

You do not install this. A coding agent reads it and builds a fleet that fits one person's repo, machines and budget. This file is the spec the agent builds to, and it is also the rubric the finished fleet is graded by. It is a set of contracts and rules, and it is not a framework. Each rule has a failure behind it, and those failures are listed in `references/failures.md`.

## Read this first: fetch the raw files

Web fetch tools often summarize a page, and a summary drops the exact shapes, regexes and numbers that this skill depends on. Please fetch every file as raw text with `curl -sL` and read the whole file. These are the absolute URLs.

- `curl -sL https://minifleet.dev/skill` (this file)
- `curl -sL https://minifleet.dev/skill/references/build.md` (the build order, with one acceptance check per step, the single machine path, and the glossary)
- `curl -sL https://minifleet.dev/skill/references/contracts.md` (table shapes, the lifecycle table, verbs, prompt lint, formulas, guards)
- `curl -sL https://minifleet.dev/skill/references/failures.md` (the failure catalog)
- `curl -sL https://minifleet.dev/skill/references/tick.md` (the watch tick and its cost cap)
- `curl -sL https://minifleet.dev/skill/references/machines.md` (adding a second machine)
- `curl -sL https://minifleet.dev/skill/references/lessons.md` (what worked and what did not)
- `curl -sL https://minifleet.dev/skill/references/example-fleet.md` (one real fleet, as an example)

## Proven by a fresh build

A fresh agent that had only the public skill built a working minifleet on a sample repo in 14 minutes for $0. Three tasks landed end to end, and one rebase conflict was returned to its author and landed on the second try. That build also produced 18 findings where the skill had made a newcomer guess, and this version applies all of them.

## The shape in one paragraph

Humans write intent into a **board**, which is one SQLite file. A **dispatcher** claims tasks into **lanes**, trying cheap models first and escalating when the evidence says so. Each lane works in its own **worktree** taken from a **pool**. Lanes commit and **ship** to an **integration train**, which rebases, regenerates, runs light guards and fast-forwards `next`. A heavy gate runs on a schedule and promotes `next` to `main`. A **supervisor** loop reconciles the board, reaps stalled lanes, feeds the board from **generators**, opens **canaries** and raises alerts. A **watch tick** run by a strong model reads the numbers every 30 minutes or so, fixes one root cause or launches one improvement, and keeps a three-line note. The owner answers only the questions on a decision list.

## Single machine

Most people start with one computer, and that works well. Everything in this skill runs on one machine with no ssh.

- The train is a dedicated worktree on the same machine. It holds the `next` branch and nothing else, and only the train process commits there.
- The queue is a set of git refs named `refs/queue/<task>`. A lane ships by pointing its ref at the branch tip with `git update-ref`. The train lists those refs, rebases each one onto `next`, runs the light guards, fast-forwards `next`, and deletes the ref.
- Lanes, pool worktrees, the board and the supervisor all live in one folder tree that the agent chooses, for example `~/minifleet/<repo>/`.
- If the machine has no separate heavy tier, `next` is `main` and the promote step does nothing. Say so in the config so that nobody waits for a promotion that will never happen.

When a second machine arrives later, `references/machines.md` explains how to add it. Nothing in the single machine design has to change, because the second machine only adds lane hosts.

## Goals, and how to grade a fleet against them

The goals are local first, resumable, fast, portable, simple, modular, adaptable, inspectable, self-healing, micro-optimizable, and nothing gets stuck without anyone noticing. Grade each goal from A to F using evidence from the last 24 hours. The questions below expose the gaps.

- Local first. Does everything run with the internet down, except promote? Can a landing happen on the laptop alone?
- Resumable. After `kill -9` of any process, does work resume from the last checkpoint with no human step? Does the retry prompt include the previous attempt's notes?
- Fast. A canary should go from claim to landed in under 5 minutes, a train pass should take under 3 minutes, and queue wait p50 for tiny tasks should be under 2 minutes.
- Portable. Paths, runners and the box live in one config file, and an `init` command builds the board, pool and services on a fresh machine.
- Simple. A newcomer should be able to read the README and name every process in `ps` within 10 minutes.
- Modular. The board, lanes, pool, train, supervisor and watch tick can each be replaced behind their contracts.
- Adaptable. Caps are soft, admission follows load, rotation follows data, and generators are plug-in sources.
- Inspectable. One command shows a task's whole trail, one command shows the last 10 train passes with step timings, and one line shows velocity.
- Self-healing. Every failure class in `references/failures.md` has a guard that fires without a human.
- Micro-optimizable. Every step writes a timing to a log that a tool can aggregate.
- Nothing stuck unnoticed. The alarms watch the flow of work as well as the processes. They fire when the queue is non-empty with no launch for 10 minutes, when the train queue is non-empty with no pass for 10 minutes, when a task has been `shipped` for 20 minutes without a verdict, when any status is older than twice its p90 (15 minutes until there are 10 attempts to measure), when a generator adds nothing three times while the board is low, and when one guard fails on three branches within an hour, which means the environment is red and the branches are fine.

## Primitives every fleet has

The agent builds your fleet from a small set of primitives. Their shapes are the same everywhere, which lets two fleets be compared and lets an agent from one fleet read another. Keep the shapes and write the code in whatever language fits your repo.

| Primitive | Shape (the same for everyone) | What varies (yours) |
|---|---|---|
| Board | One SQLite file with `tasks`, `task_events`, `attempts` and ledgers. One writer CLI with the verbs in `contracts.md`. Writer-token triggers on every table. | The CLI's language, extra columns, your tiers and runners |
| Inbox | A folder of task files (markdown with frontmatter for title, tier, files, check and stages). An ingest step turns them into board rows and generates the STAGE lines from the frontmatter. | Who writes to it and how often it is swept |
| Prompt | Staged (`STAGE n (ship by minute m)`), with an `If time runs out` line and a runnable check. Linted on `add` with the regexes in `contracts.md`. | Your stage shapes and checks |
| Lanes | One script per model. It claims a task, writes a progress beat every minute, commits by name and ships. Cheap models go first. | Which models, the order and the deadlines |
| Pool | N worktrees. A claim is a file `<slot>.claim` holding a task id and an epoch. The verbs are claim, touch, release and retarget. Dirty work is salvaged to `wip/<task>`, including untracked files. | Pool size, setup steps, location |
| Train | The queue as refs. A pass is rebase, regen, light guards, oracle check, fast-forward. `passes.jsonl` holds step timings. Failed verdicts flow back to the board. | Which guards, which machine, the heavy gate's cadence |
| Status | One command. Its first line is the velocity line `tasks/h X (24h Y) = Z% of target · landings/h ...`. | Targets and extra sections |
| Alerts | One append-only `ALERTS.md` with a `critical:` prefix for alarms, and one notification channel. | Thresholds and channel |
| Decisions | One `DECISIONS.md`. The tick appends to it, the owner answers in place, and nothing else may ask the owner. | The questions |
| Digest | One markdown file per program that every agent appends to under its own heading, plus a daily morning report. | Programs |
| Config | One `fleet.json` holding home, repo, worktree root, train location, lane hosts, node, runners with caps, a daily spend counter and the scheduler. | The values |
| Tick | The ritual in `tick.md`, with a three-line note in `watch-notes.md`. | Cadence and who runs it |

Everything outside this table is yours to invent, such as guards for your repo, generators for your backlog, oracles for your domain, codemods and dashboards.

## Fourteen rules that carry the weight

1. **The board is the only truth and has one writer.** The board is one SQLite file with one CLI that writes to it. Triggers on every table refuse any other connection, using `RAISE(ABORT)` unless a per-connection token function exists. The CLI must be written in a language that can register a function on a single connection (Python's `sqlite3` can, and `node:sqlite` cannot). A raw `sqlite3` write that fails with "no such function" counts as refused, and that is the result you want to see. Exports such as JSONL and dashboards are read-only views. Reads set a busy timeout, and writes retry on lock and then alert loudly.
2. **Terminal means terminal.** `done`, `shipped`, `cancelled` and `quarantined` are refused by every later writer, which logs an `ignored` event instead. Cancel kills the lane and drops the lease. A quarantined task is revived only by an explicit requeue. The table in `contracts.md` shows who moves each status.
3. **One front door.** Nothing lands on `next` except through the train, and nothing lands on `main` except the promote gate. Per-landing guards stay light, and the full suites run at promote. After every fast-forward, verify that `git rev-parse <branch>` equals the sha that was landed.
4. **Oracle before edit, and show every guard red.** Record current behavior before changing anything, and after the change diff to zero or ledger each intended difference by name. Check that a file is live before spending an hour on it. Every guard must also be shown failing on a deliberately bad branch, because a guard that cannot fail protects nothing. One real example is a test-count guard that grepped for `# pass N`. Node 26 prints `ℹ pass N`, so the guard passed forever until someone made it fail on purpose.
5. **Never discard work.** Salvage commits tracked and untracked files to `wip/<task>` before any reset. A slot held by something the board does not know is never stolen while a process has it open or a file changed in the last 30 minutes. Lanes commit `[wip]` early.
6. **Soft limits with adaptive room.** Caps are ceilings. The admission formula follows load and RAM (see `contracts.md`, with a small-fleet default). A tiny-task reserve keeps one lane for quick wins. Raise ceilings and let the formula govern.
7. **Cheap first, escalate on evidence.** Rotation orders the CLIs the owner has installed from cheapest to strongest. A task reaped twice on the same runner moves one rung up. Deadlines honor the prompt's own "ship by minute N" plus grace. Breakers pause a runner after repeated infrastructure exits, and quota exhaustion counts as an infrastructure exit.
8. **Every failure returns to its author with the reason.** A failed train verdict sets `failed_landing` with the gate text, records an attempt outcome, and requeues to the author's runner. The second failure escalates. Generators never re-emit a target with two prior reaps or fails in 24 hours.
9. **Everything is auditable and cheap to read.** Events, attempts, an alerts file, an ops log for config changes, a digest per program and a three-line note per tick. Logs link to transcripts and do not contain them.
10. **The tick improves the factory.** Each tick measures, fixes one root cause with evidence or launches one improvement, writes the note and surfaces decisions. The tick has a cost cap and skips itself when the board is idle (see `tick.md`).
11. **A negative claim needs two methods.** Words like "missing", "unregistered", "inert" and "not running" are never reported from one probe. Print the environment the probe ran in, then confirm by an independent route, such as an absolute path, a login shell, a deliberate break test, or `pgrep` plus the lease. Put the probe in a tool so that the guard is code.
12. **Tools before tokens.** Each day, look for tasks with the same shape and turn each repeat into a tested script. Model tokens are for judgment.
13. **Self-improvement comes from the board.** The tick runs a few standing queries and picks its one improvement from those answers. Good queries are fail rate by task shape and runner, cost per landing, step time p50 per runner, and the most frequent gate failures.
14. **A progress beat counts only when something changed.** A lane's beat is real only if the lane log grew or the worktree changed since the previous beat. A lane that writes beats while nothing else moves is stalled, and the supervisor treats it that way.

## Build order

The agent asks five questions first and then probes each runner with a one-line call, such as `claude -p "say ok"`, because an installed CLI is not always a logged-in one. The questions are the repo, the machines, the models with a daily budget, what "landed" means, and when the owner sleeps.

`references/build.md` gives the build in three stages, with one runnable acceptance check per step. Do not start a step until the check for the one before it passes. A newcomer on one machine can follow it start to finish.

## Numbers to aim for

The scorecard targets in `contracts.md` come from a mature fleet running about 30 agents on two machines. A small fleet should start with the defaults listed next to them, then replace those defaults with its own measurements after a day of data.

## What makes this spread

Three things can be copied in an afternoon. They are the one-writer board with triggers, the train as the only door with light guards per landing and the heavy gate at promote, and the tick ritual of measuring, fixing one root cause with evidence, writing three lines and surfacing decisions. Keep any reference implementation small and boring.

## Files in this skill

The seven files in `references/` are listed with their absolute URLs near the top of this page. Start with `build.md`, and read `contracts.md` when you write the board.
