# Command line

Run `fleetrc <command>` to sync skills, edit the manifest, and manage the machines in your fleet. `fleetrc` with no command runs `sync`. `fleetrc <command> --help` prints that command's flags.

## Commands

| Command | What it does |
| --- | --- |
| `fleetrc sync [source]` | Fetch the sources, or only `source`, and link their skills. The default command. |
| `fleetrc init [manifest]` | Point this machine at a manifest, migrate its skill folders, sync, and install the launcher and session hooks. |
| `fleetrc status` | Show the last run, held and pending updates, edited skills, and sessions to restart. |
| `fleetrc list` | List the linked skills, files, and config entries, and where each comes from. |
| `fleetrc agents` | List every agent id, which are installed here, and where each reads skills. |
| `fleetrc doctor` | Check Node.js, git access, the sync trigger, and duplicate skills. See [Doctor](https://fleetrc.loadsheet.dev/reference/doctor). |
| `fleetrc add <source>` | Add a source to the manifest, then sync. |
| `fleetrc remove <source\|skill>` | Remove a source, or exclude one skill from its source. |
| `fleetrc adopt <path>` | Move a hand-made skill folder into your personal repository. |
| `fleetrc fork <skill>` | Move a vendored skill into your personal repository, to edit it. |
| `fleetrc diff [skill\|mcp/<agent>/<server>]` | Show updates held for review, or one skill's or MCP server's local edits. |
| `fleetrc merge <skill>` | Merge an upstream update into an edited skill or a fork. |
| `fleetrc update <source>` | Apply the updates a review-mode source is holding. |
| `fleetrc timer install\|remove\|status` | Install, remove, or show the timer that syncs on the manifest's schedule. |
| `fleetrc fleet sync\|status\|upgrade\|init\|add\|run` | Run on the manifest's machines over SSH, or add machines to it. |
| `fleetrc hook install\|remove [agent]` | Add or remove the session hooks of Claude Code and Codex. |
| `fleetrc self-install` | Copy this fleetrc into the state folder. `init` and `fleet upgrade` run it. |

`status`, `list`, `agents`, `doctor`, and `diff` are read-only. They reject `--dry-run`, since they change no skills, links, or manifest.

## Flags

These flags work on most commands. A command that does not take a flag exits `2` with `<command> does not take --<flag>`.

| Flag | Meaning |
| --- | --- |
| `--dry-run` | Print what would change and change nothing. |
| `--json` | Print one JSON document on stdout. Messages go to stderr. |
| `--offline` | Use what is already fetched, with no network. |
| `--copy`, `--no-copy` | Copy skill folders, or link them again. fleetrc remembers the choice. |
| `--manifest <m>` | Use this manifest instead of the configured one. |
| `-v`, `--version` | Print the version. |
| `-h`, `--help` | Show help. |

`--copy` and `--no-copy` together exit `2`. A dry run does not save the choice. See [Syncing](https://fleetrc.loadsheet.dev/guide/sync#link-or-copy).

These flags belong to one or a few commands:

| Flag | Commands | Meaning |
| --- | --- | --- |
| `--timer` | `init`, `fleet init` | Install the timer too, for a machine where no agent runs. |
| `--no-hooks` | `init`, `fleet init` | Do not install the session hooks. |
| `--force` | `init`, `fleet init` | Go ahead even when skill names would be lost. |
| `--timeout <s>` | `fleet` | Seconds to wait for each host. Default 30, or 120 for `fleet init`. |
| `--id <id>` | `add` | The source's id. Default: the repository, host, or package name. |
| `--skills <glob>` | `add` | Skill folders inside the source, such as `skills/*`. |
| `--include <name>` | `add` | Only this skill. Repeat for more. |
| `--exclude <name>` | `add` | Never this skill. Repeat for more. |
| `--review` | `add` | Hold the source's updates for review: sets `"update": "review"`. |

`diff` takes `--manifest` only. `status` and `list` take `--json` only.

## Exit codes

| Exit code | Meaning |
| --- | --- |
| `0` | The command did what you asked. |
| `1` | The command ran and failed: a sync reported errors, a `doctor` check failed, `merge` left conflicts, `timer status` found no timer, or a host in `fleet` failed. Errors fleetrc expects, such as a bad manifest or an unreadable repository, also exit `1`. |
| `2` | The command line is wrong: an unknown command or flag, a missing argument, or flags that contradict each other. |

Errors go to stderr as one line, `fleetrc: <message>`. An error fleetrc did not expect says so and names `FLEETRC_DEBUG`. Under `--json`, a failure is also a document on stdout:

```json
{ "ok": false, "error": "no manifest yet: run `fleetrc init <manifest>` first" }
```

A Node.js older than 22.12 exits `1` before any command runs.

## JSON output

With `--json`, a command prints one document on stdout and its messages on stderr.

| Command | The document |
| --- | --- |
| `sync`, `update` | The sync report, with a `fleetrc` field for the version. See [Syncing](https://fleetrc.loadsheet.dev/guide/sync#report). |
| `init` | `{ plan, applied, sync, installed, hooks?, timer? }`. With `--dry-run`, the plan with `launcher`, `hooks`, and `timer`. |
| `status` | `manifest`, `lastRun`, `lastChange`, `files`, `entries`, `forks`, `staleSessions`, `trigger`, `timer`, and `timerSchedule` when the schedule drifted. |
| `list` | `version`, `lastChange`, `skills`, `files`, and `entries`. |
| `agents` | An array of `{ id, name, dir?, detected, linkedInto?, kinds? }`. |
| `doctor` | An array of `{ name, ok, detail, skipped?, warn? }`. |
| `add`, `remove`, `adopt`, `fork` | What changed, with `file`, `push`, `dryRun`, and the sync report under `sync` when a sync ran. |
| `merge` | `{ merged, conflicts, into, dryRun }`, and `resolved`, `markers`, and `manifest` when they apply. |
| `fleet sync`, `status`, `upgrade`, `init` | An array with one result per host. |
| `fleet run` | `[{ host, reachable, exitCode, stdout, error }]`. |
| `timer`, `hook` | The timer's spec or status, or the hook changes. |

`diff` and `self-install` take no `--json`.

`list --json` reads only this machine's state, with no manifest and no network. A later version only adds fields, and bumps `version` for any other change. A skill's `dir` may lack a readable `SKILL.md`, so check before you read it.

```json
{
  "version": 1,
  "lastChange": "2026-12-04T09:12:41.208Z",
  "skills": [
    {
      "name": "nuxt",
      "source": "nuxt",
      "dir": "/home/me/.local/state/fleetrc/store/nuxt/live/nuxt",
      "changedAt": "2026-12-04T09:12:41.208Z"
    }
  ],
  "files": [],
  "entries": []
}
```

## Environment variables

| Variable | Effect |
| --- | --- |
| `XDG_CONFIG_HOME` | Puts `config.json` in `$XDG_CONFIG_HOME/fleetrc`. A relative value is ignored. |
| `XDG_STATE_HOME` | Puts the state folder in `$XDG_STATE_HOME/fleetrc`. A relative value is ignored. |
| `APPDATA`, `LOCALAPPDATA` | On Windows, the config folder `%APPDATA%\fleetrc` and the state folder `%LOCALAPPDATA%\fleetrc`, when the XDG variables are unset. |
| `FLEETRC_PACKAGE` | The package `fleet init` and `fleet upgrade` run on hosts with `npx`, instead of `fleetrc@<version>`: a tarball, a URL, or a preview build. It also skips the check that this version is on npm. |
| `FLEETRC_DEBUG` | Print the stack of an unexpected error. |
| `NPM_TOKEN` | Sent as a bearer token to the registry of an `npm` source. Not sent for a source only an extended manifest names. |
| `npm_config_registry` | The registry for `npm` sources without a `registry`, and for the release check in `fleet`. |

fleetrc sets some variables itself. The timer and the syncs a session hook starts set `FLEETRC_TIMER`: the report's first line then starts with its time, and a sync that finds another running exits `0` and logs that it skipped. A manifest `hooks` command gets `FLEETRC_HOOK` and `FLEETRC_CHANGED`. fleetrc sets `DO_NOT_TRACK=1` unless you set it.

## sync

`sync [source]` fetches every source, links the skills, and prints a report. With a source id, it fetches only that source and links the others from what is on disk. It exits `1` when the report has errors. See [Syncing](https://fleetrc.loadsheet.dev/guide/sync) for what a sync does.

```sh
fleetrc sync --offline
```

```txt
fleetrc: linked 12 skills into 2 folders (offline)
```

`update <source>` is `sync <source>` that also applies the updates the source holds for review.

## init

`init [manifest]` sets up this machine. The manifest is a repository (`owner/repo`, `github:owner/repo`, `gitlab:group/repo`, or a `.git` URL), read for `.fleetrc/manifest.json`; `<repo>//<file>`; or a file or folder on this machine. Without one, `init` uses the configured manifest again, and on a new machine asks your tailnet policy. `init tailscale:` switches a machine to the policy's manifest.

`init` plans the migration of your skill folders, syncs, installs the launcher, adds the session hooks to Claude Code and Codex where they exist, and keeps the timer on a machine that had one. Preview it first:

```sh
fleetrc init my-team/agents --dry-run
```

`init` exits `1` and changes nothing when it would lose skill names. Add a source for them, or pass `--force`.

## status, list, and agents

`status` prints the manifest, the last run, forks and merge conflicts that need you, what starts syncs here, the timer, and Codex sessions that began before the last skill change. `list` prints one line per skill, file, and config entry: name, source, and path. `agents` prints each agent id, whether it is installed, and the folder it reads. None needs the network.

## add, remove, adopt, and fork

`add <source>` accepts `owner/repo`, a git URL, a GitHub or GitLab page, an index URL, `npm:<package>`, or a local path.

```sh
fleetrc add onmax/nuxt-skills --include nuxt --include nuxt-ui --review
```

`remove <source|skill>` removes a source from `sources`. For a source from an extended manifest, it adds the id to `excludeSources`. For a skill, it adds the name to `exclude`.

`adopt <path>` moves a skill folder with a `SKILL.md` into the personal repository: the first source marked `"adopt": true`, else the first git source with a `path`. `fork <skill>` copies a vendored git skill there, records it under `forks` with the commit it started from, and excludes it from its source.

Each command edits the manifest and then syncs. A manifest fetched from a repository is not edited in place. fleetrc edits a working clone of it (a source with a `path`) and tells you to commit and push, or stops and says what to change.

## diff and merge

`diff` with no argument prints every update a source holds for review. `diff <skill>` prints a skill's local edits against upstream, or its pending update against what is installed. `diff mcp/<agent>/<server>` compares an MCP server in the agent's config with what the manifest gives it. It prints `no differences` or `no updates are waiting for review` when there is nothing.

`merge <skill>` brings an upstream update into an edited skill or a fork. It exits `1` when conflicts remain: resolve the markers by hand, then run `merge` again. `merge --dry-run` shows what would merge.

## timer

`timer install` installs a user timer that runs `sync` on the manifest's `timer.cron`: systemd on Linux, launchd on macOS, Task Scheduler on Windows. `timer remove` removes it. `timer status` shows it and exits `1` when none is installed. `timer status` takes no `--dry-run`. See [Timer](https://fleetrc.loadsheet.dev/guide/timer).

## fleet

`fleet` runs on the machines in the manifest's `fleet`, over SSH. Name hosts or `tag:<name>` after the action to use fewer machines.

| Action | What it does |
| --- | --- |
| `fleet sync [host...]` | Run `sync` on each host and report. |
| `fleet status [host...]` | Show each host's version and last run. |
| `fleet upgrade [host...]` | Install this version on each host with `npx`. |
| `fleet init <host...>` | Run `init` on each new host with this machine's manifest, then add it to `fleet`. The manifest must be in a repository. |
| `fleet add [host...]` | Add hosts to the manifest. With none, suggest machines and tags on your tailnet. |
| `fleet run [host...] -- <command>` | Run the command here and on each host, and print each host's output after its name. |

`fleet init` passes `--copy`, `--no-copy`, `--timer`, `--no-hooks`, and `--force` to each host. `fleet status`, `upgrade`, and `run` reject `--dry-run`. All actions but `add` exit `1` when a host is unreachable or fails. See [Fleet](https://fleetrc.loadsheet.dev/guide/fleet).

## hook and self-install

`hook install [agent]` adds the session hooks, and `hook remove [agent]` takes them out. The agent is `claude-code` or `codex`. Without one, the command acts on each agent whose folder exists. When a session starts, the hook starts a background sync if none was tried in the last 15 minutes and none is running. See [Hooks and MCP](https://fleetrc.loadsheet.dev/guide/hooks-and-mcp).

`self-install` copies this fleetrc into the state folder, where the launcher, the hooks, and the timer run it.

## Use from code

The package exports `run`, `runOnFleet`, and the `RunResult` type.

```ts
import { run, runOnFleet, type RunResult } from "fleetrc";

// The command on every host in this machine's fleet, never on this machine.
// undefined when fleetrc has no config here or the fleet is empty.
const results: RunResult[] | undefined = await runOnFleet(["uname", "-a"], { timeoutMs: 30_000 });

// The whole CLI, with help and error text naming the command the user typed.
await run(process.argv.slice(3), "mytool fleet");
```

`runOnFleet(argv, { timeoutMs })` reads the fleet from the manifest's last fetched copy and returns one result per host: `host`, `reachable`, `exitCode`, `stdout`, `stderr`, and `error` when there is no exit code. It throws when `config.json` or the manifest does not read.

`run(argv, name)` runs the CLI on `argv`, the arguments after the program name. It writes to stdout and stderr and sets `process.exitCode`. A command line it can't run exits the process with `2`, so call it once per process.

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

- [Command line](https://fleetrc.loadsheet.dev/raw/reference/cli.md) (this page)
- [Manifest schema](https://fleetrc.loadsheet.dev/raw/reference/schema.md)
- [Doctor](https://fleetrc.loadsheet.dev/raw/reference/doctor.md)

Next: [Manifest schema](https://fleetrc.loadsheet.dev/raw/reference/schema.md)

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