<!-- Generated by crates/swarmops-cli/src/reference.rs from the code: do not edit. Change the code, then run SWARMOPS_REGEN_REFERENCE=1 with the regen_reference test. -->

# CLI reference

Every command of `swarmops` and `so`, its short form: the same program by a shorter name. This page and the command pages are generated from the command line's own definition, so they say what `swarmops <command> --help` says. `-h` prints the short help and `--help` the long help that the pages give.

Every command but `mcp` prints one JSON envelope on stdout; its `op` names the operation the command runs (`cat` runs `read_file`). [Errors](errors.md) lists every error code an envelope can carry, with its exit code.

Each command's page gives its syntax, its arguments, an example recorded by the tests, what it returns and the errors it fails with. Its `yaml` metadata block says the same for programs: `group`, `mutates` (it can change what the store holds, its changesets and refs, or make the store; a write to the store's caches alone does not count), `identity_required` (it refuses to run without `--as` or `SWARMOPS_AGENT`), `mcp_tool`, `envelope_op`, `exit_codes`, `errors` and `syntax`.

## Global options

Every command takes these, before or after its subcommand.

| Option | Required | Description | Default |
| --- | --- | --- | --- |
| `--repo <STORE>` | no | The store to use (default: $SWARMOPS\_REPO). |  |
| `--as <AGENT>` | no | The agent to act as, &lt;family&gt;/&lt;instance&gt; (default: $SWARMOPS\_AGENT). |  |
| `--json` | no | Print the JSON envelope: the default, unless $SWARMOPS\_FORMAT is human. |  |
| `--human` | no | Print a short text rendering instead of JSON. |  |
| `--pretty[=<BOOL>]` | no | Pretty-print the JSON (default: when stdout is a terminal). |  |

`-h` prints a command's short help and `--help` its long help, as plain text, not an envelope. `swarmops --version` prints the version.

## Store

- [`swarmops init`](commands/init.md): Create a store in DIR, and describe it.
- [`swarmops info`](commands/info.md): Describe the store.
- [`swarmops whoami`](commands/whoami.md): Show the identity this caller's changes carry.
- [`swarmops schema`](commands/schema.md): Print the JSON Schema of every request and response type, or of TYPE's.
- [`swarmops derive`](commands/derive.md): Derive the eager derived values of new changesets, ahead of any reader.

## Write

- [`swarmops commit`](commands/commit.md): Record a changeset from a list of changes; with --advance, also move that ref to it.
- [`swarmops land`](commands/land.md): Merge a change three-way onto a ref and publish it there as one new changeset.

### swarmops blob

Store content as a blob for a commit to name by its id, or ask which blobs the store holds.

- [`swarmops blob put`](commands/blob-put.md): Store FILE's content as a blob, outside any commit, and print its id, which a change names it by: {"blob": ID}. A change list holds at most 64 MiB and a commit's contents 1 GiB together; a blob named by id counts toward neither.
- [`swarmops blob has`](commands/blob-has.md): Of the IDs given, list those the store holds blobs under.

## Read

- [`swarmops resolve`](commands/resolve.md): Name the changeset REV names, and whether REV is a ref's name.
- [`swarmops cat`](commands/cat.md): Print one file at a revision, or part of it: from a byte, or a range of lines.
- [`swarmops ls`](commands/ls.md): List one directory at a revision (the root without a PATH), and with --depth the directories below it.
- [`swarmops show`](commands/show.md): Show one changeset.
- [`swarmops log`](commands/log.md): List history along first parents, newest first.
- [`swarmops history`](commands/history.md): List the changesets that changed a path, newest first, along first parents.
- [`swarmops diff`](commands/diff.md): List the files that differ between two revisions, a page at a time.

## Refs

### swarmops ref

List refs, or move one by compare-and-swap.

- [`swarmops ref list`](commands/ref-list.md): List every ref.
- [`swarmops ref set`](commands/ref-set.md): Point ref NAME at REV: move it from --expect, or --create it.
- [`swarmops ref delete`](commands/ref-delete.md): Delete ref NAME.

## Operations

### swarmops op

List the store's operations, or undo one.

- [`swarmops op log`](commands/op-log.md): List the store's operations, newest first: each write transaction, its changesets and its ref moves.
- [`swarmops op undo`](commands/op-undo.md): Move every ref operation OP moved back to what it named before, all or none.

## Integrity

- [`swarmops verify`](commands/verify.md): Check the store's consistency.

## Git

### swarmops git

Bring history in from git, or send it back.

- [`swarmops git import`](commands/git-import.md): Bring a git repository's history in: every commit --ref reaches that the store does not hold, then move --into to it.
- [`swarmops git export`](commands/git-export.md): Send the store's history to git: write every commit of --ref's history that --branch's last export does not reach into the git repository at PATH, then move --branch to it.

## Server

- [`swarmops mcp`](commands/mcp.md): Serve the store's operations to an agent as an MCP server on stdin and stdout.
