Skill

Populate DOCX Contract Templates with Data

Fills Word contract/form templates with structured data via docxtpl, extracting the variable schema first.

Works with docx

91
Spark score
out of 100
Updated 2 months ago
Version guardian-v1.0.0
Models
claude

Add to Favorites

Why it matters

Automate the creation of legal documents by populating pre-defined DOCX contract templates with specific data from your context.

Outcomes

What it gets done

01

Extract relevant information from provided context.

02

Insert extracted data into specified fields within DOCX contract templates.

03

Generate completed contract documents ready for review or distribution.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/docx-contracts | bash

Overview

DOCX Contract Templates

Fills Word contract/form templates using docxtpl and Jinja2 {{variable}} placeholders, extracting the schema via script first and asking the user for any missing required data rather than guessing. Use when a user uploads a .docx template with {{variable}} placeholders and provides data to fill it, or requests contract/form generation from an existing template.

What it does

This skill automates filling Word document templates - contracts, forms - with structured data using the docxtpl library, which reads Jinja2-style {{VARIABLE_NAME}} placeholders embedded in a .docx file. Its workflow is explicitly script-driven rather than reading the document directly: run scripts/extract_schema.py against the uploaded template to get the list of variables and a JSON schema (the skill is instructed not to try reading the .docx file itself, since docxtpl's schema extraction handles that reliably); gather values for each schema field from the user's message context, using Claude's own extraction ability where needed; explicitly ask the user for any required field that's missing or uncertain rather than guessing or inventing a plausible-sounding value; write the gathered data to a JSON file and run scripts/fill_template.py with the template, the data file, and an output path to produce the filled document; and finally move the result to /mnt/user-data/outputs/ and provide a download link, again without reading the output file directly.

Its key constraints: the template must use Jinja2 {{VARIABLE_NAME}} syntax for docxtpl to recognize placeholders, every required field identified in the extracted schema must be filled before the document is considered complete, and missing data is always a reason to ask the user - never to fill in an invented value. The docxtpl library itself may need installing (pip install docxtpl --break-system-packages) if not already present.

When to use - and when NOT to

Use this skill when a user uploads a .docx template containing {{variable}} placeholders and provides, or can provide, the data to fill them, or explicitly requests contract or form generation from an existing template.

It is not a general document-editing or contract-drafting tool - it fills an existing template's defined variables rather than writing new contract language or restructuring a document's content, and it depends on the template already using the correct Jinja2 placeholder syntax; a template without {{}} placeholders isn't something this skill's extraction step can work with.

Inputs and outputs

Input is a .docx template with {{VARIABLE_NAME}} placeholders plus the data to fill each required field, extracted from context or supplied directly by the user when missing. Output is a completed .docx document with all template variables populated, delivered as a download link from /mnt/user-data/outputs/.

python scripts/extract_schema.py template.docx

Integrations

Built on the docxtpl Python library for Jinja2-based Word template filling, using companion scripts extract_schema.py (schema extraction) and fill_template.py (template population).

Who it's for

Users generating contracts or forms from a pre-built Word template who need structured data filled in reliably, with missing fields flagged for user input rather than silently guessed.

Source README

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

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.