OfficeCLI
Website: https://officecli.ai CLI Tool: officecli Repository: https://github.com/iOfficeAI/OfficeCLI License: Apache 2.0
Description
AI-native command-line tool for creating, reading, and modifying Word (.docx), Excel (.xlsx), and PowerPoint (.pptx) files. Single binary with no Office installation or external dependencies required. Features path-based element access, JSON output, and live preview. Designed for AI agents like Claude Code, Cursor, and GitHub Copilot.
Install
# macOS / Linux
curl -fsSL https://raw.githubusercontent.com/iOfficeAI/OfficeCLI/main/install.sh | bash
# Windows (PowerShell)
irm https://raw.githubusercontent.com/iOfficeAI/OfficeCLI/main/install.ps1 | iex
# Verify
officecli --version
# Install skill for AI agents (auto-detects Claude Code, Cursor, etc.)
officecli install
Commands
| Command | Description |
|---|---|
officecli create <file> |
Create blank .docx, .xlsx, or .pptx |
officecli view <file> |
Display content (outline, text, annotated, stats, html) |
officecli get <file> <path> |
Get element properties (--json for structured output) |
officecli set <file> <path> |
Modify element properties |
officecli add <file> <path> |
Insert new elements |
officecli remove <file> <path> |
Delete elements |
officecli query <file> <selector> |
CSS-like element selection |
officecli merge <template> <output> <json> |
Template substitution |
officecli batch <file> |
Execute multiple operations atomically |
officecli watch <file> |
Live HTML preview with auto-refresh |
officecli validate <file> |
Check OpenXML schema conformance |
officecli mcp <tool> |
Register MCP server (claude, cursor, vscode) |
Path Syntax
Elements are addressed using XPath-like paths:
- /slide[1] - First slide
- /slide[1]/shape[1] - First shape on first slide
- /sheet[1]/cell[A1] - Cell A1 on first sheet
- /paragraph[1]/run[1] - First run in first paragraph
Examples
PowerPoint
# Create presentation
officecli create deck.pptx
# Add slide with title
officecli add deck.pptx / --type slide --prop title="Q4 Report"
# Add text shape
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
# View structure
officecli view deck.pptx --format outline
# Live preview
officecli watch deck.pptx --port 26315
Word
# Create document
officecli create report.docx
# Add paragraph
officecli add report.docx / --type paragraph --prop text="Executive Summary"
# Set paragraph style
officecli set report.docx '/paragraph[1]' --prop style=Heading1
# View as text
officecli view report.docx --format text
Excel
# Create spreadsheet
officecli create data.xlsx
# Set cell values
officecli set data.xlsx '/sheet[1]/cell[A1]' --prop value="Sales"
officecli set data.xlsx '/sheet[1]/cell[B1]' --prop value=1000
# Add formula
officecli set data.xlsx '/sheet[1]/cell[B10]' --prop formula="=SUM(B1:B9)"
# Query cells
officecli query data.xlsx '/sheet[1]/cell[@value>100]' --json
Template Merge
# Merge data into template
officecli merge template.docx output.docx '{"name":"Alice","dept":"Sales","date":"2024-01-15"}'
Batch Operations
# Multiple operations in one save
echo '[
{"command":"set","path":"/slide[1]/shape[1]","props":{"text":"Hello"}},
{"command":"add","path":"/slide[1]","type":"shape","props":{"text":"World"}}
]' | officecli batch deck.pptx --json
AI Agent Integration
# Auto-detect and configure AI tools
officecli install
# Or manually register MCP server
officecli mcp claude # Claude Code
officecli mcp cursor # Cursor
officecli mcp vscode # VS Code / GitHub Copilot
Python Integration
import subprocess, json
def officecli(*args):
result = subprocess.run(["officecli", *args], capture_output=True, text=True)
return result.stdout
# Create and modify
officecli("create", "report.pptx")
officecli("add", "report.pptx", "/", "--type", "slide", "--prop", "title=Summary")
officecli("set", "report.pptx", "/slide[1]/shape[1]", "--prop", "text=Hello World")
# Get as JSON
data = json.loads(officecli("get", "report.pptx", "/slide[1]", "--json"))
Three-Layer Architecture
| Layer | Purpose | Commands |
|---|---|---|
| L1: Read | High-level semantic views | view with text/outline/annotated |
| L2: DOM | Element-level operations | get, set, add, remove, query |
| L3: Raw XML | XPath fallback for edge cases | raw, raw-set |
Output Formats
All commands support --json for machine-readable output:
{
"tag": "shape",
"path": "/slide[1]/shape[1]",
"attributes": {"name": "TextBox 1", "text": "Hello"}
}
Errors include suggestions:
{
"success": false,
"error": {
"error": "Slide 50 not found (total: 8)",
"code": "not_found",
"suggestion": "Valid Slide index range: 1-8"
}
}
Notes
- Single binary: No Office installation, no dependencies
- Cross-platform: macOS, Linux, Windows (x64 & ARM64)
- JSON output: All commands support
--jsonfor AI consumption - Live preview:
watchcommand opens browser with auto-refresh - Resident mode:
open/closefor multi-step workflows with near-zero latency - Headless-friendly: Works in CI/CD and server environments
Comments (0)
Add a Comment
No comments yet. Be the first to comment!