docx Skill for AI Agents
by Anthropic
Document creation, editing, and analysis with support for tracked changes, comments, formatting preservation, and text extraction. Use when working with Word documents (.docx) for creating, modifying, reviewing, or analyzing professional documents.
53downloads
Updated
About this Skill
The docx skill enables AI agents like Claude and ChatGPT to document creation, editing, and analysis with support for tracked changes, comments, formatting preservation, and text extraction. use when working with word documents (.docx) for creating, modifying, reviewing, or analyzing professional documents.
SKILLS.md Content
# DOCX Processing
Comprehensive toolkit for Word document manipulation.
## Core Capabilities
- Document creation from scratch
- Editing existing documents
- Tracked changes support
- Comments and annotations
- Formatting preservation
- Text extraction and analysis
## Primary Workflows
### Reading/Analysis
Use text extraction for content analysis. Access raw XML for:
- Comments
- Complex formatting
- Document metadata
### Creating Documents
Use docx-js library with JavaScript/TypeScript to build new Word documents from scratch.
### Editing Existing Documents
Python-based Document library handles OOXML manipulation with:
- High-level methods for common operations
- Direct DOM access for complex changes
### Document Review (Redlining)
For tracked changes:
1. Plan changes in markdown first
2. Implement systematic OOXML edits
3. Preserve revision history
## Key Implementation Principles
### Minimal, Precise Edits
Only mark text that actually changes. Don't replace entire sentences when modifying a word.
### Preserve Unchanged Content
Reuse original XML elements with their RSID values for unchanged portions.
### Batching Strategy
Group 3-10 related changes per batch:
- Enables manageable debugging
- Maintains efficiency
- Reduces error surface
## Technical Operations
```
# Unpack document
python ooxml/scripts/unpack.py document.docx
# Modify XML files...
# Repack document
python ooxml/scripts/pack.py document.docx
```
## Visual Analysis
Convert documents to PDF then JPEG for visual inspection when needed.
## Best Practices
- Always work on copies, not originals
- Validate document structure after edits
- Test tracked changes display in Word
- Preserve styles and formatting