Percerno Skillsbeta
← everything it can do · documents

DOCX Writer DOCX

Creates, fills, and converts Microsoft Word (.docx) documents from Markdown or existing templates using pandoc and python-docx, with optional PDF export via LibreOffice.

10 uses this weeksource Percernolicence MIT
Quality gate: PASS · makes it possible · measured 2026-10-23
Delivered a valid file in 3 of 3 requests; the bare model cannot produce this file type.
3/3 requests produced a file that opens
Security scan: clean · 2026-10-24 · 4 files · ran in sandbox
no network calls, shell tricks, credential access or instruction tampering found in its files.

Try asking

Say it in your own words; the assistant finds this recipe by itself. Examples:

“Lav et brev til Nordisk ApS om vores nye prisliste, og brug vores firmapapir som skabelon.”
“Udfyld kontrakt-skabelonen med kundenavn 'Mette Hansen' og beløb '48.000 kr.' og gem det som docx.”
“Omdan denne markdown-fil til en Word-rapport med overskrifter og tabeller.”
“Create a formal business letter in Danish to Mette Hansen regarding a service renewal, using the attached company letterhead template.”
“I have a contract template with {{client_name}} and {{date}} placeholders. Please fill them in with 'Acme Corp' and 'Oct 21, 2026' and save it as a new docx.”
“Convert this Markdown file into a professional Word report with a table of contents and proper heading styles.”
Try this skill from Claude, ChatGPT or a chat on your own page. Free plan, no credit card.Get started free

Good for

worddocxpandoctemplatepdflettercontractreportplaceholderdocument-generation

Not for

Do not use this skill for creating or editing PowerPoint presentations, Excel spreadsheets, or plain text files. It is not suitable for complex document layout design that requires manual graphical editing in Word, nor for reading non-Word formats like PDFs or images directly.

Details

When it is the right choice

Use this skill when the user needs to generate a new Word document from text or Markdown, fill in specific fields within an existing .docx template, or convert a Word document to PDF. It is also appropriate when the user provides a custom .docx template and wants the output to retain specific styles, headers, or footers.

The full recipe the assistant reads

docx-writer

Word documents from the sandbox: write Markdown, convert with pandoc, style with the customer's own template, fill placeholders, export PDF. Everything writes to /work/out/.

Decide the path

Situation Do
New document from content you are writing A. Markdown → docx (pandoc)
Customer gave a template or an example .docx whose look must be kept A with --reference-doc
Customer gave a form/letter with {{fields}} to fill B. Fill placeholders
You must read an existing .docx first C. Read
They want a PDF finish with D. PDF

A. Markdown → docx

Write the document as Markdown (headings #/##, bullet lists, numbered lists, tables in pipe syntax, bold/italic, > quotes). Then:

pandoc /work/draft.md -o /work/out/document.docx
# with the customer's styles (headers, footers, fonts, logo come from the template):
pandoc /work/draft.md -o /work/out/document.docx --reference-doc=/work/in/their-template.docx

Rules that keep pandoc output clean: - Start with a title block only if wanted: a first line % Title renders as the Title style. - Keep one blank line between paragraphs and before lists and tables. - Danish letters and quotes are fine; pandoc is UTF-8 throughout. - A Danish date at the start of a line (21. oktober 2026) is an ordered list to Markdown: write 21\. oktober 2026. - Page breaks: insert a raw block ```{=openxml} <w:p><w:r><w:br w:type="page"/></w:r></w:p> ```. - A reference doc must be a .docx; if the customer gave .dotx, convert first: soffice --headless --convert-to docx --outdir /work /work/in/template.dotx.

For a letter use scripts/letter.py: it writes the Markdown skeleton with date, recipient block, subject, greeting and sign-off in Danish or English, then runs pandoc:

python /skills/docx-writer/scripts/letter.py --to "Mette Hansen, Nordisk ApS" \
  --subject "Tilbud på rådgivning" --lang da --body /work/body.md \
  --sender "Elfar Thorarinsson, Percerno" --out /work/out/brev.docx [--template /work/in/letterhead.docx]

B. Fill placeholders in an existing .docx

The template contains {{name}}-style fields anywhere: body, tables, headers, footers. Provide values as JSON and run:

python /skills/docx-writer/scripts/fill_template.py /work/in/contract.docx /work/out/contract-filled.docx \
  --values '{"customer": "Nordisk ApS", "date": "21. oktober 2026", "amount": "48.000 kr."}'

Unfilled fields are reported on stderr so you can ask the user for them. Formatting around a field is preserved because the script edits runs, not paragraphs; a field split across runs by Word is joined first.

C. Read an existing .docx

markitdown /work/in/file.docx > /work/file.md          # Markdown, tables kept
pandoc /work/in/file.docx -t markdown -o /work/file.md  # alternative
python /skills/docx-writer/scripts/describe.py /work/in/file.docx   # styles, headers/footers, {{fields}}

D. PDF

soffice --headless --convert-to pdf --outdir /work/out /work/out/document.docx

Always list /work/out at the end so the links can be handed to the user.

Checks before you finish

  • Open the result once with python /skills/docx-writer/scripts/describe.py /work/out/document.docx to confirm headings, tables and fields.
  • Numbers, dates and names in the document come from the user's material, never invented.
  • If a template was provided and the output ignores its styles, you forgot --reference-doc.
Files in this skill (4)
  • SKILL.md
  • scripts/describe.py
  • scripts/fill_template.py
  • scripts/letter.py
Where it comes from

Written by Percerno, MIT licence.