Install
$ agentstack add skill-costa-marcello-skillkit-docx ✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Verified badge
Passed review? Show it. Paste this badge into your README, it links to the public security report.
Reliability & compatibility
Declared compatibility
Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.
We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.
How agent discovery & health will work →About
DOCX Creation, Editing, and Analysis
Read the relevant reference file completely before starting work:
- Creating a new document: read
references/docx-js.md - Editing an existing document: read
references/ooxml.md
Workflow Decision Tree
| Task | Workflow | Reference | |------|----------|-----------| | Read/analyse content | Text extraction (pandoc) or Raw XML | None needed | | Create new document | docx-js (JavaScript) | references/docx-js.md | | Edit your own doc (simple) | OOXML editing | references/ooxml.md | | Edit someone else's doc | Redlining workflow (recommended) | references/ooxml.md | | Legal/business/government | Redlining workflow (required) | references/ooxml.md |
If unsure who owns the document, default to Redlining. OOXML editing writes changes directly and is only safe on your own drafts where tracked changes are unwanted.
Reading and Analysing Content
Default to text extraction. Use raw XML only when you need comments, complex formatting, document structure, embedded media, or metadata.
Text Extraction (Default)
Convert the document to markdown with pandoc:
pandoc --track-changes=all path-to-file.docx -o output.md
# Options: --track-changes=accept (default) / reject / all
Default to --track-changes=all to preserve revision history. Use accept only when the user wants clean text without markup.
Raw XML Access
Use raw XML when you need: comments, complex formatting, document structure, embedded media, or metadata.
python ooxml/scripts/unpack.py
Key files after unpacking:
word/document.xml-- main document bodyword/comments.xml-- comments referenced in document.xmlword/media/-- embedded images and media- Tracked changes use `
(insertions) and` (deletions) tags
Creating a New Word Document
Use docx-js (JavaScript/TypeScript) for new documents.
- Read
references/docx-js.mdcompletely - Write a script using Document, Paragraph, TextRun components
- Export with
Packer.toBuffer() - Verify the output opens in Word/LibreOffice without errors
Task: User says "Create a one-page memo with a title and two bullet points"
Action:
- Read
references/docx-js.md - Create script with Document, Paragraph, TextRun, numbering config for bullets
- Run:
node memo.js - Verify:
soffice --headless --convert-to pdf memo.docx && pdftoppm -jpeg -r 150 memo.pdf preview
Editing an Existing Word Document
Use the Document library (Python) from scripts/document.py. It handles infrastructure setup automatically (people.xml, RSIDs, settings.xml, comments, relationships, content types).
Standard Editing Workflow
- Read
references/ooxml.mdcompletely (focus on "Document Library" section) - Unpack:
python ooxml/scripts/unpack.py - Edit using Document library methods
- Pack:
python ooxml/scripts/pack.py - Verify: convert to markdown and check output
Task: User says "Change '30 days' to '60 days' in this contract"
Action:
from scripts.document import Document
doc = Document('unpacked', track_revisions=True)
node = doc["word/document.xml"].get_node(tag="w:r", contains="30 days")
rpr = tags[0].toxml() if (tags := node.getElementsByTagName("w:rPr")) else ""
replacement = (
f'{rpr}within '
f'{rpr}30'
f'{rpr}60'
f'{rpr} days'
)
doc["word/document.xml"].replace_node(node, replacement)
doc.save()
Redlining Workflow (Document Review with Tracked Changes)
Plan tracked changes in markdown before implementing in OOXML. Group related changes into batches of 3-10 for manageable debugging.
Principle: Minimal, Precise Edits. Only mark text that actually changes. Repeating unchanged text makes edits harder to review. Break replacements into: [unchanged text] + [deletion] + [insertion] + [unchanged text]. Preserve the original run's RSID for unchanged text.
Step-by-Step
- Get markdown representation:
``bash pandoc --track-changes=all path-to-file.docx -o current.md ``
- Identify and group changes. Organise into batches by section, type, or proximity. Use these location methods for finding text in XML:
- Section/heading numbers (e.g., "Section 3.2")
- Grep patterns with unique surrounding text
- Document structure (e.g., "first paragraph after Heading 2")
- Do NOT use markdown line numbers -- they do not map to XML structure
- Read documentation and unpack:
- Read
references/ooxml.md-- focus on "Document Library" and "Tracked Change Patterns" - Unpack:
python ooxml/scripts/unpack.py - Note the suggested RSID from unpack script
- Implement changes in batches. For each batch:
- Grep
word/document.xmlto verify current text and line numbers (they shift after each script) - Write a script using
get_nodeto find nodes, thenreplace_node,suggest_deletion, orinsert_after - Run the script and verify with
doc.save()
- Pack the document:
``bash python ooxml/scripts/pack.py unpacked reviewed-document.docx ``
- Final verification:
``bash pandoc --track-changes=all reviewed-document.docx -o verification.md grep "original phrase" verification.md # Should NOT match grep "replacement phrase" verification.md # Should match ``
Task: User says "Review this NDA and suggest changing the non-compete period from 2 years to 1 year, and update the jurisdiction from New York to Delaware"
Batch plan:
- Batch 1 (Term changes): "2 years" to "1 year" in Section 5
- Batch 2 (Jurisdiction): "New York" to "Delaware" in Section 8
Per batch: grep for text, write script, run, verify. After all batches, pack and do final verification.
Method Selection Guide
| Scenario | Method | |----------|--------| | Change part of regular text | replace_node() with `/ | | Delete entire run or paragraph | suggestdeletion() | | Reject another author's insertion | revertinsertion() (NOT suggestdeletion()) | | Restore another author's deletion | revertdeletion() | | Partially modify another author's change | replace_node() with nested /` |
Converting Documents to Images
Two-step process for visual analysis:
# Step 1: DOCX to PDF
soffice --headless --convert-to pdf document.docx
# Step 2: PDF pages to JPEG
pdftoppm -jpeg -r 150 document.pdf page
# Creates page-1.jpg, page-2.jpg, etc.
# For specific pages only:
pdftoppm -jpeg -r 150 -f 2 -l 5 document.pdf page
Use -r 150 for a good quality/size balance. Increase to 300 for print-quality output.
Code Style
Write concise code. Avoid verbose variable names, redundant operations, and unnecessary print statements.
Dependencies
Install if not available:
| Dependency | Install | Purpose | |------------|---------|---------| | pandoc | brew install pandoc or apt-get install pandoc | Text extraction | | docx | npm install -g docx | Creating new documents | | LibreOffice | brew install --cask libreoffice or apt-get install libreoffice | PDF conversion | | Poppler | brew install poppler or apt-get install poppler-utils | PDF to images | | defusedxml | pip install defusedxml | Secure XML parsing |
References
| File | Purpose | |------|---------| | references/docx-js.md | docx-js API patterns for creating new documents | | references/ooxml.md | OOXML XML patterns, Document library API, tracked changes |
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: costa-marcello
- Source: costa-marcello/skillkit
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet, be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.