GitHub 0
Skip to content

Coding agents

Tell coding agents how your program reaches machines, and let them test it without a real host.

A coding agent that works on a program built on fleethosts needs three facts: where the fleet is, how a run reports a dead machine, and how to test without one. Put them in AGENTS.md:

## Machines

- The fleet is in `~/.local/state/mytool/hosts.json` (`recordHosts`, `recordedHosts` from fleethosts).
- `runOnHosts` returns one result per machine. Read `exitCode` only when it is there: a machine that
  didn't answer has `reachable: false` and an `error`, not a failed exit code.
- Tests never reach a real host. `MYTOOL_SSH` and `MYTOOL_TAILSCALE` name fake CLIs; a `.mjs` file
  runs with Node.
AGENTS.md

<PROGRAM>_SSH names the ssh fleethosts runs. Point it at a script that runs the remote command on this machine:

import { spawnSync } from "node:child_process";

const args = process.argv.slice(2);
while (args[0] === "-o") args.splice(0, 2);
if (args[0] === "--") args.shift();
const [, command] = args;
process.exit(spawnSync("sh", ["-c", command], { stdio: "inherit" }).status ?? 1);
test/fake-ssh.mjs
process.env.MYTOOL_SSH = new URL("./fake-ssh.mjs", import.meta.url).pathname;
const [box] = await runOnHosts(places, [{ host: "box" }], ["echo", "hi"], 5_000, { here: false });
// { host: "box", reachable: true, exitCode: 0, stdout: "hi\n", stderr: "" }
ts

Build the Places in a temporary folder, so a test never writes to the machine's own state.

Every page on this site has a raw Markdown copy at /raw/<page>.md, such as /raw/guide/hosts.md, and a full index at /llms.txt.