How to Create a New PowerPoint Presentation with OfficeCLI: A Complete Guide

Use officecli create <file.pptx> to initialize a blank OpenXML package, then chain add, set, and save commands to build slides programmatically without installing Microsoft Office.

OfficeCLI is a single-binary, headless CLI tool developed by iOfficeAI that manipulates Word, Excel, and PowerPoint documents through a path-based API. According to the repository's README.md (lines 94-96), the tool parses Office OpenXML packages into an in-memory DOM, applies mutations, and writes changes back to disk only when you explicitly save, enabling batch workflows with near-zero latency.

Prerequisites and Installation

OfficeCLI ships as a self-contained binary with an embedded .NET runtime, eliminating dependency hell.

Install via the official one-liner:

curl -fsSL https://raw.githubusercontent.com/iOfficeAI/OfficeCLI/main/install.sh | bash

Once installed, verify the binary is available:

officecli --version

Initializing the .pptx File

To create a new PowerPoint presentation with OfficeCLI, run the create command followed by your desired filename:

officecli create deck.pptx

This command performs three operations atomically:

  1. Generates a fresh OpenXML package containing [Content_Types].xml, slide-master parts, and a single blank slide
  2. Registers the file in a resident session (if the CLI process remains open), keeping the DOM in memory for subsequent commands
  3. Defers disk I/O until you invoke officecli save or close, allowing you to batch hundreds of edits without intermediate writes

As documented in the PPTX skill file at skills/officecli-pptx/SKILL.md (lines 14-16), this creation flow is the entry point for both manual CLI usage and AI-agent automation.

Adding Slides and Content

OfficeCLI uses XPath-like selectors to address document parts. After creating the file, populate it using the add command with --type and --prop flags.

Adding a Blank Slide

officecli add deck.pptx / \
  --type slide --prop layout=blank --prop background=1E2761

The / path targets the presentation root, while --prop layout=blank specifies the slide master.

Inserting Text Shapes

Address specific slides using /slide[index] syntax:


# Add a title shape to slide 1

officecli add deck.pptx "/slide[1]" \
  --type shape --prop name=CoverTitle --prop text="Q4 Business Review" \
  --prop x=2cm --prop y=7cm --prop width=29.87cm --prop height=3cm \
  --prop font=Georgia --prop size=44 --prop bold=true --prop color=FFFFFF \
  --prop align=center

# Add a content slide with bullet points

officecli add deck.pptx / \
  --type slide --prop layout=blank --prop background=FFFFFF

officecli add deck.pptx "/slide[2]" \
  --type shape --prop name=BodyTitle --prop text="Revenue Growth" \
  --prop x=1.5cm --prop y=1.2cm --prop width=30cm --prop height=2cm \
  --prop font=Georgia --prop size=36 --prop bold=true --prop color=1E2761

officecli add deck.pptx "/slide[2]" \
  --type shape --prop text="• Q1: +12%  • Q2: +9%  • Q3: +8%" \
  --prop x=1.5cm --prop y=4cm --prop width=30cm --prop height=3cm \
  --prop font=Calibri --prop size=20 --prop color=333333

Adding Speaker Notes

Append notes to any slide using the notes type:

officecli add deck.pptx "/slide[2]" \
  --type notes --prop text="Emphasise the YoY trend and the drivers behind Q2."

Live Preview and Validation

Before finalizing, validate the OpenXML schema and preview the deck.

Live preview spins up a local HTTP server (implemented in src/officecli/Resources/watch-overlay.js) that auto-refreshes on every edit:

officecli watch deck.pptx   # Opens http://localhost:26315

Validation catches schema errors before saving:

officecli validate deck.pptx

Persist the package when satisfied:

officecli save deck.pptx

# Or close the resident session entirely

officecli close deck.pptx

Programmatic Integration

OfficeCLI exposes deterministic JSON output via the --json flag, making it ideal for automation.

Node.js SDK: The wrapper at sdk/node/index.js auto-provisions the binary and forwards commands, simplifying integration into CI/CD pipelines.

MCP Server: The plugin protocol defined in plugins/plugin-protocol.md enables AI agents to invoke OfficeCLI through JSON-RPC, allowing large language models to query document structure, compute layout math, and iterate until visual QA rules are satisfied.

Example machine-readable query:

officecli get deck.pptx "/slide[1]" --json

Summary

  • Create a new .pptx with officecli create <file> to initialize the OpenXML structure in memory
  • Modify content using path-based selectors like /slide[1]/shape[@name=Title] and --prop key-value pairs
  • Batch edits efficiently through resident sessions that defer disk writes until save or close
  • Preview changes in real-time via officecli watch (powered by src/officecli/Resources/watch-overlay.js)
  • Automate using --json output or the Node.js SDK wrapper at sdk/node/index.js

Frequently Asked Questions

Do I need Microsoft Office installed to use OfficeCLI?

No. OfficeCLI is a headless, self-contained binary that parses and writes Office OpenXML packages directly. It constructs the in-memory DOM and manipulates the ZIP archive without calling any external Office applications, making it ideal for serverless environments and CI/CD pipelines.

How do I add images or charts to a PowerPoint file?

Use the --type parameter with values like image or chart followed by the appropriate --prop flags for source paths and dimensions. For example, --type image --prop src=./logo.png --prop x=1cm --prop y=1cm. The path-based API treats media as first-class document parts addressable via XPath selectors.

What is the difference between save and close?

The save command flushes the in-memory DOM to disk while keeping the resident session active for further edits. The close command writes the final package and then releases the file handle from the resident session, terminating the in-memory representation. Use save for incremental checkpoints during long editing sessions.

Can I use OfficeCLI in a Node.js script instead of the command line?

Yes. The repository includes a Node.js SDK wrapper at sdk/node/index.js that auto-downloads the correct binary for your platform and exposes the CLI commands as JavaScript functions. Additionally, the MCP server implementation (documented in plugins/plugin-protocol.md) allows AI agents to control OfficeCLI via JSON-RPC for fully automated document generation workflows.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →