---
name: edit-docx-agreement
description: >-
  Make bespoke edits to a DOCX agreement generated by OpenAgreements (or any
  existing DOCX), using Safe Docx MCP tools for surgical, formatting-preserving
  edits and tracked-changes outputs. Use when user says "edit this contract,"
  "change a clause," "modify the agreement," "custom edits to the docx," or
  "bespoke changes to the document."
license: MIT
compatibility: >-
  Works with any agent. Requires a separately configured Safe Docx MCP server for document editing.
  OpenAgreements fill capabilities require the OpenAgreements remote MCP or local CLI.
metadata:
  author: open-agreements
  version: "0.2.0"
catalog_group: Editing And Client Workflows
catalog_order: 10
---

# edit-docx-agreement

Use this skill when a user asks for **custom edits that are not exposed as template fields** in an OpenAgreements-generated (or any existing) DOCX agreement.

> **Interactivity note**: Always ask the user for missing inputs (file path, change intent, output preferences).

## Security model

This skill bridges two separate systems:
- **OpenAgreements** (remote MCP or local CLI) — for template filling. Follows the OpenAgreements zero-download security model.
- **Safe Docx** (local MCP server) — for surgical DOCX editing. Requires separate setup. This is **not** part of the OpenAgreements skill set and has its own trust/security model.

The agent must have Safe Docx MCP tools available to perform edits. If Safe Docx tools are not detected, inform the user and provide setup guidance (see Connectors).

## Decision rule: refill vs edit vs both

1. **Field-only changes** (e.g., party name, date, amount, valuation cap):
   Re-run OpenAgreements `fill_template` with the updated field values. No Safe Docx needed.

2. **Boilerplate-only changes** (e.g., custom clause, modified standard language):
   Use Safe Docx MCP tools to surgically edit the existing DOCX.

3. **Mixed changes** (field updates + bespoke edits):
   Re-fill via OpenAgreements first (to get a clean base with updated fields), save the output locally, then use Safe Docx to apply bespoke edits on the fresh file.

## Execution

### Step 0: Confirm you have a local .docx file path

- If OpenAgreements was run via remote MCP, the fill response returns a download URL (with `expires_at`). Save the DOCX to a local path immediately.
- If the download link has expired, re-run `fill_template` to get a fresh URL.
- If OpenAgreements was run via local CLI, use the output file path directly.

### Step 1: Verify Safe Docx MCP is available

Check whether Safe Docx tools (e.g., `read_file`, `replace_text`, `apply_plan`) are available in the current session.

- **If available**: proceed to Step 2.
- **If not available**: inform the user that Safe Docx MCP is required for bespoke edits and provide setup instructions from [CONNECTORS.md](./CONNECTORS.md). Stop here until the user configures it.

### Step 2: Apply the decision rule

Follow the routing logic above (field-only / boilerplate-only / mixed).

For Safe Docx edits:
- Use `read_file` to locate target paragraphs
- Use `replace_text` or `insert_paragraph` for surgical changes
- Use `apply_plan` for batch edits (fails safely if any step is invalid)
- Re-read edited paragraphs to verify changes

### Step 3: Deliver reviewable outputs

Use Safe Docx `download` to save:
- A **tracked-changes** DOCX for legal review
- A **clean** DOCX for signing (optional but recommended)

Summarize edits for the user (paragraph IDs, before/after text).

## Licensing note

Some templates (notably YC SAFEs) are licensed under CC-BY-ND-4.0. You can fill them for your own use but must not redistribute modified versions of the template itself. The filled output may constitute an "adapted work" — do not redistribute your filled output publicly without reviewing the license terms. See `docs/licensing.md` for details.

This tool does not provide legal advice — consult an attorney.

## Connectors

For MCP server setup (OpenAgreements remote MCP + Safe Docx local MCP), see [CONNECTORS.md](./CONNECTORS.md).
