# Integrating OfficeCLI with Claude Code: A Complete Guide to AI-Native Document Automation

> Automate documents with OfficeCLI and Claude Code. Read edit and generate Word Excel and PowerPoint files using AI without Office installed. Learn how.

- Repository: [OfficeAI/OfficeCLI](https://github.com/iofficeai/OfficeCLI)
- Tags: how-to-guide
- Published: 2026-07-10

---

**OfficeCLI provides a built-in MCP server and automatic skill discovery that enables Claude Code to read, edit, and generate Word, Excel, and PowerPoint documents through deterministic JSON-RPC calls without requiring Microsoft Office installation.**

OfficeCLI from the `iOfficeAI/OfficeCLI` repository is a self-contained, cross-platform binary designed specifically for AI-native document manipulation. Its architecture eliminates the traditional dependency on Microsoft Office installations while providing Claude Code with full programmatic control over OOXML documents through a progressive API and real-time preview capabilities.

## Architecture Built for Claude Code Integration

OfficeCLI employs a **three-layer command model** (L1 Read, L2 DOM, L3 Raw XML) that provides a progressive API starting with high-level views and falling back to raw OOXML only when necessary. This design is implemented in the repository's core documentation at [`README.md`](https://github.com/iOfficeAI/OfficeCLI/blob/main/README.md) and allows Claude Code to interact with documents at the appropriate abstraction level.

The tool ships as a **single binary with an embedded .NET runtime**, requiring no external dependencies or Office installations. According to the source code in [`README.md`](https://github.com/iOfficeAI/OfficeCLI/blob/main/README.md) (lines 7-11), this self-contained distribution ensures consistent behavior across macOS, Linux, and Windows environments.

## Registering the MCP Server

OfficeCLI exposes a **built-in MCP (Model Context Protocol) server** that registers the CLI as a JSON-RPC tool for Claude Code. The server implementation handles the translation between Claude Code's natural language requests and precise document mutations.

To register the MCP server for Claude Code, execute:

```bash
officecli mcp claude

```

This command launches a local HTTP JSON-RPC endpoint that Claude Code can invoke. The server supports automatic skill discovery—on first run, OfficeCLI scans known configuration directories and installs a [`SKILL.md`](https://github.com/iOfficeAI/OfficeCLI/blob/main/SKILL.md) file that describes all available commands.

If automatic installation fails, manually install the skill file:

```bash
curl -fsSL https://officecli.ai/SKILL.md -o ~/.claude/skills/officecli.md

```

The [`SKILL.md`](https://github.com/iOfficeAI/OfficeCLI/blob/main/SKILL.md) file (located in the repository root) contains the complete command reference that Claude Code uses to understand OfficeCLI's capabilities.

## Document Creation and Manipulation

Once registered, Claude Code can issue commands through JSON-RPC calls. OfficeCLI supports deterministic JSON output via the `--json` flag, providing Claude Code with stable schemas for parsing results and handling errors.

Create a new PowerPoint deck:

```bash
officecli create deck.pptx

```

Add a slide with a specific title:

```bash
officecli add deck.pptx / --type slide --prop title="Q4 Report"

```

Add a text shape with precise positioning:

```bash
officecli add deck.pptx '/slide[1]' --type shape \
  --prop text="Revenue grew 25%" --prop x=2cm --prop y=5cm \
  --prop font=Arial --prop size=24 --prop color=FFFFFF

```

Retrieve structured document data for inspection:

```bash
officecli get deck.pptx '/slide[1]/shape[1]' --json

```

According to [`README.md`](https://github.com/iOfficeAI/OfficeCLI/blob/main/README.md) (lines 11-13), every command supports the `--json` flag, ensuring that Claude Code receives machine-readable responses rather than formatted text.

## Live Preview and Visual Feedback

OfficeCLI provides Claude Code with "eyes" on the output through the **live preview server**. This capability enables a *render → look → fix* loop where Claude Code can verify visual changes before finalizing documents.

Start the live preview server:

```bash
officecli watch deck.pptx

```

This command launches a local server that refreshes rendered HTML each time the document mutates. The implementation resides in [`src/officecli/Resources/watch-sse-core.js`](https://github.com/iOfficeAI/OfficeCLI/blob/main/src/officecli/Resources/watch-sse-core.js), which handles Server-Sent Events for real-time updates, while [`src/officecli/Resources/preview.js`](https://github.com/iOfficeAI/OfficeCLI/blob/main/src/officecli/Resources/preview.js) manages the HTML rendering engine. The overlay UI is supplied by [`src/officecli/Resources/watch-overlay.js`](https://github.com/iOfficeAI/OfficeCLI/blob/main/src/officecli/Resources/watch-overlay.js).

As documented in [`README.md`](https://github.com/iOfficeAI/OfficeCLI/blob/main/README.md) (lines 65-69), this server allows Claude Code to verify layout, typography, and positioning without external tools.

## Batch Operations and Error Handling

For complex document transformations, OfficeCLI supports batch operations that apply multiple mutations atomically. Claude Code can generate JSON batch files containing sequences of commands.

Execute multiple mutations in a single call:

```bash
cat <<EOF | officecli batch deck.pptx --json
[
  {"command":"set","path":"/slide[1]/shape[1]","props":{"text":"Updated headline"}},
  {"command":"set","path":"/slide[1]/shape[1]","props":{"fill":"#FF0000"}}
]
EOF

```

Error handling follows precise codes (e.g., `not_found`, `invalid_value`) as specified in [`README.md`](https://github.com/iOfficeAI/OfficeCLI/blob/main/README.md) (lines 55-63). These deterministic error codes enable Claude Code to automatically correct malformed requests without human intervention.

Persist changes to disk before external processes access the file:

```bash
officecli save deck.pptx

```

## Summary

- **Single binary distribution** with embedded .NET runtime eliminates Office installation requirements
- **Built-in MCP server** at `officecli mcp claude` provides JSON-RPC integration for Claude Code
- **Automatic skill discovery** via [`SKILL.md`](https://github.com/iOfficeAI/OfficeCLI/blob/main/SKILL.md) installation enables immediate command visibility
- **Three-layer API** (Read/DOM/Raw XML) offers progressive access to document complexity
- **Deterministic JSON output** via `--json` flag ensures reliable parsing by AI agents
- **Live preview server** (`officecli watch`) provides real-time visual feedback for document editing
- **Precise error codes** allow autonomous error correction by Claude Code

## Frequently Asked Questions

### Does Claude Code require Microsoft Office installed to use OfficeCLI?

No. OfficeCLI is a completely self-contained binary with an embedded .NET runtime. According to the source code in [`README.md`](https://github.com/iOfficeAI/OfficeCLI/blob/main/README.md) (lines 7-11), it operates independently of Microsoft Office installations, making it suitable for headless environments and CI/CD pipelines where Office cannot be installed.

### How does OfficeCLI communicate with Claude Code?

OfficeCLI implements the Model Context Protocol (MCP) as a JSON-RPC server. When you run `officecli mcp claude`, the tool starts a local HTTP endpoint that accepts structured requests from Claude Code. The Node.js SDK available at [`sdk/node/index.js`](https://github.com/iOfficeAI/OfficeCLI/blob/main/sdk/node/index.js) provides additional programmatic access for JavaScript-based integrations.

### What is the three-layer command model in OfficeCLI?

The three-layer model provides progressive API access: **L1 (Read)** offers high-level document views, **L2 (DOM)** allows manipulation of document object model elements, and **L3 (Raw XML)** enables direct OOXML modification. As documented in [`README.md`](https://github.com/iOfficeAI/OfficeCLI/blob/main/README.md) (lines 42-47), this architecture allows Claude Code to start with simple operations and access lower-level controls only when necessary.

### Can OfficeCLI handle multiple document mutations in a single request?

Yes. The `batch` command accepts JSON arrays containing multiple operations that execute atomically. This minimizes process spawning overhead and ensures consistency when Claude Code needs to apply complex transformations. The batch input format accepts standard command objects with `command`, `path`, and `props` properties.