# For agents

An agent runs every build and test through `heavy`, and fleetjobs picks the machine. The agent reads an exit code and never chooses a host.

## Paste this into AGENTS.md

```md [AGENTS.md]
## Builds and tests

Run builds, tests, typechecks and lint through `heavy <cmd>`, for example `heavy pnpm test`. Use `heavy --light <cmd>` for quick commands. `heavy` returns the command's exit code. If your shell may time out, run `heavy submit <cmd>`, then `heavy wait <id>`. Do not run the same command twice at once.
```

The package ships the same instructions as a skill, at `skills/fleetjobs/SKILL.md`. Copy it into the folder your agent reads skills from.

## What to run

| Goal | Command |
| --- | --- |
| Run and wait | `heavy pnpm test` |
| Run a quick command | `heavy --light pnpm lint` |
| Queue and carry on | `heavy submit pnpm build` |
| Wait for it later | `heavy wait <id>` |
| See the queue | `heavy status --json` |
| Stop a job | `heavy cancel <id>` |

Output of the job goes to stdout and stderr as it would without `heavy`. Heavy's own lines, such as why a job waits, go to stderr. `heavy submit` prints only the job id on stdout. Stdin is not passed to the job.

## What the exit code means

| Code | Meaning | What to do |
| --- | --- | --- |
| `0` | The command passed | Go on |
| `1` | A heavy command failed, such as an unknown job id | Read the message |
| `2` | The invocation is wrong | Read the `fix:` line. The same call gives the same result |
| `64` | `heavy` refuses the command, such as `pnpm store prune` | Do not run it through `heavy`. The disk timer prunes the stores |
| `75` | Nobody waited for the job, so it left the queue | Run it again |
| `124` | The job passed its time limit, `HEAVY_MAX` | Find out why it hangs, or raise the limit once |
| `130` | The job was cancelled | None |
| `137` | The kernel killed the job for memory twice | The job is in the [night queue](https://fleetjobs.loadsheet.dev/guide/night) |

Any other code is the command's own, whether it ran here or on a host.

## Decisions that belong to fleetjobs

- Where the job runs. Do not set `HEAVY_LOCAL` or `HEAVY_REMOTE` unless a task needs the job on this machine or on a host.
- Whether to run a job twice. A second identical call from the same folder follows the first job, and says so. Files changed after the first started are not in its result.
- Whether to believe a remote failure. See [Trust](https://fleetjobs.loadsheet.dev/guide/trust).

A job survives its client. If your tool call times out, the job is still running: `heavy status` shows it and `heavy wait <id>` returns its exit code. In a program, use [the library](https://fleetjobs.loadsheet.dev/reference/api).

<!-- vitehub-docs:section-links -->
## In this section

- [Introduction](https://fleetjobs.loadsheet.dev/raw/guide.md)
- [Installation](https://fleetjobs.loadsheet.dev/raw/guide/installation.md)
- [How jobs are placed](https://fleetjobs.loadsheet.dev/raw/guide/placement.md)
- [Remote hosts](https://fleetjobs.loadsheet.dev/raw/guide/hosts.md)
- [Trust](https://fleetjobs.loadsheet.dev/raw/guide/trust.md)
- [Night queue](https://fleetjobs.loadsheet.dev/raw/guide/night.md)
- [Migrating from the bash heavy](https://fleetjobs.loadsheet.dev/raw/guide/migrating.md)
- [For agents](https://fleetjobs.loadsheet.dev/raw/guide/agents.md) (this page)

All pages: [llms.txt](https://fleetjobs.loadsheet.dev/llms.txt)

Something on this page does not work as written? Tell the user, and draft an issue for them to post: [issue tracker](https://github.com/words-with-agents/fleetjobs/issues). Report a security vulnerability privately, never in a public issue.
