AGENT SKILL

docx-from-template

Write a Word document (.docx) in a template's house style — or update an existing one section by section, as tracked changes, or bring an old one onto a template (restyle) — with docx_styles, docx_create, docx_update, docx_restyle and docx_render, then check it by rendering it with Word (Windows), LibreOffice or ONLYOFFICE and fixing what the render shows. Use whenever the user asks for a report, memo, specification or letter in their Word template, to turn notes or Markdown into a Word document, or to revise sections of an existing .docx, to fix a document's inconsistent fonts or move it onto a new template — and whenever a .dotx file is involved.

License 许可
MIT
最近更新
2026-11-15
Stars
★ 29
Forks
3

01 前言 Front Matter

name
docx-from-template
license
MIT
metadata
{ "version": "1.0" }
description
Write a Word document (.docx) in a template's house style — or update an existing one section by section, as tracked changes, or bring an old one onto a template (restyle) — with docx_styles, docx_create, docx_update, docx_restyle and docx_render, then check it by rendering it with Word (Windows), LibreOffice or ONLYOFFICE and fixing what the render shows. Use whenever the user asks for a report, memo, specification or letter in their Word template, to turn notes or Markdown into a Word document, or to revise sections of an existing .docx, to fix a document's inconsistent fonts or move it onto a new template — and whenever a .dotx file is involved.

03 SKILL.md 正文

Word documents from a template

A Word template carries what "our document" means: heading styles and their numbering, body and list styles, the cover page, headers and footers, margins, fonts and colours. You write the content in Markdown; docx_create puts it into the template's styles, so every heading, list and table takes the house style without you setting a font. docx_update does the same inside an existing document, and leaves everything you did not touch exactly as it was.

Task Tool
See what a template offers: styles, numbering, cover page, table of contents docx_styles
Read an existing document, and its headings docx_extract
Write a new document from Markdown in a template docx_create
Change sections of an existing document docx_update
Bring an existing document into a template's styles, fixing hand-set fonts docx_restyle
See the pages as the reader will, with the chapters and any lost text docx_render
Hand over a PDF as well docx_render with pdf_path

Writing a new document

  1. Read the template. Call docx_styles on it. It says which of its styles your headings, paragraphs and lists will wear, whether the template numbers its headings (then do not type numbers into your headings: "Scope", not "2. Scope" — Word adds its own, and a number you type is removed and reported in the answer), and whether it has a cover page and a table of contents.
  2. Write the content as Markdown. # is a chapter, ## a section, ### a subsection — the heading levels become the document's outline. Use real lists, tables and **bold**; LaTeX ($…$, $$…$$) becomes native Word equations. Reference pictures by workspace path (![Architecture](figures/architecture.svg)); prefer SVG for diagrams. Mermaid is written as code, not drawn — a page showing source where a diagram belongs. To get the .svg, write what the diagram describes as a structured-exchange document and turn it into the picture with write_structure_figure; the structured-exchange skill holds the document shape, and is worth reading before the first one, since the schema is checked and a near miss is refused.
  3. Create with docx_create: template_path, output_path (a .docx), and markdown (or markdown_path for a file, whose pictures then resolve against its folder). Pass keep: ["cover", "toc"] when the template has them and the document should — Word fills the table of contents when the file is opened. The template's sample text is never carried over.
  4. Render and look with docx_render — see Checking the render.
  5. Fix and write again with the same output_path and overwrite: true.

