FISCFED9/CLI / .agents/skills/docx-processing-lawvable
Word Editor
VerifiedEdit, query, and transform Word documents (.docx) with the SuperDoc CLI. Use when the user asks to read, search, modify, format, comment, track changes, or review changes in .docx files. Triggers on any task involving Word documents — text replacement, redlining, contract markup, template filling, bulk edits, content extraction, or document review.
| File | Kind | Size |
|---|---|---|
| LICENSE.txt | markdown | 33.7 KB |
| SKILL.md | skill md | 5.6 KB |
| references/bookmarks-footnotes.md | markdown | 2.2 KB |
| references/citations.md | markdown | 2.6 KB |
| references/comments.md | markdown | 2.6 KB |
| references/content-controls.md | markdown | 6.2 KB |
| references/create.md | markdown | 2.6 KB |
| references/diff.md | markdown | 2.0 KB |
| references/format.md | markdown | 7.3 KB |
| references/headers-footers.md | markdown | 1.4 KB |
| references/hyperlinks.md | markdown | 2.1 KB |
| references/images.md | markdown | 2.6 KB |
| references/index.md | markdown | 6.0 KB |
| references/lists.md | markdown | 4.3 KB |
| references/mutations-apply.md | markdown | 6.4 KB |
| references/mutations.md | markdown | 4.8 KB |
| references/protection.md | markdown | 849 B |
| references/reading.md | markdown | 5.2 KB |
| references/sections.md | markdown | 1.8 KB |
| references/session.md | markdown | 2.7 KB |
| references/tables.md | markdown | 7.2 KB |
| references/toc.md | markdown | 2.3 KB |
| references/track-changes.md | markdown | 1.8 KB |
references/mutations-apply.md
View on GitHub# Critical Patterns
### mutations apply (batch / find-and-replace)
The most powerful command. Handles find-and-replace, multi-step edits, and atomic batches -- all declaratively. **Use this instead of individual replace/delete/format calls whenever possible.**
```bash
superdoc mutations apply --atomic true --change-mode tracked --steps-json '<JSON array>' 2>/dev/null
```
| Flag | Type | Required | Description |
|------|------|----------|-------------|
| `--steps-json` | JSON array | yes | Array of mutation step objects |
| `--atomic` | boolean | no | Execute all steps in a single transaction (default: true) |
| `--change-mode` | string | no | `direct` or `tracked` |
| `--session` | string | no | Session ID |
| `--expected-revision` | number | no | Optimistic concurrency check |
| `--in-json` | JSON | no | Story scope (defaults to body) |
| `--out` | string | no | Output file path (stateless mode) |
### Step Format
Each step needs: `id`, `op`, `where`, `args`.
```json
{
"id": "unique-step-id",
"op": "<operation>",
"where": { ... },
"args": { ... }
}
```
Available `op` values: `text.rewrite`, `text.insert`, `text.delete`, `format.apply`, `assert`.
---
#### text.rewrite -- find and replace text
```json
{
"id": "s1",
"op": "text.rewrite",
"where": {
"by": "select",
"select": { "type": "text", "pattern": "old text" },
"require": "all"
},
"args": {
"replacement": { "text": "new text" }
}
}
```
**`require` values:**
| Value | Behavior |
|-------|----------|
| `"all"` | Replace every match (global find-and-replace). Fails if 0 matches. |
| `"first"` | Replace only the first match |
| `"exactlyOne"` | Fail if there is not exactly one match |
**`select` options:**
| Selector | Description |
|----------|-------------|
| `{"type": "text", "pattern": "..."}` | Substring match (default, case-insensitive) |
| `{"type": "text", "pattern": "...", "mode": "regex"}` | Regex match |
| `{"type": "text", "pattern": "...", "caseSensitive": true}` | Case-sensitive substring |
| `{"type": "node", "nodeType": "paragraph"}` | Match by node type |
**Optional: scope to a specific block with `within`:**
```json
"where": {
"by": "select",
"select": { "type": "text", "pattern": "old" },
"within": { "kind": "block", "nodeType": "paragraph", "nodeId": "ABC123" },
"require": "all"
}
```
**Optional: control replacement styling:**
```json
"args": {
"replacement": { "text": "new text" },
"style": {
"inline": {
"mode": "preserve",
"setMarks": { "bold": "on", "italic": "clear" }
}
}
}
```
Style `mode`: `"preserve"` (keep original formatting), `"set"`, `"clear"`, `"merge"`.
---
#### text.insert -- insert text relative to a match
```json
{
"id": "s2",
"op": "text.insert",
"where": {
"by": "select",
"select": { "type": "text", "pattern": "anchor text" },
"require": "first"
},
"args": {
"position": "after",
"content": { "text": " inserted text" }
}
}
```
`position`: `"before"` or `"after"` the matched text.
---
#### text.delete -- delete matched text
```json
{
"id": "s3",
"op": "text.delete",
"where": {
"by": "select",
"select": { "type": "text", "pattern": "text to remove" },
"require": "all"
},
"args": { "behavior": "selection" }
}
```
`behavior`: `"selection"` (default, deletes the matched text range) or `"exact"`.
---
#### format.apply -- format matched text
```json
{
"id": "s4",
"op": "format.apply",
"where": {
"by": "select",
"select": { "type": "text", "pattern": "text to format" },
"require": "all"
},
"args": {
"inline": { "bold": true, "fontSize": 14, "fontFamily": "Arial" }
}
}
```
All inline properties from `format apply` are available (bold, italic, underline, strike, fontSize, fontFamily, color, highlight, etc.). Set a property to `null` to clear it.
---
#### assert -- validate document state
```json
{
"id": "s5",
"op": "assert",
"where": {
"by": "select",
"select": { "type": "text", "pattern": "expected text" }
},
"args": { "expectCount": 3 }
}
```
Fails the entire batch if the expected count does not match. Useful for precondition checks before mutations.
---
### Targeting with `where` -- the 3 modes
#### Mode 1: `by: "select"` (preferred for find-and-replace)
```json
"where": {
"by": "select",
"select": { "type": "text", "pattern": "search text" },
"require": "all"
}
```
#### Mode 2: `by: "ref"` (from a previous query match result)
```json
"where": {
"by": "ref",
"ref": "text:v4:eyJ..."
}
```
Use the `.handle.ref` value from a `query match` response.
#### Mode 3: `by: "target"` (explicit SelectionTarget from query match)
```json
"where": {
"by": "target",
"target": {
"kind": "selection",
"start": { "kind": "text", "blockId": "ABC123", "offset": 0 },
"end": { "kind": "text", "blockId": "ABC123", "offset": 8 }
}
}
```
Use the `.target` value from a `query match` response.
---
### SelectionTarget Format
Used by `--target-json` across replace, delete, format apply, and `by: "target"` in mutations apply.
**Text-offset addressing (character-level):**
```json
{
"kind": "selection",
"start": { "kind": "text", "blockId": "ABC123", "offset": 0 },
"end": { "kind": "text", "blockId": "ABC123", "offset": 8 }
}
```
**Block-edge addressing (whole-block operations):**
```json
{
"kind": "selection",
"start": { "kind": "nodeEdge", "node": { "kind": "block", "nodeType": "paragraph", "nodeId": "ABC123" }, "edge": "before" },
"end": { "kind": "nodeEdge", "node": { "kind": "block", "nodeType": "paragraph", "nodeId": "ABC123" }, "edge": "after" }
}
```
**BlockNodeAddress (for structural replacements):**
```json
{
"kind": "block",
"nodeType": "paragraph",
"nodeId": "ABC123"
}
```
Valid `nodeType` values: `paragraph`, `heading`, `listItem`, `table`, `tableRow`, `tableCell`, `tableOfContents`, `image`, `sdt`.
Valid `edge` values: `before`, `after`.
---
### Multiple Steps in One Batch
Steps execute in order within a single atomic transaction:
```json
[
{"id":"s1","op":"text.rewrite","where":{"by":"select","select":{"type":"text","pattern":"ACME"},"require":"all"},"args":{"replacement":{"text":"NewCo"}}},
{"id":"s2","op":"text.rewrite","where":{"by":"select","select":{"type":"text","pattern":"2024"},"require":"all"},"args":{"replacement":{"text":"2025"}}},
{"id":"s3","op":"format.apply","where":{"by":"select","select":{"type":"text","pattern":"CONFIDENTIAL"},"require":"all"},"args":{"inline":{"bold":true,"color":"#FF0000"}}}
]
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| canvas-designanthropics/skillsCreate beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| docxanthropics/skillsUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| pdfanthropics/skillsUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| pptxanthropics/skillsUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |