Communitygithub.com

94youshin/word-formatting-skill

A Word document formatting skill that follows the Agent Skills open specification, based on GB/T 8567-2006 (Software Documentation Specification) and GB/T 9704-2012 (Party and Government Official Document Format).

What is word-formatting-skill?

This skill automates the formatting of Microsoft Word documents according to two distinct Chinese national standards: GB/T 8567-2006 for software documentation and GB/T 9704-2012 for official party and government documents. It provides a structured workflow using a Python-based CLI tool (`docx_tools.py`) to inspect, format, verify, and render DOCX files. The skill supports multiple document subtypes (e.g., IDD, interface change notices, ordinary official documents, letters, orders, minutes) and respects explicit user instructions, organization templates, and national standard requirements. It enforces critical invariants such as never overwriting the source file, preserving all original content unless explicitly authorized, and reporting unsupported constructs rather than silently normalizing them. The skill is designed for use with AI coding agents like Claude Code and Cursor, providing clear, scriptable commands and reference documentation to ensure compliant and safe document formatting.

Works with~Claude Code~Codex CLI~Cursor
npx skills add 94youshin/word-formatting-skill

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

Word Formatting

Handle two modes and keep their rules separate:

Always read references/common-workflow.md. Read references/style-pack-schema.md only when changing style packs or the formatter.

Workflow

  1. Preserve the source DOCX and work on a new output path.

  2. Resolve mode, document subtype, user instructions, and any organization template. Apply priorities in this order: explicit user instruction, approved organization template, applicable national-standard requirement, project default.

  3. Inspect before modifying:

    python scripts/docx_tools.py inspect INPUT.docx --mode MODE --report inspection.json

    For an interface supplement:

    python scripts/docx_tools.py inspect INPUT.docx --mode software-document --document-type IDD --profile interface-change-note --report inspection.json

  4. Review reported risks. Do not infer or rewrite headings, identifiers, dates, addressees, signatures, seals, confidentiality markings, or document content without evidence or user direction.

  5. Apply the selected pack:

    python scripts/docx_tools.py format INPUT.docx OUTPUT.docx --mode MODE --report formatting.json

    Add --infer-headings only when numbered heading candidates have been reviewed.

  6. To create an ordinary official document from reviewed Markdown or TXT instead of reformatting an existing DOCX:

    python scripts/docx_tools.py compose-official INPUT.md OUTPUT.docx --title "标题" --recipient "主送机关" --issuer "发文机关" --issue-date "成文日期"

    Add --note once per reviewed annotation. DOCX input is deliberately blocked unless --extract-text-from-docx is supplied, because extraction discards tables, images, fields, and source styles. This composition command does not create red headers, document numbers, seals, page numbers, or edition records.

  7. Verify the output:

    python scripts/docx_tools.py verify OUTPUT.docx --mode MODE --report verification.json

  8. Render the output to PDF and page images with the available Word/document workflow. Inspect every page for overflow, bad pagination, table breaks, blank pages, clipped content, heading placement, and visual balance. Iterate until no critical issue remains or report the unresolved blocker.

Invariants

  • Never overwrite the source file.
  • Preserve text, images, fields, links, comments, tracked changes, section breaks, and numbering unless the user explicitly authorizes changes. The formatter changes styles and page geometry; unsupported constructs must be reported, not silently normalized.
  • A passing automated report means only that implemented checks passed. It is not legal, archival, printing, or standards certification.
  • For GB/T 8567-2006, do not invent missing technical content. Report missing or uncertain sections against the selected document type.
  • For interface supplements, distinguish baseline-document control, change completeness, protocol completeness, and layout risks. Do not silently promote numbered procedures or list items to headings.
  • For GB/T 9704-2012, do not fabricate a red header, document number, signer, seal, issuing authority, copy recipients, or issue date.
  • Center standalone image paragraphs and tables by default and clear inherited body indentation from image paragraphs. Preserve mixed text-and-image paragraphs for manual review rather than moving content automatically.
  • If required fonts are unavailable, use no silent substitution: keep the requested font name in the DOCX and report that visual verification on the target machine is required.

Related Skills