Updating an existing document

  1. Read it first with docx_extract to see its headings as they are written. Sections are named by heading path: "Scope", or "Scope > Out of scope" when a heading name repeats.
  2. Say what changes, as a list of edits:
    • replace — new content under an existing heading; the heading stays.
    • insert_after — a new section after a whole section (subsections included). Start its Markdown with its own heading at the right level (## New section).
    • append — at the end of the document.
    • delete — a section and its subsections. All edits apply to the document as it is now; two edits touching the same section are refused — combine them into one.
  3. Tracked changes are the default. The owner of the document reviews and accepts them in Word, as they would a colleague's. Only pass track_changes: false when the user asks for the edits to be written directly. A section holding changes nobody has accepted yet is refused: say so, and let the user resolve them in Word first.
  4. Write to a new file (output_path) unless the user asked to change the original — then overwrite: true without output_path.
  5. Render the result and look at the changed pages: the tracked changes are drawn as markup.

Everything outside the edited sections — other chapters, headers, footers, comments, pictures — is left byte for byte as it was. The answer says how many content controls, fields and comment anchors went with a deleted or replaced section: report them to the user.

Bringing a document into the template

When a document's fonts and sizes are inconsistent, or it has to move onto a new template:

  1. Call docx_restyle with the document (path), the template (template_path) and an output_path. The template's styles, theme and heading numbering replace the document's — matched by name, so an English Word's Heading 1 becomes the template's heading 1 — and fonts, sizes and colours set by hand are removed so the text takes its style's. Emphasis, spacing, lists, tables and pictures are kept, and the text is checked unchanged before writing.
  2. Add include: ["page"] for the template's page size and margins, ["headers"] for its headers and footers, only when the user wants them: a document's own title-page footer is often deliberate.
  3. The removals are tracked formatting changes; the replaced style definitions are not. Tell the user so, and that the original file is the way back.
  4. Report the styles the answer lists as missing from the template: they were kept as they were, and the user decides what they should become.
  5. Render the result with docx_render and look at it next to the original.

Checking the render

docx_render returns the page count, the chapters as the PDF's bookmarks, a text check, and pictures of the pages.

  • Chapters: the bookmarks are your headings as Word sees them. A heading missing from the list is a paragraph that only looks like a heading; a wrong level shows as wrong nesting. With a template that numbers headings, the numbers are in the bookmarks — check they run 1, 2, 3.
  • Text check: any paragraph listed is on no page — hidden by a style, lost in a field. Fix it.
  • Look at the pages for: leftover sample text from the template; tables wider than the page; pictures too large or out of place; a heading alone at the bottom of a page; tracked changes where you did not expect them.

Word on Windows is the reference rendering. LibreOffice and ONLYOFFICE substitute fonts they do not have, so line and page breaks can differ; do not chase a page break they show. If no office application is available, say so: without a render, the document was not checked.

What it does not do

Footnotes, comments, text boxes and section changes (landscape pages, columns) are not written; a mermaid diagram is written as its source. Headers, footers and the cover page come from the template, not from the Markdown. If the user needs one of these, write the rest and say what is missing rather than faking it.

04 同仓库更多 Skills

laurentftech
laurentftech/pi-outpost

structured-exchange

Author a structured-exchange document — a graph, sequence, table or planning timeline the interface renders natively, such as a table of requirements with their attributes, a programme schedule with milestones and dependencies, or a proposal to change one an external authority holds — and write figures of one into a document you are authoring. Read it before calling present_structure or write_structure_figure. Use when asked to draw or diagram a structure, to present requirements or other typed items, to plan or show a schedule, roadmap or Gantt chart, to propose an evolution of an existing model, to illustrate a report you are writing, when a project's profile refuses a kind, attribute or value, or when a result would otherwise be a hand-written diagram.

★ 29
laurentftech
laurentftech/pi-outpost

structured-exchange-project

Set up the model and the review rules a project holds its structured-exchange documents to — the registry (.pi-outpost/structured-exchange.json), its profiles (kinds, attributes, enumerations, which kinds a relationship joins) and its rules files. Read it before writing or changing any of those files, and when the project's structured-exchange registry cannot be used. Use when asked to build a profile from a requirements tool's export or a data model, to turn review rules from a standard or a plan into rules files, or to show a project's rules for review with present_project_model.

★ 29
laurentftech
laurentftech/pi-outpost

pptx-from-template

Build a PowerPoint presentation (.pptx) from a template (.potx or .pptx) — or from no template at all, on the built-in Office theme — titles, bullets, pictures, native tables and editable charts, or update an existing deck slide by slide, with pptx_layouts, pptx_create, pptx_update and pptx_render, then check it is readable by rendering it with PowerPoint (Windows), LibreOffice or ONLYOFFICE and fixing what the render shows. Use whenever the user asks for a deck, slides or a presentation — from their template, a corporate/brand deck, on the default or standard PowerPoint theme, or with no theme named at all — and to turn a document, notes or an outline into slides, and whenever a .potx file is involved.

★ 29
laurentftech
laurentftech/pi-outpost

posters

Make a poster, a worksheet, a slide or any one-page visual (a class poster, a vocabulary sheet, a timetable, an announcement) as a .poster.html file the user opens in the file viewer, retouches there — corrects a text, moves a pictogram, changes a colour — and exports to Word to print or PowerPoint to show. Use whenever the user asks for a poster, an affiche, a printable sheet, a visual, or a slide made to look designed, or to change an existing .poster.html file.

★ 29
laurentftech
laurentftech/pi-outpost

drawio

Write a draw.io diagram (.drawio) — flowchart, architecture, sequence of steps, org chart, network or data-flow map — as XML the user can open and edit in draw.io, then check it with drawio_check and show it in the reply. Use whenever the user asks for a draw.io or diagrams.net diagram, an editable diagram file, or to change an existing .drawio file. The conversation and the file viewer draw it; the user touches it up there, or edits it in draw.io desktop.

★ 29
laurentftech
laurentftech/pi-outpost

test-skill

A skill for testing isolation.

★ 29