Use coding agents for paperwork too.
Safe Docx is an open-source TypeScript stack for surgical editing of existing Microsoft Word .docx files. It is built for workflows where an agent proposes changes and a human still needs reliable, formatting-preserving document edits.
If you review contracts with AI, the slowest step is often applying accepted recommendations in Word. Safe Docx turns that into deterministic tool calls.
AI coding CLIs are great with code and text files but weak on brownfield .docx editing. Business and legal workflows still run on Word documents, so we built a native TypeScript path for:
- reading and searching existing documents in token-efficient formats
- making surgical edits without destroying formatting
- producing clean/tracked outputs and revision extraction artifacts
For setup and daily usage, go to:
packages/docx-mcp/README.md
Quick run:
npx -y @usejunior/safe-docx- Brownfield editing of existing
.docxfiles - Formatting-preserving text replacement and paragraph insertion
- Comment and footnote workflows
- Tracked-changes outputs for review (
download,compare_documents) - Revision extraction as structured JSON (
extract_revisions)
Safe Docx is not a from-scratch document generation toolkit.
If your primary need is generating new .docx files from templates/programmatic layout, use packages such as docx.
- Common Paper style mutual NDA fixtures
- Bonterms mutual NDA fixture
- Letter of Intent fixture
- ILPA limited partnership agreement redline fixtures
- NVCA financing forms
- YC SAFEs
- Offering memoranda
- Order forms and services agreements
- Limited partnership agreements
@usejunior/docx-core: primitives + comparison engine for existing.docxdocuments@usejunior/docx-mcp: MCP server implementation and tool surface@usejunior/safe-docx: canonical end-user install name (npx -y @usejunior/safe-docx)@usejunior/safedocx-mcpb: private MCP bundle wrapper
- Tool schemas are generated from
packages/docx-mcp/src/tool_catalog.ts. - OpenSpec traceability matrix:
packages/docx-mcp/src/testing/SAFE_DOCX_OPENSPEC_TRACEABILITY.md - Assumption matrix:
packages/docx-mcp/assumptions.md - Conformance guide:
docs/safe-docx/sprint-3-conformance.md
A TypeScript-first DOCX editing stack for coding-agent workflows that need deterministic, formatting-preserving edits on existing Word documents.
That is a core design goal. The tool surface is built around surgical operations (replace_text, insert_paragraph, layout controls) that preserve document structure and formatting semantics as much as possible.
No. Supported runtime usage is JavaScript/TypeScript with jszip + @xmldom/xmldom.
Not the primary focus. For from-scratch generation, use packages such as docx.
Mutual NDAs (including Common Paper/Bonterms-style fixtures), Letter of Intent, and ILPA limited partnership agreement redline fixtures.
No. The same brownfield .docx editing problems appear in HR, procurement, finance, sales ops, and other paperwork-heavy workflows.
Use @usejunior/safe-docx via npx, then follow setup examples in packages/docx-mcp/README.md.
See the generated reference at packages/docx-mcp/docs/tool-reference.generated.md.
npm ci
npm run build
npm run lint --workspaces --if-present
npm run test:run
npm run check:spec-coverage
npm run test:coverage:packages
npm run coverage:packages:check
npm run coverage:matrix- In npm package settings, add a trusted publisher.
- Provider: GitHub Actions.
- Owner:
UseJunior - Repository:
safe-docx - Workflow file:
.github/workflows/release.yml - Environment: leave empty (unless you later add an Actions environment constraint).
Packages to configure:
@usejunior/docx-core@usejunior/docx-mcp@usejunior/safe-docx