# Automate a DOCX from the CLI

> Accept tracked changes and save a separate DOCX from a shell or CI job.




Use the CLI when a shell script or CI job already knows which document operation to run. This guide accepts every
tracked change in a DOCX and writes the result to a separate file.

## 1. Install the CLI [#1-install-the-cli]

```bash
pnpm add --global @superdoc/cli@latest
```

The package installs the matching native command for your platform. Published builds support macOS on Apple Silicon and
Intel, Linux on ARM64 and x64, and Windows on x64.

Confirm that the command is available:

```bash
superdoc --version
```

## 2. Prepare a document [#2-prepare-a-document]

Download the [tracked-changes fixture](/fixtures/tracked-changes.docx) and save it as `contract.docx` in your working
directory. It contains one tracked change.

[Download the tracked-changes fixture](/fixtures/tracked-changes.docx): Synthetic NDA with one tracked change · DOCX


## 3. Accept the changes and save [#3-accept-the-changes-and-save]

Create `accept-changes.sh`:

```sh
#!/usr/bin/env bash
set -euo pipefail

superdoc open ./contract.docx
trap 'superdoc close --discard >/dev/null 2>&1 || true' EXIT
superdoc track-changes list
superdoc track-changes accept-all
superdoc save --out ./contract.accepted.docx

```

Run it from the directory containing `contract.docx`:

```bash
bash accept-changes.sh
```

`open` creates an active document session. The review command changes that session, and `save --out` writes a separate
DOCX. The `EXIT` trap closes the session whether the script succeeds or fails. The source file is not overwritten.

> **Keep the output path clear (warning)**
>
> The CLI refuses to replace an existing output file unless you pass `--force`. Rename or inspect the existing file
> before rerunning the script.


## 4. Verify the output [#4-verify-the-output]

Open `contract.accepted.docx` in Microsoft Word or the SuperDoc editor. Every tracked change should be accepted. The
original `contract.docx` should remain unchanged.

> **Verification target (success)**
>
> The output contains the same document content and formatting with no pending tracked changes. The source file remains
> unchanged.


Use the [Node.js SDK](/agents/automation/node-sdk) or [Python SDK](/agents/automation/python-sdk) when application code
needs to own the workflow, errors, and output paths. For the operation and receipt model shared by every surface,
continue with the [Document API mental model](/document-api/mental-model).
