home / skills / artwist-polyakov / polyakov-claude-skills / docx-contracts

This skill fills Word templates (contracts or forms) with structured data using docxtpl, generating ready-to-download outputs.

npx playbooks add skill artwist-polyakov/polyakov-claude-skills --skill docx-contracts

Review the files below or copy the command above to add this skill to your agents.

Files (3)
SKILL.md
1.3 KB
---
name: docx-contracts
description: Fill Word document templates (contracts, forms) with structured data using docxtpl. Use when user uploads a .docx template with {{variables}} and provides data to fill it, or requests contract/form generation from template.
---

# docx-contracts

Automated contract and form filling using docxtpl library.

## Workflow

Be shure, that you recieve docx file. Don't try to read it.

1. **Extract schema**: Run `scripts/extract_schema.py <template.docx>` to get variables list and JSON schema. Don't read file. Just launch script.
2. **Gather data**: Extract values from user message context, matching schema fields. Use Claude completion for extraction if needed
3. **Handle missing data**: If any required field is missing or uncertain, ask user directly. Do not guess
4. **Fill template**: Create JSON file with data, then run `scripts/fill_template.py <template.docx> <data.json> <output.docx>`
5. **Deliver**: Move result to `/mnt/user-data/outputs/` and provide download link. Please don't read output file.

## Key Points

- Template must use Jinja2 syntax: `{{VARIABLE_NAME}}`
- All required fields from schema must be filled
- Ask user for missing data - never invent values
- Install docxtpl if needed: `pip install docxtpl --break-system-packages`

Overview

This skill automates filling Word (.docx) templates (contracts, forms) with structured data using the docxtpl engine. It extracts the template variable schema, collects required field values, fills the template, and produces a completed .docx output. It enforces that all required fields are provided and never invents missing values.

How this skill works

First, extract the template variable list and JSON schema from the uploaded .docx template using the provided extraction tool. Next, gather data matching the schema from the user message or by asking clarifying questions for any missing or uncertain fields. Create a JSON data file and run the template-filling tool to generate the completed .docx, then place the result in the output folder and share a download link.

When to use it

  • User uploads a .docx template containing Jinja2-style variables like {{name}} and requests a filled contract or form
  • You need to generate multiple contracts or forms from the same template using structured data
  • You want a reproducible, data-driven process for creating legal or business documents
  • You must ensure all required fields are explicitly confirmed and no placeholder values remain

Best practices

  • Require the template to use Jinja2-style variables ({{variable_name}}) and validate the extracted schema before filling
  • Extract the schema first; do not attempt to parse .docx XML manually in conversation
  • Collect all required fields from the user and ask direct questions for any missing or ambiguous values
  • Keep submitted data in JSON matching the schema to ensure deterministic fills
  • Install and use docxtpl in the execution environment to avoid runtime errors

Example use cases

  • Fill employment contracts by supplying employee details, salary, and start date to the template
  • Generate customer-facing service agreements from a standard template and a JSON dataset
  • Produce regulatory or compliance forms where every required field must be completed and confirmed
  • Batch-generate leases or vendor agreements by iterating over a list of tenant or vendor records

FAQ

What template syntax is required?

Templates must use Jinja2-style variables like {{variable_name}} so the schema extractor can identify fields.

What if a required field is missing?

Ask the user for the missing value directly; do not guess or fabricate information. The template will not be filled until all required fields are provided.