# CLI reference

With the `monton` command, you and your coding agents edit a workspace's docs as files on your computer, then send your changes back to Monton. People keep typing in the web app meanwhile, and we merge both. For comments and the inbox, connect your agent to the [MCP server](https://monton.dev/docs/mcp). With CLI 0.3.0 or later, you can also [start Claude Code with Monton](#claude).

## Install {#install}

The CLI needs Node 24 or newer.

```sh
npm install -g @monton/cli
```

To try it without installing, run `npx @monton/cli` wherever this page says `monton`. Run `monton --version` to see the version you have.

## Sign in {#sign-in}

```sh
monton login
```

We show a link and a short code, and open the link in your browser when we can. Open the link on any device where you're signed in to Monton, such as your phone, check that it shows the same code, and connect the CLI within 10 minutes. The token never goes through the browser or the link: we fetch it from the server once you connect.

The CLI then acts as an agent of yours, with a name such as "Ana's CLI on laptop". Like every agent, it can do at most what an editor can, even in a workspace you own. You see it, and can revoke it, on the Agents page in the web app. Run `monton whoami` to check whose account it acts for. If the link doesn't connect, see [The CLI's sign-in link doesn't connect](https://monton.dev/docs/troubleshooting#cli-sign-in).

To sign in with a token you made on the Agents page instead, run `monton login --with-token` and paste the token. In a script, pass the token on standard input, or set `MONTON_TOKEN`.

## The config file {#config}

We keep your tokens in `~/.config/monton/config.json`, or in `monton/config.json` under `$XDG_CONFIG_HOME` when you set it. Only you can read the file: we create it with mode 600 in a folder with mode 700. In it, we keep a token for each server you signed in to, with its agent's name, and the server you signed in to last. Run `monton logout` to remove a server's token. If the file gets damaged, delete it and sign in again.

Never paste a token into a chat or a doc. Anyone with it can act as your CLI until you revoke it.

## Environment variables {#environment}

