docx
它能做什么
这项技能帮助 AI 编写和修改 Microsoft Word 文件。适合需要以精美 Word 格式呈现报告、信函、合同或提案的人。
适用场景
- ✓当你要求制作 Word 文档,例如报告、提案、信函或合同时。
- ✓当你想编辑或标注现有的 .docx 文件时。
- ✓当你需要更高级的 Word 功能,例如目录、脚注或批注的时候。
技能链接
https://github.com/spinabot/brigade/blob/main/skills/docx/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请用 Word 起草一份两页的项目提案,包括目录、带样式的预算表格和页眉。”
每周 5 个新技能,1 分钟读完。
工作原理
对于快速草稿,AI 会使用简单的生成器。如需更多细节,它会编写一个使用 docx 库的脚本,然后打开文件进行检查。对于已有品牌样式的文件,可以在不改变其样式的前提下填写内容。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
docx — professional Word documents
Pick the lightest path that meets the need. Never declare a document done without opening/validating the result at least once (see Verify).
| Need | Path |
|---|---|
| Simple structured doc (headings, paragraphs, bullets, a basic table, an image) | Path 1 — make_document tool |
| Anything richer (custom styles, numbered/multi-level lists, merged/shaded table cells, headers/footers, TOC, hyperlinks, footnotes, inline bold/italic/color, tracked changes, comments) | Path 2 — script the docx library via brigade exec-node |
Fill / redline an EXISTING branded .docx without disturbing its styling |
Path 3 — OOXML round-trip |
| Markdown → branded Word inheriting a corporate template | Path 4 — pandoc (optional) |
Path 1 — quick structured doc (make_document tool)
make_document(format="docx", content={ title, sections:[{heading, level, paragraphs, bullets, table:{rows}, image:{path}}] })
Good for a fast first draft. It is deliberately limited (single-level bullets, string-only tables, no inline formatting). The moment you need more, go to Path 2 — don't fight the schema.
Path 2 — full power: script the docx library
Brigade bundles the docx library (dolanmiu/docx). Write a CommonJS script and run it with brigade exec-node, which makes Brigade's bundled libraries require()-able from anywhere (no install):
writea filegen.cjs.- Run:
brigade exec-node gen.cjs
// gen.cjs — illustrative; adapt to the content
const fs = require("node:fs");
const {
Document, Packer, Paragraph, TextRun, HeadingLevel, AlignmentType,
Table, TableRow, TableCell, WidthType, BorderStyle, ShadingType,
LevelFormat, Header, Footer, PageNumber, TableOfContents, ExternalHyperlink,
} = require("docx");
const doc = new Document({
styles: { default: { document: { run: { font: "Calibri", size: 22 } } }, // size is half-points (22 = 11pt)
paragraphStyles: [{ id: "Body", name: "Body", run: { size: 22 }, paragraph: { spacing: { after: 160 } } }] },
numbering: { config: [{ reference: "nums", levels: [{ level: 0, format: LevelFormat.DECIMAL, text: "%1.", alignment: AlignmentType.START }] }] },
sections: [{
properties: { page: { size: { width: 12240, height: 15840 } } }, // US Letter, in DXA (1440 = 1 inch)
headers: { default: new Header({ children: [new Paragraph("Acme Corp — Confidential")] }) },
footers: { default: new Footer({ children: [new Paragraph({ children: [new TextRun("Page "), new TextRun({ children: [PageNumber.CURRENT] })] })] }) },
children: [
new Paragraph({ text: "Q3 Business Review", heading: HeadingLevel.TITLE }),
new TableOfContents("Contents", { hyperlink: true, headingStyleRange: "1-3" }),
new Paragraph({ text: "Summary", heading: HeadingLevel.HEADING_1 }),
new Paragraph({ children: [ new TextRun("Revenue was "), new TextRun({ text: "$1.2M", bold: true }), new TextRun(" — up 18%.") ] }),
new Paragraph({ text: "First item", numbering: { reference: "nums", level: 0 } }),
new Paragraph({ children: [ new ExternalHyperlink({ children: [new TextRun({ text: "Full data", style: "Hyperlink" })], link: "https://example.com" }) ] }),
new Table({
columnWidths: [4680, 4680], // DXA, sum = content width
rows: [
new TableRow({ tableHeader: true, children: ["Metric","Value"].map((t) =>
new TableCell({ width: { size: 4680, type: WidthType.DXA }, shading: { type: ShadingType.CLEAR, fill: "D9E2F3" },
children: [new Paragraph({ children: [new TextRun({ text: t, bold: true })] })] })) }),
new TableRow({ children: ["Revenue","$1.2M"].map((t) =>
new TableCell({ width: { size: 4680, type: WidthType.DXA }, children: [new Paragraph(t)] })) }),
],
}),
],
}],
});
Packer.toBuffer(doc).then((buf) => { fs.writeFileSync(process.argv[2] || "out.docx", buf); console.log("wrote", process.argv[2] || "out.docx"); });
The docx library also supports: footnotes (FootnoteReferenceRun + footnotes), comments, tracked changes (InsertedTextRun/DeletedTextRun with author/date), multi-section layouts, page breaks, columns, internal bookmarks, and images inside table cells. Read its API as needed — anything Word can express, this can author.
Path 3 — fill / redline an EXISTING .docx (highest fidelity)
To f
常见问题
它可以编辑已有的 Word 文件吗?
可以。它可以在保留品牌样式的前提下,填写或标注已有的文件。
制作完成后它会检查文件吗?
会。在认为工作完成之前,该技能会打开并验证文档。
它支持修订记录吗?
支持。该技能可以在 Word 文档中添加修订记录和批注。
详情
作者的原始描述
Create and edit Microsoft Word (.docx) documents to a professional standard — reports, proposals, contracts, letters, memos — with custom styles, multi-level lists, styled/merged tables, headers/footers, table of contents, hyperlinks, footnotes, tracked changes and comments. Use when the user asks Brigade to make, write, draft, fill, redline, or edit a Word document or .docx file.
repo: spinabot/brigade
热度
- GitHub 星标
- 11k
- 排名
- #11717
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …