> ## Documentation Index
> Fetch the complete documentation index at: https://superdoc-nick-sd-2099-images-core-lifecycle-placement-seman.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI

> Edit documents from the terminal with the SuperDoc CLI

The SuperDoc CLI lets you open, query, and edit `.docx` files from any shell. It exposes the same operations as the [Document API](/document-api/overview) through a stdio-based process.

<Info>
  The CLI is in <strong>alpha</strong>. Commands and output formats may change.
</Info>

## Installation

```bash theme={null}
npm install -g @superdoc-dev/cli
```

Or run without installing:

```bash theme={null}
npx @superdoc-dev/cli open my-doc.docx
```

## Workflow

The CLI uses persistent sessions. Open a document, run operations, then save and close:

```bash theme={null}
# Open a document
superdoc open contract.docx

# Search for text
superdoc find --pattern "ACME Corp"

# Replace it
superdoc replace --target-json '{"blockId":"...","range":{"start":0,"end":9}}' --text "NewCo Inc."

# Save and close
superdoc save
superdoc close
```

## Tracked mode for mutations

Use `--tracked` on mutating commands to apply edits as tracked changes instead of direct edits.

```bash theme={null}
# Replace text as a tracked change
superdoc replace \
  --target-json '{"kind":"text","blockId":"...","range":{"start":0,"end":9}}' \
  --text "NewCo Inc." \
  --tracked

# Insert text as a tracked change
superdoc insert --text "Added clause" --tracked
```

`--tracked` is shorthand for `--change-mode tracked`:

```bash theme={null}
superdoc replace \
  --target-json '{"kind":"text","blockId":"...","range":{"start":0,"end":9}}' \
  --text "NewCo Inc." \
  --change-mode tracked
```

For commands that do not support tracked mode, the CLI returns `TRACK_CHANGE_COMMAND_UNAVAILABLE`.

## User identity

By default, the CLI attributes edits to a generic "CLI" user. Pass `--user-name` and `--user-email` on `open` to identify your automation in comments, tracked changes, and collaboration presence:

```bash theme={null}
superdoc open contract.docx --user-name "Review Bot" --user-email "bot@example.com"
```

## Commands

### Lifecycle

| Command               | Description                                                                                                                                                                                              |
| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `superdoc open <doc>` | Open a document and create an editing session. Supports `--user-name` and `--user-email` to set the editing identity. In collaboration mode, also supports `--on-missing` and `--bootstrap-settling-ms`. |
| `superdoc save`       | Save the current session to disk                                                                                                                                                                         |
| `superdoc close`      | Close the active session and clean up resources                                                                                                                                                          |

### Document operations

The CLI exposes all [Document API operations](/document-api/overview) as commands. The command name matches the operation's member path, converted to kebab-case:

| CLI command                     | Operation              | Description                                    |
| ------------------------------- | ---------------------- | ---------------------------------------------- |
| `superdoc find`                 | `find`                 | Search by text, node type, or structured query |
| `superdoc info`                 | `info`                 | Get document structure and metadata            |
| `superdoc get-node`             | `getNode`              | Get a node by address                          |
| `superdoc get-node-by-id`       | `getNodeById`          | Get a node by ID                               |
| `superdoc insert`               | `insert`               | Insert text at a position                      |
| `superdoc replace`              | `replace`              | Replace content at a position                  |
| `superdoc delete`               | `delete`               | Delete content at a position                   |
| `superdoc format bold`          | `format.bold`          | Toggle bold on a range                         |
| `superdoc format italic`        | `format.italic`        | Toggle italic on a range                       |
| `superdoc format underline`     | `format.underline`     | Toggle underline on a range                    |
| `superdoc format strikethrough` | `format.strikethrough` | Toggle strikethrough on a range                |
| `superdoc create paragraph`     | `create.paragraph`     | Insert a new paragraph                         |
| `superdoc comments create`      | `comments.create`      | Create a comment thread                        |
| `superdoc comments list`        | `comments.list`        | List all comments                              |
| `superdoc track-changes list`   | `trackChanges.list`    | List tracked changes                           |
| `superdoc track-changes decide` | `trackChanges.decide`  | Accept or reject a tracked change              |

Run `superdoc --help` for the full list, or `superdoc describe` for machine-readable metadata.

### Session management

| Command                             | Description                                     |
| ----------------------------------- | ----------------------------------------------- |
| `superdoc session list`             | List all active sessions                        |
| `superdoc session save <id>`        | Save a specific session                         |
| `superdoc session close <id>`       | Close a specific session                        |
| `superdoc session set-default <id>` | Set the default session for subsequent commands |

### Introspection

| Command                           | Description                                         |
| --------------------------------- | --------------------------------------------------- |
| `superdoc status`                 | Show current session status and document metadata   |
| `superdoc describe`               | List all available operations and contract metadata |
| `superdoc describe command <cmd>` | Show detailed metadata for a single operation       |

## JSON I/O

All commands accept `--input-json` or `--input-file` for structured input and return JSON output. Use `superdoc call <operationId>` for raw operation invocation:

```bash theme={null}
superdoc call doc.find --input-json '{"doc":"./contract.docx","query":{"select":{"type":"text","pattern":"test"}}}'
```

## Related

* [SDKs](/document-engine/sdks) — typed Node.js and Python wrappers over the CLI
* [Document API](/document-api/overview) — the in-browser API that defines the operation set