- `MONTON_TOKEN`: a token we use instead of the saved one, on whichever server the command reaches. It suits CI and other machines where nobody runs `monton login`. With `monton claude`, we use the login for the chosen server.
- `MONTON_SERVER`: the server, such as `https://monton.dev`, unless a command's `--server` names one. Without either, we use the server you signed in to last, then `https://monton.dev`. In a clone, we always use the server it came from. Plain `http` works only for this computer, such as `http://localhost:4000`.
- `XDG_CONFIG_HOME` and `HOME`: where we look for the [config file](#config).

## JSON answers {#json}

Add `--json` to a command that offers it. We then print each answer as one line of JSON on standard output, and what we say along the way on standard error, so you can read standard output alone. With `monton login --json`, we print two lines: the link and code first, then whom you signed in as. We list every field of each command's answer in its entry below. We may add fields to an answer, so ignore the fields you don't know. We answer `monton --help` and `monton --version` in plain text even with `--json`.

## Exit codes {#exit-codes}

- `0`: success.
- `1`: an error.
- `2`: a usage mistake, such as a missing argument or an unknown option, and a push too big for one without `--split`.
- `3`: a conflict with changes in Monton. After `monton push`, it means we pushed nothing: run `monton pull`, resolve the conflicts, then push again. We also exit `monton pull` with 3 when we leave conflicts in your files.

## Errors {#errors}

When a command fails with `--json`, we print an error answer on standard output: `{"error": {...}}`, with a stable `code`, a `message` that says what went wrong and what to do, and the details some codes carry. Without `--json`, we print the message on standard error. We list the codes each command can give in its entry below. A code that comes from Monton's API, such as `rate_limited`, reaches you unchanged, with the server's message; when the server answers an HTTP error without a code, the code is `http_` and the status, such as `http_502`.

The error answer's fields:

- `code` (string): The error's code, from the CLI's list of error codes or Monton's API.
- `message` (string): What went wrong and what to do, in plain words.
- `commits` (array of strings, optional): For `monton push --split`: the commits we had already pushed before the error, which are in Monton.

Any command can fail with these:

- `usage` (exit code 2): The command line has a mistake: an unknown command or option, too few or too many arguments, or options that don't go together. What to do: Read the message, then run `monton <command> --help` for the command's arguments and options.
- `internal` (exit code 1): Something broke that we didn't expect. The message names only the kind of error, never its details. What to do: Run the command again. If it fails the same way, tell us the command and the message.

And any command that reaches Monton can fail with an error from Monton's API:

- `<the server’s code>` (exit code 1): Monton's API refused the request, such as `rate_limited` or `forbidden`. The error has the server's code and message, and nothing more. What to do: Read the message, which says what to do.
- `http_<status>` (exit code 1): The server answered with an HTTP error and no code of its own, such as `http_502`. What to do: Run the command again later, and check that `--server` names a Monton server.

## Commands {#commands}

Run `monton <command> --help` to see a command's help, such as `monton push --help`. Run `status`, `diff`, `pull` and `push` in a clone's folder or any folder inside it.

### `claude` {#claude}

Requires CLI 0.3.0 or later. Run `monton --version` to check your installed version. With 0.2.0, choose **Connect an agent** in your workspace to give Claude access to docs, comments and the inbox. We currently offer incoming delivery in the private mention pilot.

Start Claude Code with Monton tools in the current folder. Give the workspace slug from its Monton URL. The CLI uses your login for that server or opens a browser to sign in. Claude uses the same agent for reading, sending and receiving mentions.

Choose whether to receive mentions while Claude is open. To receive them, accept Claude’s channel prompt and look for “Channels (experimental)” in its startup notice. Monton confirms delivery in the debug log after Claude calls the tool to read or answer a mention. Claude keeps its usual permissions for replies and edits. When you skip receiving, you can still ask Claude to send mentions and read documents. Check the agent’s Monton inbox for incoming mentions.

#### Usage

```sh
monton claude [options]
```

#### Options

- `--workspace <slug>`: The workspace slug from its Monton URL.
- `--server <url>`: The Monton server. Default: your last Claude server on a repeat launch, or your CLI server.
- `--receive-mentions`: Choose to receive mentions.
- `--skip-mentions`: Start with Monton tools and skip incoming mentions.

#### Text output

The CLI shows the workspace and the agent’s name and owner. It then opens Claude in the terminal. When Claude exits, the CLI returns its exit code.

#### Errors

- `config` (exit code 1): We couldn't read the CLI's config file, or it isn't valid JSON, or it isn't a Monton config. The message names the file. What to do: Fix the file, or delete it and run `monton login` again.
- `network` (exit code 1): We couldn't reach the server. What to do: Check the address in `--server` or `MONTON_SERVER` and your connection, then run the command again.
- `login_failed` (exit code 1): Signing in failed: the server refused it, or answered something we don't know. What to do: Run `monton login` again. If it fails again, check that `--server` names a Monton server.
- `refused` (exit code 1): Someone refused this sign-in in Monton. What to do: Run `monton login` again if you meant to sign in.
- `timeout` (exit code 1): Nobody connected the CLI in time after `monton login` showed its link. What to do: Run `monton login` again, and connect the CLI within 10 minutes.
- `cancelled` (exit code 1): You stopped the command while it asked you something, or cancelled signing in. What to do: Run the command again when you want to.
- `claude_start` (exit code 1): We could not start Claude Code with Monton. What to do: Check your Claude Code installation and the Monton agent’s access to the workspace.

Besides these, it can fail with [`usage` or `internal`](#errors), as any command can, or with [an error from Monton's API](#errors).

#### Examples

Start from the folder where you want Claude to work:

```sh
monton claude --workspace team
```

Start again with the last workspace and your previous choice about incoming mentions:

```sh
monton claude
```

Start with document tools and skip incoming mentions:

```sh
monton claude --workspace team --skip-mentions
```

### `login` {#login}

Signs this computer in to Monton. Run it once on each computer where you or your coding agents use the CLI. We show a link and a short code and, when we can, open the link in a browser on this computer. Open the link on any device where you're signed in to Monton, such as your phone, check that it shows the same code, and connect the CLI within 10 minutes. We then save a token in the [config file](#config), and the CLI acts as an agent of yours, named after you and this computer, such as "Ana's CLI on laptop". Like every agent, it can do at most what an editor can.

With `--with-token`, we read a token you made on the Agents page instead, and show no link. We ask for it when you run the command in a terminal, and read it from standard input otherwise. Use it on a computer without a browser, or in a script.

A coding agent runs `monton login --json`, sends the link and the code from the first line to its own user in their private chat, and waits. It never asks its user for a token. We describe the whole flow in [Set the CLI up for coding agents](#agents).

#### Usage

```sh
monton login [options]
```

#### Options

- `--server <url>`: The Monton server. Default: the last one you signed in to, or monton.dev.
- `--no-browser`: Show the link without opening a browser here.
- `--with-token`: Read a token from standard input instead (make one on the Agents page in Monton).
- `--json`: Answer in JSON.

#### Text output

We print the link, the code and what we're waiting for on standard error. Once you connect the CLI, we print one line on standard output: the server, the agent's name, and the person it acts for, with their email. Check that the email is yours. If we couldn't ask the server whose account it is, we say to run `monton whoami`.

#### JSON answer

The first line, before the person connects the CLI. An agent sends the link and code to its own user only.

- Either: The usual sign-in, approved from any device.
  - `link` (string): The link to open on any device where the person is signed in to Monton.
  - `code` (string): The code that page shows, for the person to check.
  - `expiresAt` (string): When the link stops working, in ISO 8601.
- Or: A server that doesn't offer sign-in from any device.
  - `link` (string): The link to open in a browser on this computer.
  - `code` (null): No code to check.
  - `thisComputerOnly` (true): The link works only in a browser on this computer.

Whom the CLI signed in as.

- `server` (string): The Monton server, such as `https://monton.dev`.
- `agent` (object): The agent the CLI signs in as.
  - `id` (string): The CLI's agent ID in Monton.
  - `name` (string): The CLI's agent name, such as `Ana's CLI`.
- `owner` (object or null): The person the CLI acts for; `null` when we couldn't ask the server.
  - `id` (string): The person's ID in Monton.
  - `name` (string): The person's name.
  - `email` (string): The person's email address.

#### Errors

- `config` (exit code 1): We couldn't read the CLI's config file, or it isn't valid JSON, or it isn't a Monton config. The message names the file. What to do: Fix the file, or delete it and run `monton login` again.
- `network` (exit code 1): We couldn't reach the server. What to do: Check the address in `--server` or `MONTON_SERVER` and your connection, then run the command again.
- `invalid_token` (exit code 1): `monton login --with-token` read something that isn't a Monton token, or a token the server doesn't accept: unknown, expired or revoked. What to do: Make a new token on the Agents page in Monton, or run `monton login` without `--with-token`.
- `login_failed` (exit code 1): Signing in failed: the server refused it, or answered something we don't know. What to do: Run `monton login` again. If it fails again, check that `--server` names a Monton server.
- `refused` (exit code 1): Someone refused this sign-in in Monton. What to do: Run `monton login` again if you meant to sign in.
- `timeout` (exit code 1): Nobody connected the CLI in time after `monton login` showed its link. What to do: Run `monton login` again, and connect the CLI within 10 minutes.
- `cancelled` (exit code 1): You stopped the command while it asked you something, or cancelled signing in. What to do: Run the command again when you want to.

Besides these, it can fail with [`usage` or `internal`](#errors), as any command can, or with [an error from Monton's API](#errors).

#### Examples

Sign in, approving on a phone. We print the first line at once, and the second once Ana connects the CLI:

```sh
monton login --json
```

```json
{"link":"https://monton.dev/cli/authorize?code=KQWT-MBRX","code":"KQWT-MBRX","expiresAt":"2026-11-14T10:10:00.000Z"}
```

```json
{"server":"https://monton.dev","agent":{"id":"b33aed8f-3134-9967-03dc-39f9a7c95783","name":"Ana's CLI on laptop"},"owner":{"id":"276b6c46-92e7-8d47-99c1-2ada515bc3e4","name":"Ana","email":"ana@example.com"}}
```

Sign in with a token from the Agents page, which we read from standard input:

```sh
monton login --with-token --json
```

```json
{"server":"https://monton.dev","agent":{"id":"b33aed8f-3134-9967-03dc-39f9a7c95783","name":"Ana's CLI on laptop"},"owner":{"id":"276b6c46-92e7-8d47-99c1-2ada515bc3e4","name":"Ana","email":"ana@example.com"}}
```

#### Over MCP and in the web app

In the web app, on the Agents page you see every CLI you signed in, with when its token expires, and make tokens for `--with-token`. You sign in an MCP client when you connect it: see [Connect your agent](https://monton.dev/docs/connect).

### `logout` {#logout}

Revokes this computer's token on the server, then removes it from the [config file](#config). Run it when you stop using the CLI on a computer, or when you find someone other than you in the answer of `monton whoami`. If the server had already stopped accepting the token, we remove it all the same and answer `"revoked": false`. If the token came from `MONTON_TOKEN`, we revoke it, and you unset the variable yourself.

#### Usage

```sh
monton logout [options]
```

#### Options

- `--server <url>`: The Monton server. Default: the last one you signed in to, or monton.dev.
- `--json`: Answer in JSON.

#### Text output

One line: the server we signed you out of, and whether we revoked its token.

#### JSON answer

The server we signed out of.

- `server` (string): The Monton server, such as `https://monton.dev`.
- `revoked` (boolean): We revoked the token; `false` when the server had already stopped accepting it.

#### Errors

- `config` (exit code 1): We couldn't read the CLI's config file, or it isn't valid JSON, or it isn't a Monton config. The message names the file. What to do: Fix the file, or delete it and run `monton login` again.
- `not_signed_in` (exit code 1): The CLI has no token for this server, or the server doesn't accept it any more: it expired or someone revoked it. What to do: Run `monton login`. An agent runs `monton login --json` and sends its user the link and code from the first line.
- `network` (exit code 1): We couldn't reach the server. What to do: Check the address in `--server` or `MONTON_SERVER` and your connection, then run the command again.

Besides these, it can fail with [`usage` or `internal`](#errors), as any command can, or with [an error from Monton's API](#errors).

#### Examples

```sh
monton logout --json
```

```json
{"server":"https://monton.dev","revoked":true}
```

#### Over MCP and in the web app

On the Agents page in the web app, you can revoke any of your CLIs and agents, including one on a computer you no longer have.

### `whoami` {#whoami}

Shows the agent the CLI signs in as on this server, and the person it acts for. Run it after `monton login` to check that the CLI acts for you: someone could send you a link with which you'd connect the CLI to their own account. A coding agent checks that the email is its user's, and if it isn't, runs `monton logout` and tells its user.

#### Usage

```sh
monton whoami [options]
```

#### Options

- `--server <url>`: The Monton server. Default: the last one you signed in to, or monton.dev.
- `--json`: Answer in JSON.

#### Text output

One line with the server, the agent's name, and the person's name and email, then the day the token expires, if it does.

#### JSON answer

The CLI's agent and the person it acts for.

- `server` (string): The Monton server, such as `https://monton.dev`.
- `agent` (object): The agent the CLI acts as.
  - `id` (string): The CLI's agent ID in Monton.
  - `name` (string): The CLI's agent name.
  - `expiresAt` (any): When its token expires, in ISO 8601; `null` for never.
- `owner` (object): The person whose account the CLI acts for.
  - `id` (string): The person's ID in Monton.
  - `name` (string): The person's name.
  - `email` (string): The person's email address.

#### Errors

- `config` (exit code 1): We couldn't read the CLI's config file, or it isn't valid JSON, or it isn't a Monton config. The message names the file. What to do: Fix the file, or delete it and run `monton login` again.
- `not_signed_in` (exit code 1): The CLI has no token for this server, or the server doesn't accept it any more: it expired or someone revoked it. What to do: Run `monton login`. An agent runs `monton login --json` and sends its user the link and code from the first line.
- `network` (exit code 1): We couldn't reach the server. What to do: Check the address in `--server` or `MONTON_SERVER` and your connection, then run the command again.

Besides these, it can fail with [`usage` or `internal`](#errors), as any command can, or with [an error from Monton's API](#errors).

#### Examples

```sh
monton whoami --json
```

```json
{"server":"https://monton.dev","agent":{"id":"b33aed8f-3134-9967-03dc-39f9a7c95783","name":"Ana's CLI on laptop","expiresAt":"2027-02-12T10:00:00.000Z"},"owner":{"id":"276b6c46-92e7-8d47-99c1-2ada515bc3e4","name":"Ana","email":"ana@example.com"}}
```

#### Over MCP and in the web app

On the Agents page in the web app, you see the CLI's agent, with when its token expires.

### `workspaces` {#workspaces}

Lists the workspaces your CLI agent can reach on the server, with its role in each. You can limit the CLI agent to selected workspaces on the **Agents** page. Use it to find a workspace's slug for `monton clone` or `monton import --workspace`. The CLI acts as an agent, so we show its role as editor at most, even in a workspace you own. A workspace where someone shared only a folder or a doc with you has no role: we show `guest` and, with `--json`, the workspace's owner.

#### Usage

```sh
monton workspaces [options]
```

#### Options

- `--server <url>`: The Monton server. Default: the last one you signed in to, or monton.dev.
- `--json`: Answer in JSON.

#### Text output

A table with a row per workspace: its slug, your role and its name. If you can't reach any workspace yet, we say so.

#### JSON answer

The workspaces you can reach.

- `workspaces` (array of objects): The workspaces the person can reach.
  - Either: A workspace the person is a member of.
    - `id` (string): The workspace's ID.
    - `slug` (string): The workspace's slug, as in its address.
    - `name` (string): The workspace's name.
    - `role` (string): The person's role in it. The CLI acts as an agent, so it acts at most as editor. One of `owner`, `editor`, `commenter`, `viewer`.
  - Or: A workspace where someone shared a folder or a doc with the person.
    - `id` (string): The workspace's ID.
    - `slug` (string): The workspace's slug, as in its address.
    - `name` (string): The workspace's name.
    - `role` (null): No role: someone shared a folder or a doc in it with the person.
    - `access` ("guest"): The person is a guest.
    - `owner` (object or null): Whose workspace it is.
      - `name` (string): The owner's name.

#### Errors

- `config` (exit code 1): We couldn't read the CLI's config file, or it isn't valid JSON, or it isn't a Monton config. The message names the file. What to do: Fix the file, or delete it and run `monton login` again.
- `not_signed_in` (exit code 1): The CLI has no token for this server, or the server doesn't accept it any more: it expired or someone revoked it. What to do: Run `monton login`. An agent runs `monton login --json` and sends its user the link and code from the first line.
- `network` (exit code 1): We couldn't reach the server. What to do: Check the address in `--server` or `MONTON_SERVER` and your connection, then run the command again.

Besides these, it can fail with [`usage` or `internal`](#errors), as any command can, or with [an error from Monton's API](#errors).

#### Examples

```sh
monton workspaces --json
```

```json
{"workspaces":[{"id":"742523da-ef59-db4b-7184-09f46de05d0c","slug":"acme","name":"Acme","role":"editor"}]}
```

#### Over MCP and in the web app

Your MCP agent can list its own workspaces with `list_workspaces`. In the web app, the menu at the top of the sidebar lists the workspaces you can reach.

### `import` {#import}

Imports a folder of docs from your computer into a workspace, as one commit. We take the markdown, HTML and text files in it (`.md`, `.markdown`, `.mdx`, `.html`, `.txt`) and leave out hidden files and folders, `.git`, `node_modules` and build output folders. We never overwrite a doc: we skip each file whose doc already exists. Use it to bring docs into Monton once; to keep editing them as files, `monton clone` the workspace afterwards.

We first upload the folder for a preview and show what we would import and skip. Then we ask before we import anything, unless you pass `--yes`. With `--dry-run`, we stop after the preview. Without a terminal to ask in, pass one of the two. Each import and each dry run counts toward the 10 imports an hour. We take at most 25 MiB of files in one import. We explain each reason we skip a file in [An import left out some files](https://monton.dev/docs/troubleshooting#import-skipped).

Without `--workspace`, we import into the only workspace you can edit, or ask you to pick one. To import into a folder someone shared with you, name its workspace with `--workspace` and the folder with `--to`.

#### Usage

```sh
monton import <folder> [options]
```

#### Arguments

- `<folder>`: The folder on your computer to import.

#### Options

- `--workspace <slug>`: The workspace. Default: the only one you can edit, or we ask.
- `--to <folder>`: The folder in the workspace to import into. Default: the top level.
- `--dry-run`: Show what we would import and skip, then stop without importing.
- `-y, --yes`: Import without asking first (with --dry-run, a usage error).
- `--server <url>`: The Monton server. Default: the last one you signed in to, or monton.dev.
- `--json`: Answer in JSON.

#### Text output

On standard error, the docs we would import and the files we would skip, with the reason for each, and the files we left out before uploading. Then one line on standard output: how many docs we imported, and the commit.

#### JSON answer

What we imported, or would import.

- Either: A preview: a dry run, nothing to import, or an import you declined.
  - `workspace` (string): The workspace's slug, as in its address.
  - `folder` (string): The folder in the workspace; empty for the top level.
  - `preview` (object): What we would import and skip.
    - `id` (string): The import's ID.
    - `status` (string): The import's state, such as `previewed` or `done`.
    - `via` (string): How the files came in: `link` for the CLI, `web` for the web app.
    - `dryRun` (boolean): A dry run, which imports nothing.
    - `folder` (string): The folder in the workspace we import into; empty for the top level.
    - `source` (any): The name of the folder you imported.
    - `strippedFolder` (any): A top-level folder that held everything, which we left out of the paths.
    - `commit` (string or null): The import's commit, once it made one.
    - `imported` (array of strings): The docs we imported, or would import.
    - `skipped` (array of objects): The files we skipped, or would skip, and why.
      - `name` (string): The file's path in the folder.
      - `reason` (string): Why we skipped it, such as `exists` or `other-type`.
      - `path` (string, optional): Where it would have gone in the workspace.
      - `detail` (string, optional): More about the reason.
    - `skippedLeftOut` (number): How many more files we skipped than `skipped` lists.
    - `images` (object or null): The images in the docs; `null` until the import finishes, or without images.
      - `imported` (array of strings): The images we imported, by their paths in the folder.
      - `refused` (array of objects): Images we didn't import.
        - `name` (string): The image's path in the folder.
        - `reason` (string): Why we didn't import it.
    - `counts` (object or null): How many files we imported and skipped; `null` until the import finishes.
      - `imported` (number): Docs imported.
      - `skipped` (number): Files skipped.
      - `byReason` (object of numbers): Files skipped, by reason.
    - `error` (object or null): Why the import failed, if it did.
      - `code` (string): The error's code.
      - `message` (string): What went wrong.
    - `createdAt` (string): When the import started, in ISO 8601.
    - `finishedAt` (any): When it finished, in ISO 8601.
    - `expiresAt` (any): When a preview stops working, in ISO 8601.
  - `imported` (false, optional): `false` after `--dry-run`, or when you said no; absent when there was nothing to import.
- Or: A finished import.
  - `workspace` (string): The workspace's slug, as in its address.
  - `folder` (string): The folder in the workspace; empty for the top level.
  - `import` (object): What we imported and skipped. It has the same fields as `preview` above.

#### Errors

- `config` (exit code 1): We couldn't read the CLI's config file, or it isn't valid JSON, or it isn't a Monton config. The message names the file. What to do: Fix the file, or delete it and run `monton login` again.
- `not_signed_in` (exit code 1): The CLI has no token for this server, or the server doesn't accept it any more: it expired or someone revoked it. What to do: Run `monton login`. An agent runs `monton login --json` and sends its user the link and code from the first line.
- `network` (exit code 1): We couldn't reach the server. What to do: Check the address in `--server` or `MONTON_SERVER` and your connection, then run the command again.
- `no_workspace` (exit code 1): You can't reach the workspace you named, or you can't import into any workspace: that needs the editor or owner role, or a folder someone shared with you as editor. What to do: Run `monton workspaces` to list yours. To import into a folder someone shared with you, name its workspace with `--workspace` and the folder with `--to`.
- `not_a_folder` (exit code 1): The path you gave `monton import` or `monton clone` isn't a folder. What to do: Check the path, then run the command again.
- `too_many_files` (exit code 1): The folder has more files than one import takes. The message gives the numbers. What to do: Import a smaller folder, such as each of its folders in turn.
- `too_large` (exit code 1): The folder's files add up to more than 25 MiB, the most one import takes. What to do: Import a smaller folder, such as each of its folders in turn.
- `no_docs` (exit code 1): The folder has no markdown, HTML or text files to import. What to do: Check that you named the right folder.
- `import_failed` (exit code 1): The import failed, and the server didn't say why. When it says why, the error has the server's code instead. What to do: Run the import again. Add `--dry-run` to see what we would import first.
- `import_not_previewed` (exit code 1): The server didn't keep the import as a preview, so we stopped without importing anything. What to do: Run the import again.

Besides these, it can fail with [`usage` or `internal`](#errors), as any command can, or with [an error from Monton's API](#errors).

#### Examples

A dry run, to see what we would import:

```sh
monton import ./handbook --workspace acme --to handbook --dry-run --json
```

```json
{"workspace":"acme","folder":"handbook","preview":{"id":"bfdc5e9e-d767-7cdc-3511-d2da65334486","status":"previewed","via":"web","dryRun":true,"folder":"handbook","source":"handbook","strippedFolder":null,"commit":null,"images":null,"imported":["handbook/onboarding.md","handbook/policies/leave.md"],"skipped":[],"skippedLeftOut":0,"counts":{"imported":2,"skipped":0,"byReason":{}},"error":null,"createdAt":"2026-11-14T10:00:00.000Z","finishedAt":null,"expiresAt":"2026-11-14T10:15:00.000Z"},"imported":false}
```

The import itself, without asking:

```sh
monton import ./handbook --workspace acme --to handbook --yes --json
```

```json
{"workspace":"acme","folder":"handbook","import":{"id":"b2fd918e-5350-530b-becd-c00810ead42c","status":"done","via":"web","dryRun":false,"folder":"handbook","source":"handbook","strippedFolder":null,"commit":"9c0abe51c6e6655d81de2d044d4fb194931f058c0426c67c7285d8f5657ed64a","images":null,"imported":["handbook/onboarding.md","handbook/policies/leave.md"],"skipped":[],"skippedLeftOut":0,"counts":{"imported":2,"skipped":0,"byReason":{}},"error":null,"createdAt":"2026-11-14T10:00:00.000Z","finishedAt":"2026-11-14T10:00:01.000Z","expiresAt":null}}
```

#### Over MCP and in the web app

Over MCP, an agent calls `start_import` to give you a link to the web app's import page, where you drop a folder or a zip file, and `get_import` to see what came in. An agent with a few docs at hand sends them with `create_docs` instead.

### `clone` {#clone}

Copies a workspace into a new folder on your computer, so you and your coding agents can edit its docs as files. We create the folder, named after the workspace unless you name it, and check out the docs an import would take. We leave a file already at a doc's path as it is, as your version of that doc, and we list it in `differs`. On a Monton server with images on, we put the images the docs use in `attachments/` at the folder's root; we don't take images on monton.dev yet.

Afterwards, run every other command in that folder or a folder inside it. We explain what we keep in the clone in [How clone, pull and push work together](#sync).

#### Usage

```sh
monton clone <workspace> [folder] [options]
```

#### Arguments

- `<workspace>`: The workspace to clone, by its slug or its ID.
- `[folder]` (optional): The folder to clone into, which we create if needed. By default, a folder named after the workspace in the current folder.

#### Options

- `--server <url>`: The Monton server. Default: the last one you signed in to, or monton.dev.
- `--json`: Answer in JSON.

#### Text output

One line with the workspace, the folder and the commit we checked out, then the docs we didn't check out, the files that differ from Monton's text, and the images we fetched or couldn't.

#### JSON answer

What we checked out.

- `workspace` (string): The workspace's slug, as in its address.
- `server` (string): The Monton server, such as `https://monton.dev`.
- `folder` (string): The folder we cloned into, as you gave it or named after the workspace.
- `commit` (string or null): The commit we checked out; `null` for a workspace with none.
- `docs` (number): How many docs we checked out.
- `notCheckedOut` (array of objects): The docs in Monton that we didn't check out, and why.
  - `fileId` (string): A doc's ID in Monton, which stays when it moves.
  - `path` (string): The doc's path in Monton, such as `plans/q3.md`.
  - `blob` (string): The hash of the doc's text at Monton's head.
  - `reason` (string): Why: a hidden file or folder, inside a tool folder such as `node_modules`, not markdown, HTML or text, a name we never write on disk, over 1 MiB, a file of yours in the way, or the disk refused it. One of `hidden`, `excluded`, `other-type`, `invalid-name`, `too-large`, `in-the-way`, `write-failed`.
  - `blockedBy` (string, optional): For `in-the-way`: the file in the way.
- `differs` (array of strings): Files that were in the folder already with text other than Monton's. We kept them; a push would send them.
- `conflicts` (array of objects): The docs with conflict markers from a pull, to resolve before you push.
  - `fileId` (string): A doc's ID in Monton, which stays when it moves.
  - `path` (string): The doc's path in Monton, such as `plans/q3.md`.
  - `disk` (string, optional): The doc's file, when it isn't at `path`.
  - `lines` (array of objects): Where the conflict markers are.
    - `start` (number): The first line of the conflict, from 1.
    - `end` (number): Its last line.
- `images` (object): The images the docs use that we fetched into `attachments/`.
  - `fetched` (array of strings): The image files we added to `attachments/`.
  - `failed` (array of objects): Images we couldn't add.
    - `file` (string): The image file.
    - `why` (string): Why we couldn't add it.
    - `later` (boolean): A later pull may get it.

#### Errors

- `config` (exit code 1): We couldn't read the CLI's config file, or it isn't valid JSON, or it isn't a Monton config. The message names the file. What to do: Fix the file, or delete it and run `monton login` again.
- `not_signed_in` (exit code 1): The CLI has no token for this server, or the server doesn't accept it any more: it expired or someone revoked it. What to do: Run `monton login`. An agent runs `monton login --json` and sends its user the link and code from the first line.
- `network` (exit code 1): We couldn't reach the server. What to do: Check the address in `--server` or `MONTON_SERVER` and your connection, then run the command again.
- `no_workspace` (exit code 1): You can't reach the workspace you named, or you can't import into any workspace: that needs the editor or owner role, or a folder someone shared with you as editor. What to do: Run `monton workspaces` to list yours. To import into a folder someone shared with you, name its workspace with `--workspace` and the folder with `--to`.
- `already_a_clone` (exit code 1): The folder you gave `monton clone` is a clone already, or inside one. What to do: Clone into another folder, or run `monton pull` in that clone.
- `not_a_folder` (exit code 1): The path you gave `monton import` or `monton clone` isn't a folder. What to do: Check the path, then run the command again.
- `damaged_folder` (exit code 1): A file in the clone's `.monton` folder is damaged or missing. What to do: Clone the workspace again into a new folder, and copy your changes over.
- `bad_answer` (exit code 1): The server answered something we can't read. We didn't change anything. What to do: Run the command again. If it fails the same way, update the CLI.
- `missing_texts` (exit code 1): The server couldn't find some of the texts we asked for, or we lost track of one during a pull. We didn't change anything. What to do: Run the command again.

Besides these, it can fail with [`usage` or `internal`](#errors), as any command can, or with [an error from Monton's API](#errors).

#### Examples

```sh
monton clone acme --json
```

```json
{"workspace":"acme","server":"https://monton.dev","folder":"/Users/ana/acme","commit":"d0f631ca1ddba8db3bcfcb9e057cdc98d0379f1bee00e75a545147a27dadd982","docs":3,"notCheckedOut":[],"differs":[],"conflicts":[],"images":{"fetched":[],"failed":[]}}
```

#### Over MCP and in the web app

There is no clone over MCP: an agent reads and writes one doc at a time with `read_doc` and `write_doc`, and lists the docs with `get_tree`.

### `status` {#status}

Shows your changes to push: the docs you modified, renamed, created and deleted since your last pull or push, the files with conflict markers, the files a push can't take, and the docs we didn't check out. You can run it offline. With `--remote`, we also ask Monton what changed there since your last pull, without changing your files.

Run it before you push, and show it to the person you work for before a push that deletes or moves many docs.

#### Usage

```sh
monton status [options]
```

#### Options

- `--remote`: Also show what changed in Monton since your last pull.
- `--json`: Answer in JSON.

#### Text output

The workspace, its server and the commit you last pulled, then a line per change under "Changes to push", such as `modified:  plans/q3.md`, and lists of the files with conflict markers, the files a push can't take and the docs we didn't check out. With `--remote`, the changes in Monton follow.

#### JSON answer

Your changes to push.

- `workspace` (string): The workspace's slug, as in its address.
- `server` (string): The Monton server, such as `https://monton.dev`.
- `commit` (string or null): The commit you last pulled; `null` before the first.
- `changes` (array of objects): Your changes to push.
  - Either: A file that a push creates as a new doc.
    - `kind` ("new"): A new doc.
    - `path` (string or null): The new doc's path in Monton; `null` when Monton doesn't allow its name.
    - `disk` (string): The file's path on disk, from the clone's root, with `/` between folders.
  - Or: A doc whose file you deleted, which a push deletes in Monton.
    - `kind` ("deleted"): A deleted doc.
    - `fileId` (string): A doc's ID in Monton, which stays when it moves.
    - `path` (string): The deleted doc's path in Monton.
  - Or: A doc whose text you changed.
    - `kind` ("modified"): A doc with new text.
    - `fileId` (string): A doc's ID in Monton, which stays when it moves.
    - `path` (string): The doc's path in Monton, such as `plans/q3.md`.
    - `disk` (string, optional): The doc's file, when it isn't at `path`.
  - Or: A doc whose file you renamed or moved.
    - `kind` ("renamed"): A renamed or moved doc.
    - `fileId` (string): A doc's ID in Monton, which stays when it moves.
    - `from` (string): The doc's path in Monton before.
    - `path` (string or null, optional): Its new path in Monton; `null` when Monton doesn't allow the new name.
    - `disk` (string, optional): Where its file is now.
    - `modified` (boolean): You changed its text as well.
- `conflicts` (array of objects): Files with conflict markers, which a push refuses.
  - `path` (string): The doc's path in Monton, such as `plans/q3.md`.
  - `disk` (string): The file's path on disk, from the clone's root, with `/` between folders.
  - `fileId` (string, optional): A doc's ID in Monton, which stays when it moves.
- `cantPush` (array of objects): Files a push can't take.
  - `disk` (string): The file's path on disk, from the clone's root, with `/` between folders.
  - `path` (string, optional): The synced doc's path in Monton, for a synced doc.
  - `reason` (string): Why: its bytes aren't UTF-8 text, it's over 1 MiB, or Monton doesn't allow its name. One of `not-utf8`, `too-large`, `invalid-name`.
- `notCheckedOut` (array of objects): The docs in Monton that we didn't check out, and why.
  - `fileId` (string): A doc's ID in Monton, which stays when it moves.
  - `path` (string): The doc's path in Monton, such as `plans/q3.md`.
  - `blob` (string): The hash of the doc's text at Monton's head.
  - `reason` (string): Why: a hidden file or folder, inside a tool folder such as `node_modules`, not markdown, HTML or text, a name we never write on disk, over 1 MiB, a file of yours in the way, or the disk refused it. One of `hidden`, `excluded`, `other-type`, `invalid-name`, `too-large`, `in-the-way`, `write-failed`.
  - `blockedBy` (string, optional): For `in-the-way`: the file in the way.
- `remote` (array of objects, optional): With `--remote`: what changed in Monton since your last pull.
  - Either: A doc whose text someone changed in Monton.
    - `kind` ("modified"): Someone changed its text.
    - `fileId` (string): A doc's ID in Monton, which stays when it moves.
    - `path` (string): The doc's path in Monton, such as `plans/q3.md`.
    - `base` (string): The hash of the doc's text when you last pulled it.
    - `blob` (string): The hash of its text in Monton now.
  - Or: A doc someone renamed or moved in Monton.
    - `kind` ("renamed"): Someone renamed or moved it.
    - `fileId` (string): A doc's ID in Monton, which stays when it moves.
    - `from` (string): Its path when you last pulled it.
    - `path` (string): Its path in Monton now.
    - `base` (string): The hash of the doc's text when you last pulled it.
    - `blob` (string): The hash of its text in Monton now.
  - Or: A doc someone deleted in Monton.
    - `kind` ("deleted"): Someone deleted it.
    - `fileId` (string): A doc's ID in Monton, which stays when it moves.
    - `path` (string): The doc's path in Monton, such as `plans/q3.md`.
    - `base` (string): The hash of the doc's text when you last pulled it.
  - Or: A doc someone created in Monton.
    - `kind` ("new"): Someone created it.
    - `fileId` (string): A doc's ID in Monton, which stays when it moves.
    - `path` (string): The doc's path in Monton, such as `plans/q3.md`.
    - `blob` (string): The hash of its text in Monton.

#### Errors

- `not_a_clone` (exit code 1): The command needs a clone, and the current folder isn't one, nor inside one. What to do: Run it in a folder you made with `monton clone`, or clone the workspace first.
- `damaged_folder` (exit code 1): A file in the clone's `.monton` folder is damaged or missing. What to do: Clone the workspace again into a new folder, and copy your changes over.
- `locked` (exit code 1): Another monton command is running in this clone. What to do: Wait for it to finish. If none is running, delete the lock file the message names.
- `pull_unfinished` (exit code 1): A pull in this clone stopped before it finished. What to do: Run `monton pull` to finish it, then run your command again.
- `config` (exit code 1): We couldn't read the CLI's config file, or it isn't valid JSON, or it isn't a Monton config. The message names the file. What to do: Fix the file, or delete it and run `monton login` again.
- `not_signed_in` (exit code 1): The CLI has no token for this server, or the server doesn't accept it any more: it expired or someone revoked it. What to do: Run `monton login`. An agent runs `monton login --json` and sends its user the link and code from the first line.
- `network` (exit code 1): We couldn't reach the server. What to do: Check the address in `--server` or `MONTON_SERVER` and your connection, then run the command again.
- `bad_answer` (exit code 1): The server answered something we can't read. We didn't change anything. What to do: Run the command again. If it fails the same way, update the CLI.

Besides these, it can fail with [`usage` or `internal`](#errors), as any command can, or with [an error from Monton's API](#errors).

#### Examples

After Ana edits `plans/q3.md`, writes `notes/retro.md` and deletes `notes/standup.md`:

```sh
monton status --json
```

```json
{"workspace":"acme","server":"https://monton.dev","commit":"d0f631ca1ddba8db3bcfcb9e057cdc98d0379f1bee00e75a545147a27dadd982","changes":[{"kind":"new","path":"notes/retro.md","disk":"notes/retro.md"},{"kind":"deleted","fileId":"53d03498-d810-0458-482f-b457c786f38e","path":"notes/standup.md"},{"kind":"modified","fileId":"68fd4ab1-e3b5-5706-88b4-f14d5a3080ab","path":"plans/q3.md"}],"conflicts":[],"cantPush":[],"notCheckedOut":[]}
```

#### Over MCP and in the web app

Over MCP, an agent lists the changes in a workspace with `get_history`. In the web app, you see them in History.

### `diff` {#diff}

Shows your changes as a unified diff against what you last pulled or pushed, for every doc or only for the docs at or under a path. You can run it offline. With `--remote`, we show Monton's changes since your last pull instead, without changing your files. Use it to check your changes before you push, or to see what you'd get from a pull.

#### Usage

```sh
monton diff [path] [options]
```

#### Arguments

- `[path]` (optional): A doc or folder in the clone, relative to the current folder. By default, every doc.

#### Options

- `--remote`: Show Monton's changes since your last pull instead.
- `--json`: Answer in JSON.

#### Text output

A unified diff for each doc, in the format of `git diff`, with the doc's path in Monton in each file header.

#### JSON answer

Your changes, or Monton's with `--remote`, as diffs.

- `remote` (boolean): With `--remote`: the diffs are Monton's changes since your last pull.
- `diffs` (array of objects): Each doc's diff.
  - `kind` (string): What changed. One of `modified`, `renamed`, `deleted`, `new`.
  - `from` (string or null): The path before; `null` for a new doc.
  - `to` (string or null): The path after; `null` for a deleted doc.
  - `lines` (array of strings): The unified diff's lines, without the file header.
  - `added` (number): Lines added.
  - `removed` (number): Lines removed.

#### Errors

- `not_a_clone` (exit code 1): The command needs a clone, and the current folder isn't one, nor inside one. What to do: Run it in a folder you made with `monton clone`, or clone the workspace first.
- `damaged_folder` (exit code 1): A file in the clone's `.monton` folder is damaged or missing. What to do: Clone the workspace again into a new folder, and copy your changes over.
- `locked` (exit code 1): Another monton command is running in this clone. What to do: Wait for it to finish. If none is running, delete the lock file the message names.
- `pull_unfinished` (exit code 1): A pull in this clone stopped before it finished. What to do: Run `monton pull` to finish it, then run your command again.
- `config` (exit code 1): We couldn't read the CLI's config file, or it isn't valid JSON, or it isn't a Monton config. The message names the file. What to do: Fix the file, or delete it and run `monton login` again.
- `not_signed_in` (exit code 1): The CLI has no token for this server, or the server doesn't accept it any more: it expired or someone revoked it. What to do: Run `monton login`. An agent runs `monton login --json` and sends its user the link and code from the first line.
- `network` (exit code 1): We couldn't reach the server. What to do: Check the address in `--server` or `MONTON_SERVER` and your connection, then run the command again.
- `bad_answer` (exit code 1): The server answered something we can't read. We didn't change anything. What to do: Run the command again. If it fails the same way, update the CLI.
- `missing_texts` (exit code 1): The server couldn't find some of the texts we asked for, or we lost track of one during a pull. We didn't change anything. What to do: Run the command again.

Besides these, it can fail with [`usage` or `internal`](#errors), as any command can, or with [an error from Monton's API](#errors).

#### Examples

After Ana adds a line to `plans/q3.md`:

```sh
monton diff plans/q3.md --json
```

```json
{"remote":false,"diffs":[{"kind":"modified","from":"plans/q3.md","to":"plans/q3.md","lines":["@@ -2,3 +2,4 @@"," "," - Ship the docs site"," - Hire a designer","+- Plan the offsite"],"added":1,"removed":0}]}
```

#### Over MCP and in the web app

Over MCP, an agent sees how a doc changed between two versions with `get_diff`. In the web app, you see each change in History.

### `pull` {#pull}

Brings Monton's changes into your files: new, edited, renamed, moved and deleted docs. We merge them with your changes since your last pull. Where you and someone in Monton changed the same lines, we write conflict markers into the file and exit with 3; see [Conflicts](#conflicts) to resolve them. On a Monton server with images on, we also fetch the images the docs use that `attachments/` doesn't hold yet; we don't take images on monton.dev yet.

Pull before you start work, and again before a long task: people edit in Monton all the time. If a pull stops halfway, run it again to finish it; until then, we refuse to run `status`, `diff` and `push` in the clone.

#### Usage

```sh
monton pull [options]
```

#### Options

- `--json`: Answer in JSON.

#### Text output

One line with the commit we pulled and how many docs changed, were renamed, are new or were deleted, or that you were already up to date. Then a line for each doc that needs you, such as one you deleted that someone changed in Monton, the conflicts to resolve with their lines, and the images we fetched or couldn't.

#### JSON answer

What we brought into your files. Exits with 3 when it left conflicts.

- `commit` (string or null): The commit we pulled.
- `unchanged` (boolean): Monton's head was still the commit you last pulled.
- `docs` (array of objects): The docs the pull changed.
  - `fileId` (string): A doc's ID in Monton, which stays when it moves.
  - `path` (string): The doc's path in Monton, such as `plans/q3.md`.
  - `disk` (string, optional): The doc's file, when it isn't at `path`.
  - `outcome` (string): What the pull did to the doc. One of `unchanged`, `changed`, `added`, `deleted`, `restored`, `untracked`, `renamed-both`, `deleted-locally`, `left-out`, `blocked`, `skipped`.
  - `text` (string): What the file holds now: your text, Monton's, a merge, or a merge with conflict markers. One of `kept`, `monton`, `merged`, `conflicted`.
  - `why` (string, optional): Why we skipped the doc. One of `in-the-way`, `invalid-local-name`, `unresolved-conflict`.
  - `blockedBy` (string, optional): What is in the way.
- `conflicts` (array of objects): The docs with conflict markers from a pull, to resolve before you push.
  - `fileId` (string): A doc's ID in Monton, which stays when it moves.
  - `path` (string): The doc's path in Monton, such as `plans/q3.md`.
  - `disk` (string, optional): The doc's file, when it isn't at `path`.
  - `lines` (array of objects): Where the conflict markers are.
    - `start` (number): The first line of the conflict, from 1.
    - `end` (number): Its last line.
- `skipped` (array of objects): Files we left as they were.
  - `fileId` (string): A doc's ID in Monton, which stays when it moves.
  - `disk` (string): The file's path on disk, from the clone's root, with `/` between folders.
  - `reason` (string, optional): Why we left the file as it was: it changed while we pulled, something is in the way, or the disk refused. One of `changed`, `in-the-way`, `write-failed`.
  - `blockedBy` (string, optional): What is in the way.
  - `keptAs` (string, optional): Where we put your copy of a doc we could not move.
- `notCheckedOut` (array of objects): The docs in Monton that we didn't check out, and why.
  - `fileId` (string): A doc's ID in Monton, which stays when it moves.
  - `path` (string): The doc's path in Monton, such as `plans/q3.md`.
  - `blob` (string): The hash of the doc's text at Monton's head.
  - `reason` (string): Why: a hidden file or folder, inside a tool folder such as `node_modules`, not markdown, HTML or text, a name we never write on disk, over 1 MiB, a file of yours in the way, or the disk refused it. One of `hidden`, `excluded`, `other-type`, `invalid-name`, `too-large`, `in-the-way`, `write-failed`.
  - `blockedBy` (string, optional): For `in-the-way`: the file in the way.
- `images` (object): The images the docs use that we fetched into `attachments/`.
  - `fetched` (array of strings): The image files we added to `attachments/`.
  - `failed` (array of objects): Images we couldn't add.
    - `file` (string): The image file.
    - `why` (string): Why we couldn't add it.
    - `later` (boolean): A later pull may get it.

#### Errors

- `not_a_clone` (exit code 1): The command needs a clone, and the current folder isn't one, nor inside one. What to do: Run it in a folder you made with `monton clone`, or clone the workspace first.
- `damaged_folder` (exit code 1): A file in the clone's `.monton` folder is damaged or missing. What to do: Clone the workspace again into a new folder, and copy your changes over.
- `locked` (exit code 1): Another monton command is running in this clone. What to do: Wait for it to finish. If none is running, delete the lock file the message names.
- `config` (exit code 1): We couldn't read the CLI's config file, or it isn't valid JSON, or it isn't a Monton config. The message names the file. What to do: Fix the file, or delete it and run `monton login` again.
- `not_signed_in` (exit code 1): The CLI has no token for this server, or the server doesn't accept it any more: it expired or someone revoked it. What to do: Run `monton login`. An agent runs `monton login --json` and sends its user the link and code from the first line.
- `network` (exit code 1): We couldn't reach the server. What to do: Check the address in `--server` or `MONTON_SERVER` and your connection, then run the command again.
- `bad_answer` (exit code 1): The server answered something we can't read. We didn't change anything. What to do: Run the command again. If it fails the same way, update the CLI.
- `missing_texts` (exit code 1): The server couldn't find some of the texts we asked for, or we lost track of one during a pull. We didn't change anything. What to do: Run the command again.

Besides these, it can fail with [`usage` or `internal`](#errors), as any command can, or with [an error from Monton's API](#errors).

#### Examples

After someone adds a line to `README.md` in Monton:

```sh
monton pull --json
```

```json
{"commit":"7c1c97df17c066924822b0af09a65251554962c61e23329aed04cd19020dc3b8","unchanged":false,"docs":[{"fileId":"04c6e90f-aac2-675a-a89e-2176d2eec7d8","path":"README.md","outcome":"changed","text":"monton"}],"conflicts":[],"skipped":[],"notCheckedOut":[],"images":{"fetched":[],"failed":[]}}
```

#### Over MCP and in the web app

Over MCP, an agent reads the latest text of one doc with `read_doc`. In the web app, you always see it.

### `push` {#push}

Sends your changes to Monton as one commit: edited, new, renamed, moved and deleted docs. We merge them with what people typed since your last pull, so you never overwrite their work, and we leave your files as they are: run `monton pull` afterwards to see the merged text. With `-m`, you write the commit's message; otherwise we list what changed.

If your changes conflict with Monton's, we push nothing and exit with 3: run `monton pull`, resolve the conflicts, then push again. We also push nothing while a file has conflict markers, while a file can't go to Monton, or when you delete more than 5 docs without `--allow-deletes`, or your changes are bigger than one push may be without `--split`. We explain these two flags in [Many deletes and big pushes](#guards).

We don't take images on monton.dev yet: there, when a doc gains a link to an image file in the folder, we push nothing and stop with `image_refused`. On a Monton server with images on, to add an image, put the PNG, JPEG, GIF or WebP file in the folder, link it from a doc by a relative path, and push: we upload it first, then point the link at its copy in `attachments/`. That's the only change we make to your files when you push. We explain more in [Images in a clone](#images).

#### Usage

```sh
monton push [options]
```

#### Options

- `-m, --message <text>`: The commit's message. Default: a list of what changed.
- `--allow-deletes`: Push even if it deletes more than 5 docs.
- `--split`: Send a push too big for one (over 200 docs to write, 2 MiB of text, or 2,000 renames, moves and deletes) as several commits.
- `--json`: Answer in JSON.

#### Text output

One line with how many changes we pushed and the commit, or the commits with `--split`. Then the images we uploaded, the links to images we left as they were, and the docs we merged with changes in Monton.

#### JSON answer

What we sent to Monton.

- Either: Nothing to push.
  - `commit` (null): No commit.
  - `pushed` (array of objects): Empty.
    - Either: A file that a push creates as a new doc.
      - `kind` ("new"): A new doc.
      - `path` (string or null): The new doc's path in Monton; `null` when Monton doesn't allow its name.
      - `disk` (string): The file's path on disk, from the clone's root, with `/` between folders.
    - Or: A doc whose file you deleted, which a push deletes in Monton.
      - `kind` ("deleted"): A deleted doc.
      - `fileId` (string): A doc's ID in Monton, which stays when it moves.
      - `path` (string): The deleted doc's path in Monton.
    - Or: A doc whose text you changed.
      - `kind` ("modified"): A doc with new text.
      - `fileId` (string): A doc's ID in Monton, which stays when it moves.
      - `path` (string): The doc's path in Monton, such as `plans/q3.md`.
      - `disk` (string, optional): The doc's file, when it isn't at `path`.
    - Or: A doc whose file you renamed or moved.
      - `kind` ("renamed"): A renamed or moved doc.
      - `fileId` (string): A doc's ID in Monton, which stays when it moves.
      - `from` (string): The doc's path in Monton before.
      - `path` (string or null, optional): Its new path in Monton; `null` when Monton doesn't allow the new name.
      - `disk` (string, optional): Where its file is now.
      - `modified` (boolean): You changed its text as well.
- Or: What we pushed.
  - `commits` (array of strings): The commits we made: one, or several with `--split`.
  - `commit` (string or null): The last commit; `null` when the push changed nothing in Monton.
  - `pushed` (array of objects): The changes we pushed. It has the same fields as `pushed` above.
  - `merged` (array of strings): Docs with changes in Monton since your last pull, which we merged with yours.
  - `parts` (number): How many pushes we sent: 1, or more with `--split`.
  - `images` (object): The images the pushed docs link to.
    - `uploaded` (array of objects): Images we uploaded.
      - `path` (string): The image's path on disk, from the clone's root.
      - `url` (string): The image's link in Monton.
    - `reused` (array of objects): Images Monton already had, which we linked again.
      - `path` (string): The image's path on disk, from the clone's root.
      - `url` (string): The image's link in Monton.
    - `missing` (array of objects): Links to images we didn't upload, which we left as they were.
      - `doc` (string): The doc with the link.
      - `path` (string): The image the link names.
      - `why` (string): The image isn't there, or is in a hidden folder. One of `missing`, `hidden`.

#### Errors

- `not_a_clone` (exit code 1): The command needs a clone, and the current folder isn't one, nor inside one. What to do: Run it in a folder you made with `monton clone`, or clone the workspace first.
- `damaged_folder` (exit code 1): A file in the clone's `.monton` folder is damaged or missing. What to do: Clone the workspace again into a new folder, and copy your changes over.
- `locked` (exit code 1): Another monton command is running in this clone. What to do: Wait for it to finish. If none is running, delete the lock file the message names.
- `pull_unfinished` (exit code 1): A pull in this clone stopped before it finished. What to do: Run `monton pull` to finish it, then run your command again.
- `config` (exit code 1): We couldn't read the CLI's config file, or it isn't valid JSON, or it isn't a Monton config. The message names the file. What to do: Fix the file, or delete it and run `monton login` again.
- `not_signed_in` (exit code 1): The CLI has no token for this server, or the server doesn't accept it any more: it expired or someone revoked it. What to do: Run `monton login`. An agent runs `monton login --json` and sends its user the link and code from the first line.
- `network` (exit code 1): We couldn't reach the server. What to do: Check the address in `--server` or `MONTON_SERVER` and your connection, then run the command again.
- `bad_answer` (exit code 1): The server answered something we can't read. We didn't change anything. What to do: Run the command again. If it fails the same way, update the CLI.
- `missing_texts` (exit code 1): The server couldn't find some of the texts we asked for, or we lost track of one during a pull. We didn't change anything. What to do: Run the command again.
- `unresolved_conflicts` (exit code 3): Some files still have conflict markers from a pull, so we pushed nothing. What to do: In each file, keep what should stay and delete the marker lines, then push again.
  - `paths` (array of strings): The files with conflict markers, by their paths in Monton.
- `cant_push` (exit code 1): Some files can't go to Monton: their bytes aren't UTF-8 text, they're over 1 MiB, or Monton doesn't allow their names. We pushed nothing. What to do: Fix or rename each file, or move it out of the clone, then push again.
  - `files` (array of objects): The files a push can't take.
    - `disk` (string): The file's path on disk, from the clone's root, with `/` between folders.
    - `path` (string, optional): The synced doc's path in Monton, for a synced doc.
    - `reason` (string): Why: its bytes aren't UTF-8 text, it's over 1 MiB, or Monton doesn't allow its name. One of `not-utf8`, `too-large`, `invalid-name`.
- `too_many_deletes` (exit code 1): The push would delete more than 5 docs, so we pushed nothing. What to do: Check the deletes with `monton status`. If you mean them, run `monton push --allow-deletes`.
  - `deletes` (array of objects): The docs the push would delete. It has the same fields as `pushed` above.
- `doc_too_large` (exit code 1): Some docs have more than 2 MiB of text, the most one push takes, so we pushed nothing. What to do: Make each of those docs smaller, or split it into several docs.
  - `paths` (array of strings): The docs over 2 MiB.
- `push_too_large` (exit code 2): The push holds more than one push may: over 200 docs to write, 2 MiB of text, or 2,000 renames, moves and deletes. We pushed nothing. What to do: Push fewer changes at a time, or run `monton push --split` to send them as several commits.
  - `limits` (object): What one push may hold.
    - `writtenDocs` (number): The most docs one push may write.
    - `textBytes` (number): The most bytes of text one push may hold.
    - `treeChanges` (number): The most renames, moves and deletes one push may hold.
  - `counts` (object): What this push holds.
    - `docs` (number): The docs this push writes.
    - `bytes` (number): The bytes of text this push holds.
    - `treeChanges` (number): The renames, moves and deletes this push holds.
- `images_busy` (exit code 1): Monton can't tell us right now whether it still has an image an earlier push uploaded, so we pushed nothing. What to do: Push again after `retryAfter` seconds.
  - `path` (string): The image's path on disk, from the clone's root.
  - `retryAfter` (number): How many seconds to wait before you push again.
- `image_refused` (exit code 1): Monton didn't take an image a doc links to, or we couldn't read the image, so we pushed nothing. What to do: Read the message, then fix or replace the image and push again. Monton takes PNG, JPEG, GIF and WebP files up to 10 MB.
  - `path` (string): The image's path on disk, from the clone's root.
  - `serverCode` (string, optional): When Monton refused the upload: the server's code, or an empty string.
  - `status` (number, optional): When Monton refused the upload: the answer's HTTP status.
- `unknown_base` (exit code 1): Monton doesn't know the versions some of your docs started from, so we pushed nothing. What to do: Run `monton pull`, then push again.
  - `fileIds` (array of strings): The docs whose base version Monton lacks.
  - `commits` (array of strings, optional): For `monton push --split`: the commits we had already pushed before the error, which are in Monton.
- `conflict` (exit code 3): Your changes conflict with changes someone made in Monton since your last pull, so we pushed nothing. What to do: Run `monton pull`, resolve the conflicts it marks, then push again.
  - `conflicts` (array of objects): What conflicts.
    - `kind` (string): What conflicts: `content` for the same lines changed on both sides, or a change to the tree such as a move onto a path someone took.
    - `path` (string or null): The path in Monton the conflict is about, if any.
    - `fileId` (string, optional): A doc's ID in Monton, which stays when it moves.
    - `deletedBy` (string, optional): For a doc one side deleted while the other changed it: who deleted it, this push or someone in Monton. One of `push`, `monton`.
  - `commits` (array of strings, optional): For `monton push --split`: the commits we had already pushed before the error, which are in Monton.
- `history_pending` (exit code 1): Your edits are in Monton, but we couldn't save them as a commit, so your renames, new docs and deletes didn't happen. What to do: Push again to send the renames, new docs and deletes.
  - `edited` (array of objects): The docs whose edits are in Monton.
    - `fileId` (string): A doc's ID in Monton, which stays when it moves.
    - `version` (string): The version of the text we pushed.
    - `merged` (boolean): Monton had changes to this doc since your last pull, which we merged.
  - `notApplied` (object): The changes to the tree that didn't happen.
    - `moves` (array of objects): Renames and moves that didn't happen.
      - `fileId` (string): A doc's ID in Monton, which stays when it moves.
      - `path` (string): Where the push moved it.
    - `creates` (array of strings): New docs we didn't create.
    - `deletes` (array of strings): Docs we didn't delete.
  - `commits` (array of strings, optional): For `monton push --split`: the commits we had already pushed before the error, which are in Monton.

Besides these, it can fail with [`usage` or `internal`](#errors), as any command can, or with [an error from Monton's API](#errors).

#### Examples

After Ana adds a line to `plans/q3.md`:

```sh
monton push -m "Plan the offsite" --json
```

```json
{"commits":["9c0abe51c6e6655d81de2d044d4fb194931f058c0426c67c7285d8f5657ed64a"],"commit":"9c0abe51c6e6655d81de2d044d4fb194931f058c0426c67c7285d8f5657ed64a","pushed":[{"kind":"modified","fileId":"68fd4ab1-e3b5-5706-88b4-f14d5a3080ab","path":"plans/q3.md"}],"merged":[],"parts":1,"images":{"uploaded":[],"reused":[],"missing":[]}}
```

After Ana and someone in Monton change the same line of `notes/standup.md`, the push fails with exit code 3:

```sh
monton push --json
```

```json
{"error":{"conflicts":[{"kind":"content","fileId":"53d03498-d810-0458-482f-b457c786f38e","path":"notes/standup.md"}],"code":"conflict","message":"We didn't push anything: 1 doc conflicts with changes in Monton since your last pull.\n  notes/standup.md: you and someone in Monton changed the same lines.\nRun `monton pull` to merge those changes into your files, resolve the conflicts, then push again."}}
```

#### Over MCP and in the web app

Over MCP, an agent changes one doc at a time with `edit_doc` and `write_doc`, and we merge a write with changes since its base version as we do a push. People edit in the web app, and we save as they type.

### `help agents` {#help}

Prints a short guide for coding agents: how to sign in, pull before work, edit files, push, resolve conflicts, add images and import, and when to ask their user first. Paste it into your coding agents' instructions, such as a repo's `AGENTS.md` or `CLAUDE.md`, or give them the [monton-cli skill](https://monton.dev/docs/working-with-agents#skills), with which they learn to use the CLI and Monton's MCP tools together.

Run `monton help <command>` to see a command's help, as with `monton <command> --help`.

#### Usage

```sh
monton help agents [options]
```

#### Options

- `--json`: Answer in JSON.

#### Text output

The guide, in markdown.

#### JSON answer

The guide to paste into your coding agents' instructions.

- `guide` (string): The guide for coding agents, in markdown.

#### Errors

Besides these, it can fail with [`usage` or `internal`](#errors), as any command can.

#### Examples

We cut the guide short here:

```sh
monton help agents --json
```

```json
{"guide":"# Working in a Monton clone\n\nThis folder is a clone of a Monton workspace…"}
```

## How clone, pull and push work together {#sync}

With `monton clone`, you make a folder that we keep in step with a workspace. You and your coding agents edit its docs as files, send your changes with `monton push`, and bring in what people and other agents changed in Monton with `monton pull`. Pull before you start, push when you're done, and pull again to see the merged text.

### The folder {#clone-folder}

We check out each doc an import would take: `.md`, `.markdown`, `.mdx`, `.html` and `.txt` files up to 1 MiB, outside hidden folders and tool folders such as `node_modules`, with names we can write on your disk. We never write any other kind of file, so nobody can plant a script or a tool's settings on your computer through a workspace, and we never write outside the folder or follow links. Files of yours that aren't docs, such as code or notes in other formats, stay yours: we never read, push or delete them. Run `monton status` to see the docs we didn't check out, and why.

In the `.monton` folder at the clone's root, we keep the workspace and server the clone came from, the version of each doc you last pulled or pushed, and a copy of those versions, so you can run `status` and `diff` offline. Leave it as it is; if it gets damaged, clone the workspace again. We keep no token there.

### Merges {#merges}

We keep each doc's ID when someone renames or moves it, so we match docs by ID, not by path. When you push, we merge your changes with what people typed since your last pull, doc by doc, starting from the version each file started from, as `write_doc` does over MCP. We apply a push all at once or not at all, and record it as one commit by the CLI's agent; with `--split`, we apply and record each part that way. In one rare case, when we can't save the commit after we apply your edits, the edits stay in Monton without your renames, new docs and deletes, and the error says so: push again to send them. Apart from new image links, we never change your files when you push: run `monton pull` afterwards to see the merged text.

When you pull, we merge Monton's changes into your files the same way, and write each file through a temporary file, so a file never ends up half written. We never replace a file that changed while we pulled; the next pull merges it. If a pull stops halfway, run `monton pull` again to finish it.

### Conflicts {#conflicts}

A conflict happens when you and someone in Monton change the same lines of a doc, or make changes that can't both stand, such as two different renames of one doc. Then we push nothing and exit `monton push` with 3. Run `monton pull`: where both sides changed the same lines, we write conflict markers into the file and list the lines.

```text
<<<<<<< current (in Monton)
their text
||||||| base (the version you started from)
the text before either change
=======
your text
>>>>>>> yours
```

Keep what should stay, delete the marker lines, then push. We refuse to push a file that still has these markers. We go through the steps in [Troubleshooting](https://monton.dev/docs/troubleshooting#push-conflict).

### Deletes and renames {#deletes-and-renames}

Delete a file to delete its doc, and rename or move a file to rename or move its doc. We pair a renamed file with its doc by its text, as git does, and you see the pair in `monton status` before you push. When you rename a doc in the clone and someone edits it in Monton, we keep both changes. When one side deleted a doc and the other changed it, we keep the doc and say so: delete it again to push the delete. People can bring back a deleted doc from the "Recently deleted" page in the web app, with its history and comments, but not from the clone.

## Many deletes and big pushes {#guards}

To delete more than 5 docs in one push, you need `--allow-deletes`. We ask for it to catch a mistake, such as an agent clearing out a folder or someone running a script in the wrong place: without the flag, we push nothing and list the deletes. Check them with `monton status` first.

One push may write at most 200 docs, hold 2 MiB of text, and make 2,000 renames, moves and deletes, so that we hold the workspace only briefly while people type. To push more than that, you need `--split`, and then we send your changes as several commits instead of one. If we fail partway, we list the commits already in Monton in the error's `commits` field.

Coding agents should ask their user before they add either flag. We list the errors from these checks in [Troubleshooting](https://monton.dev/docs/troubleshooting#push-too-big).

## Images in a clone {#images}

We don't take images on monton.dev yet. There, when a doc in the clone gains a link to a PNG, JPEG, GIF or WebP file in the folder, such as `![Chart](chart.png)`, we push nothing, and we stop with `image_refused` and the message "This Monton server doesn't take images." Remove the link, or link to an image on the web instead, then push again. We leave links to images on the web as they are.

On a Monton server with images on, we put the images the docs use in `attachments/` at the clone's root, and the docs link to them there by a relative path. When you pull, we fetch the images that `attachments/` doesn't hold yet. To add an image, put the PNG, JPEG, GIF or WebP file anywhere in the folder, link it from a doc by a relative path, such as `![Chart](chart.png)`, and push: we upload it, then point the link at its copy in `attachments/`. We take images up to 10 MB. If we can't take one, we push nothing. Files in `attachments/` are never docs, and when you delete one, we change nothing in Monton.

## Set the CLI up for coding agents {#agents}

Coding agents such as Claude Code and Codex work well with the CLI: they edit docs with their usual tools and push. To teach them how:

- Paste the guide from [`monton help agents`](#help) into your repo's `AGENTS.md` or `CLAUDE.md`, or into your agent's instructions.
- Or add the [monton-cli skill](https://monton.dev/docs/working-with-agents#skills), which covers the CLI and Monton's MCP tools together.

An agent signs in with `monton login --json`. We print the link and the code on the first line. The agent sends both to its own user only, in their private chat, and waits while the user opens the link on any device where they're signed in to Monton, checks the code and connects the CLI. If that line has `"thisComputerOnly": true`, the link works only in a browser on the computer the agent runs on. Once the user connects the CLI, we print the second line and the command exits; an agent whose shell can't wait that long runs it in the background. Then the agent runs `monton whoami` and checks that it names its user's email; if it doesn't, the agent runs `monton logout` and tells its user. An agent never asks its user for a token.
