When to Use
User needs Microsoft Word controlled as a live application, not treated as a .docx file format.
Agent handles app attach, active document state, selection-aware edits, comments, track changes, export, and clean shutdown through the official osascript CLI.
If the main artifact is offline DOCX creation or structural file editing, use word-docx instead.
Architecture
Memory lives in ~/word/. If ~/word/ does not exist, run setup.md. See memory-template.md for structure.
CODEBLOCK0
Quick Reference
Load only the smallest file that matches the current Word task and risk level.
| Topic | File |
|---|
| Setup guide | INLINECODE7 |
| Memory template |
memory-template.md |
| Interface selection |
execution-matrix.md |
| Live control patterns |
live-control-patterns.md |
| Destructive action guardrails |
safety-checklist.md |
| Debug and recovery |
troubleshooting.md |
Requirements
- - Microsoft Word installed locally.
- macOS with
osascript available. - Explicit confirmation before destructive document actions.
Core Rules
1. Choose the app-control path by document state
- - Use
osascript for live Word document control through the app's scripting dictionary. - Keep automation inside the live Word session instead of falling back to file-only DOCX tooling.
- Do not switch to offline document libraries when the requested job depends on the current live Word app state.
2. Identify the exact document and view before acting
- - Confirm whether the target is the active document, a named open document, or a path to open now.
- Read the current view, selection, and review mode before making edits tied to cursor position or markup state.
- Never assume the frontmost Word window is the intended document.
3. Read before write, then verify the final state
- - Pre-read document name, current selection, target paragraph, comment count, or export target before mutation.
- After edits, comments, accept/reject actions, or exports, re-read the affected state and report what changed.
- If Word does not reach the requested state, stop and diagnose instead of layering more edits.
4. Treat selection-driven actions as high-risk
- - Selection-based commands can land in the wrong paragraph, story range, header, or comment balloon.
- When possible, anchor the action to a specific document object instead of only the current insertion point.
- If the selection context is ambiguous, clarify first.
5. Separate reversible review actions from destructive cleanup
- - Adding comments, changing view, and exporting are usually reversible.
- Accept all changes, reject all changes, remove comments, close without save, and overwrite exports require explicit confirmation.
- If review state matters, preserve track changes and display settings unless the user explicitly asks to change them.
6. Keep provenance explicit
- - State whether the target was already open or opened just for this task.
- Report what document was changed, which review mode was active, and where exports were written.
- Preserve user-owned open documents that were outside the task scope.
7. Recover cleanly and avoid orphaned app sessions
- - If you opened Word just for this task, keep ownership clear and close only what you created.
- If you attached to an existing session, do not close unrelated documents or quit Word without explicit approval.
- On failure, record the exact blocker: protected document, modal dialog, compatibility mode, track changes mismatch, or missing permissions.
Word Traps
- - Treating a live document like a static
.docx file -> review state, comments, fields, and view context drift apart. - Writing relative to the current cursor without verifying selection -> text lands in the wrong story range.
- Accepting or rejecting changes globally when only one section was intended -> irreversible editorial loss.
- Exporting before fields, references, or TOC are updated -> stale output delivered as final.
- Closing an attached user session after automation -> unrelated writing work is interrupted.
- Ignoring protected view or tracked-change mode -> edits silently fail or create the wrong markup history.
Security & Privacy
Data that stays local:
- - Document paths, environment notes, and reusable fixes in
~/word/. - Document contents accessed through local Word automation.
Data that may leave your machine:
- - Nothing by default from this skill itself.
- A document's own links, add-ins, macros, or cloud-backed autosave behavior may contact external systems.
This skill does NOT:
- - Use Microsoft Graph, cloud document APIs, or OAuth flows.
- Disable review warnings silently.
- Accept destructive document-wide changes without explicit confirmation.
- Bypass Word protection prompts.
Related Skills
Install with
clawhub install <slug> if user confirms:
- -
word-docx — Offline DOCX generation and editing when Word does not need to stay open. - INLINECODE19 — Broader Office task routing across documents, spreadsheets, and presentations.
- INLINECODE20 — macOS app automation patterns when Word dictionary work needs deeper script design.
Feedback
- - If useful: INLINECODE21
- Stay updated: INLINECODE22
何时使用
用户需要将 Microsoft Word 作为实时应用程序进行控制,而非将其视为 .docx 文件格式进行处理。代理通过官方的 osascript 命令行界面处理应用附加、活动文档状态、基于选择的编辑、批注、修订、导出和干净关闭。如果主要工件是离线创建 DOCX 或结构性文件编辑,请改用 word-docx。
架构
内存存储在 ~/word/ 目录中。如果 ~/word/ 不存在,请运行 setup.md。结构请参见 memory-template.md。
text
~/word/
├── memory.md # 环境事实、安全默认值和上次有效控制路径
├── incidents.md # 可复用的故障和经过验证的恢复步骤
└── document-notes.md # 关于可信文档、视图和导出目标的非敏感备注
快速参考
仅加载与当前 Word 任务和风险级别匹配的最小文件。
memory-template.md |
| 接口选择 | execution-matrix.md |
| 实时控制模式 | live-control-patterns.md |
| 破坏性操作防护 | safety-checklist.md |
| 调试与恢复 | troubleshooting.md |
要求
- - 本地安装 Microsoft Word。
- macOS 系统且 osascript 可用。
- 执行破坏性文档操作前需明确确认。
核心规则
1. 根据文档状态选择应用控制路径
- - 通过应用的脚本字典,使用 osascript 对实时 Word 文档进行控制。
- 将自动化操作保持在实时 Word 会话内,而非回退到仅限文件的 DOCX 工具。
- 当请求的任务依赖于当前实时 Word 应用状态时,不要切换到离线文档库。
2. 在操作前确认具体文档和视图
- - 确认目标是活动文档、已命名的打开文档,还是需要立即打开的路径。
- 在进行与光标位置或标记状态相关的编辑前,先读取当前视图、选择内容和审阅模式。
- 切勿假设最前端的 Word 窗口就是目标文档。
3. 先读取再写入,然后验证最终状态
- - 在修改前,预先读取文档名称、当前选择、目标段落、批注数量或导出目标。
- 在编辑、添加批注、接受/拒绝操作或导出后,重新读取受影响的状态并报告更改内容。
- 如果 Word 未达到请求的状态,请停止并诊断,而不是叠加更多编辑操作。
4. 将基于选择的操作视为高风险
- - 基于选择的命令可能落入错误的段落、故事范围、页眉或批注框。
- 在可能的情况下,将操作锚定到特定的文档对象,而不仅仅是当前的插入点。
- 如果选择上下文不明确,请先澄清。
5. 区分可逆的审阅操作与破坏性清理
- - 添加批注、更改视图和导出通常是可逆的。
- 接受所有更改、拒绝所有更改、删除批注、不保存关闭以及覆盖导出需要明确确认。
- 如果审阅状态很重要,请保留修订和显示设置,除非用户明确要求更改它们。
6. 保持来源明确
- - 说明目标是已经打开的,还是仅为当前任务而打开的。
- 报告更改了哪个文档、哪个审阅模式处于活动状态以及导出写入的位置。
- 保留任务范围之外的用户自有打开文档。
7. 干净地恢复并避免孤立的应用会话
- - 如果你仅为当前任务打开了 Word,请保持所有权清晰,并仅关闭你创建的内容。
- 如果你附加到现有会话,未经明确批准,不要关闭无关文档或退出 Word。
- 失败时,记录确切的障碍:受保护文档、模态对话框、兼容模式、修订不匹配或权限缺失。
Word 陷阱
- - 将实时文档视为静态 .docx 文件 → 审阅状态、批注、字段和视图上下文会逐渐偏离。
- 在未验证选择的情况下相对于当前光标进行写入 → 文本落入错误的故事范围。
- 在仅打算修改某个部分时全局接受或拒绝更改 → 不可逆的编辑损失。
- 在字段、引用或目录更新之前导出 → 交付过时的输出作为最终版本。
- 自动化后关闭附加的用户会话 → 中断无关的写作工作。
- 忽略受保护视图或修订模式 → 编辑静默失败或创建错误的标记历史。
安全与隐私
本地存储的数据:
- - 文档路径、环境备注和 ~/word/ 中的可复用修复方案。
- 通过本地 Word 自动化访问的文档内容。
可能离开您机器的数据:
- - 默认情况下,此技能本身不会传输任何数据。
- 文档自身的链接、加载项、宏或云备份自动保存行为可能联系外部系统。
此技能不会:
- - 使用 Microsoft Graph、云文档 API 或 OAuth 流程。
- 静默禁用审阅警告。
- 未经明确确认接受破坏性的全文档更改。
- 绕过 Word 保护提示。
相关技能
如果用户确认,使用 clawhub install
安装:
- - word-docx — 当 Word 无需保持打开状态时的离线 DOCX 生成和编辑。
- office — 跨文档、电子表格和演示文稿的更广泛 Office 任务路由。
- applescript — 当 Word 字典工作需要更深层脚本设计时的 macOS 应用自动化模式。
反馈
- - 如果觉得有用:clawhub star word
- 保持更新:clawhub sync