# fleethosts

::fleethosts-hero
# Run a command on every machine you reach

Name hosts and Tailscale tags. fleethosts turns them into ssh targets, runs one command on all of them at once, and tells you what each machine gave back.

#agents
```text
Install fleethosts as a dependency.
Read https://fleethosts.loadsheet.dev/guide/hosts, then run commands on our machines with resolveHosts and runOnHosts, passing standardPlaces("<our program>").
```

#humans
```sh pm
pnpm add fleethosts
```

#code
```ts
import { resolveHosts, runOnHosts, standardPlaces } from "fleethosts";

const places = standardPlaces("mytool");
const runs = await runOnHosts(
  places,
  async (remoteCommand) =>
    (await resolveHosts(places, ["vps", "tag:servers"], { remoteCommand })).targets,
  ["uptime", "-p"],
  30_000,
  { here: false },
);
for (const run of runs) console.log(run.host, run.exitCode ?? run.error);
```

#output
```text
vps 0
web-1.tail4f2a.ts.net 0
web-2.tail4f2a.ts.net offline in Tailscale
```
::

## Three entries

No runtime dependencies: fleethosts runs `ssh` and `tailscale` from the machine.

::card-group
:::card{title="Hosts" icon="i-lucide-server" to="/guide/hosts"}
Check entries, expand tags, run on each machine, record the fleet
:::

:::card{title="Exec" icon="i-lucide-terminal" to="/guide/exec"}
Run a command to the end, with a timeout and a cancel that stop what it started
:::

:::card{title="Places" icon="i-lucide-folder-tree" to="/guide/places"}
Your program's folders and the names it writes under
:::
::

An unreachable machine gets an `error` and no exit code, so it never reads as a failed command.

<!-- vitehub-docs:section-links -->
All pages: [llms.txt](https://fleethosts.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/fleethosts/issues). Report a security vulnerability privately, never in a public issue.
