office
MAIN method for Office and PDF — every read, create, edit, review, convert, version of .docx/.doc/.dotx/.xlsx/.xls/.xlsm/.pptx/.ppt/.pdf (and images) MUST go through officecli. Use whenever a task touches .docx/.doc/.xlsx/.xls/.pptx/.ppt/.pdf/image files or asks for document drafts, suggestions, track changes, history, batch generation, or format export. The native read/edit/write tools are blocked for these extensions.
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 5
- Forks
- 0
01 前言 Front Matter
- name
- office
- description
- MAIN method for Office and PDF — every read, create, edit, review, convert, version of .docx/.doc/.dotx/.xlsx/.xls/.xlsm/.pptx/.ppt/.pdf (and images) MUST go through officecli. Use whenever a task touches .docx/.doc/.xlsx/.xls/.pptx/.ppt/.pdf/image files or asks for document drafts, suggestions, track changes, history, batch generation, or format export. The native read/edit/write tools are blocked for these extensions.
02 资源文件 2
- 参考文档references/authoring.md3.7 KB
- 参考文档references/reviewing.md5.2 KB
03 SKILL.md 正文
Office documents
MAIN for Office/PDF — every read and handle (create/edit/accept/undo/history/revert/comment/track-change) of
.docx/.doc/.dotx/.dotm/.xlsx/.xls/.xlsm/.xlsb/.xltx/.pptx/.ppt/.potx/.pdf(and images.png/.jpg/.jpeg/.gif/.bmp/.tiff/.webp) MUST go throughofficecli. The plugin's guard blocks the nativeread/edit/writetools for these extensions and errors withuse officecli tool for office/PDF files — office is the main method for read + handle. Do not bypass.
The plugin overrides the builtin edit tool: every edit — text or binary — runs through a draft and needs officecli accept to reach the real file. Two edit surfaces:
officecli(action="edit", filePath, content)— replaces the whole draft with your markdown (for office/PDF, this is the ONLY write surface)edittool (filePath,oldString,newString) — patches the existing draft in place (text files only; blocked for office/PDF/images)
For office/PDF/images, officecli is the ONLY path: read returns markdown, create/edit consume markdown, both sides inside officecli. Never use read/edit/write on *.docx,*.doc,*.dotx,*.xlsx,*.xls,*.xlsm,*.pptx,*.ppt,*.pdf,*.png,*.jpg,*.jpeg,*.gif — guard fails them. For live Word content on the same machine use officecli(action="read", live=true) (prefers Application.Word document whose full name matches filePath, falls back to saved file; local-only).
Draft lifecycle (every task)
Every write runs through a draft: nothing reaches the real file until accept. The lock is claimed lazily on the first mutating action and released on accept/undo.
create filePath + contentfor a new file, oredit filePath + contentto open an existing file's draft- Re-
edit,comment,approve,metadata,watermarkfreely while iterating — all mutate the same draft acceptflushes the draft to disk, records a version snapshot, releases the lock
Done means: every write path ended in accept or undo. A dropped draft leaves the file locked and the change invisible.
Universal actions (all via officecli — main for office/PDF):
read—officecli(action="read")extract any office/PDF/image to markdown; inspect before editing anything you did not author this session (nativereadis blocked for.docx/.doc/.xlsx/.xls/.pptx/.ppt/.pdf)diff— unified markdown diff of draft vs real file; call before accept on edits to files you didn't createpreview— renders the draft to an HTML file for human inspectionundo— discard draft, real file unchangedlist— active drafts across all files; run when resuming after an interruption- Stale lock (
staleLockHours, default 24h):lock-status, thenforce-release— the displaced session's next mutation fails with an error, expected
Bundled format skills (anthropics/skills, source-available)
skills/docx, skills/xlsx, skills/pptx, skills/pdf are bundled verbatim from anthropics/skills (see LICENSE.txt in each). They hold the canonical gotchas and helper scripts per format. skills/office is the router + draft/history; delegate format-specific authoring to the bundled skill when fidelity matters. Quick markdown→officecli covers 80%; the bundled skill covers the 20% that silently corrupts.
| Need | Where |
|---|---|
| Simple headings + pipe tables (markdown enough) | officecli create/edit → v2 styled defaults (A4, D9E1F2, DXA) |
| Precise .docx: sections, images, TOC, page size, redlines, comments | skills/docx — docx npm + scripts/merge_runs.py/comment.py/accept_changes.py/office/validate.py + soffice |
| XLSX with formulas, styling, recalc | skills/xlsx — openpyxl + scripts/recalc.py (mandatory) + pandas for bulk |
| Styled .pptx / template fill | skills/pptx — pptxgenjs + scripts/add_slide.py/thumbnail.py/clean.py |
| PDF forms, table extraction, merge/split | skills/pdf — forms.md/reference.md + pypdf/pdfplumber/reportlab helpers |
Advanced edit on existing file: officecli read to inspect → officecli edit to open draft → run the format skill's script against the draft file (see officecli list / .opencode/office/drafts/ in src/core/draft/manager.ts:18), iterate → officecli accept. Never touch the real file bypassing the lock. For quick markdown writes, officecli edit alone is enough.
Task router
| Task type | Reference |
|---|---|
| New document, template batch generation, validation gates, format conversion | authoring.md + format skill (docx/xlsx/pptx/pdf) |
| Editing/reviewing existing documents, suggestions, track changes, version recovery | reviewing.md + docx:editing / pptx:editing sections |
| Fillable PDF forms | pdf/forms.md + scripts/check_fillable_fields.py |
| XLSX recalc / financial model | xlsx SKILL recalc.py section |
04 同仓库更多 Skills
writing-for-agents
Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.
skill-creator
Create a Task Skill for a daily document task. Use when user wants to automate a repetitive task, says create skill, daily task, Task Skill, or needs to turn a dossier/folder workflow into a reusable skill.
grilling
Grill the user relentlessly about a plan, decision, or idea. Use when the user wants to stress-test their thinking, or uses any 'grill' trigger phrases.
grill-me
A relentless interview to sharpen a plan or design.
writing-for-agents
Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.
skill-creator
Create a Task Skill for a daily document task. Use when user wants to automate a repetitive task, says create skill, daily task, Task Skill, or needs to turn a dossier/folder workflow into a reusable skill.