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.
~/word/
├── memory.md # Environment facts, safe defaults, and last working control path
├── incidents.md # Reusable failures and proven recovery steps
└── document-notes.md # Non-sensitive notes about trusted documents, views, and export targets
Quick Reference
Load only the smallest file that matches the current Word task and risk level.
| Topic |
File |
| Setup guide |
setup.md |
| 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.
office — Broader Office task routing across documents, spreadsheets, and presentations.
applescript — macOS app automation patterns when Word dictionary work needs deeper script design.
Feedback
- If useful:
clawhub star word
- Stay updated:
clawhub sync
1---2name: control-word-app-via-osascript3description: "Control Word app sessions, documents, selections, comments, export, and review state with osascript workflows."4category: "Integrations"5author: community6version: "1.0.0"7icon: plug8metadata:9 source: https://skillmd.com/skills/rondoflow/control-word-app-via-osascript10---1112## When to Use1314User needs Microsoft Word controlled as a live application, not treated as a `.docx` file format.15Agent handles app attach, active document state, selection-aware edits, comments, track changes, export, and clean shutdown through the official `osascript` CLI.16If the main artifact is offline DOCX creation or structural file editing, use `word-docx` instead.1718## Architecture1920Memory lives in `~/word/`. If `~/word/` does not exist, run `setup.md`. See `memory-template.md` for structure.2122```text23~/word/24├── memory.md # Environment facts, safe defaults, and last working control path25├── incidents.md # Reusable failures and proven recovery steps26└── document-notes.md # Non-sensitive notes about trusted documents, views, and export targets27```2829## Quick Reference3031Load only the smallest file that matches the current Word task and risk level.3233| Topic | File |34|-------|------|35| Setup guide | `setup.md` |36| Memory template | `memory-template.md` |37| Interface selection | `execution-matrix.md` |38| Live control patterns | `live-control-patterns.md` |39| Destructive action guardrails | `safety-checklist.md` |40| Debug and recovery | `troubleshooting.md` |4142## Requirements4344- Microsoft Word installed locally.45- macOS with `osascript` available.46- Explicit confirmation before destructive document actions.4748## Core Rules4950### 1. Choose the app-control path by document state51- Use `osascript` for live Word document control through the app's scripting dictionary.52- Keep automation inside the live Word session instead of falling back to file-only DOCX tooling.53- Do not switch to offline document libraries when the requested job depends on the current live Word app state.5455### 2. Identify the exact document and view before acting56- Confirm whether the target is the active document, a named open document, or a path to open now.57- Read the current view, selection, and review mode before making edits tied to cursor position or markup state.58- Never assume the frontmost Word window is the intended document.5960### 3. Read before write, then verify the final state61- Pre-read document name, current selection, target paragraph, comment count, or export target before mutation.62- After edits, comments, accept/reject actions, or exports, re-read the affected state and report what changed.63- If Word does not reach the requested state, stop and diagnose instead of layering more edits.6465### 4. Treat selection-driven actions as high-risk66- Selection-based commands can land in the wrong paragraph, story range, header, or comment balloon.67- When possible, anchor the action to a specific document object instead of only the current insertion point.68- If the selection context is ambiguous, clarify first.6970### 5. Separate reversible review actions from destructive cleanup71- Adding comments, changing view, and exporting are usually reversible.72- Accept all changes, reject all changes, remove comments, close without save, and overwrite exports require explicit confirmation.73- If review state matters, preserve track changes and display settings unless the user explicitly asks to change them.7475### 6. Keep provenance explicit76- State whether the target was already open or opened just for this task.77- Report what document was changed, which review mode was active, and where exports were written.78- Preserve user-owned open documents that were outside the task scope.7980### 7. Recover cleanly and avoid orphaned app sessions81- If you opened Word just for this task, keep ownership clear and close only what you created.82- If you attached to an existing session, do not close unrelated documents or quit Word without explicit approval.83- On failure, record the exact blocker: protected document, modal dialog, compatibility mode, track changes mismatch, or missing permissions.8485## Word Traps8687- Treating a live document like a static `.docx` file -> review state, comments, fields, and view context drift apart.88- Writing relative to the current cursor without verifying selection -> text lands in the wrong story range.89- Accepting or rejecting changes globally when only one section was intended -> irreversible editorial loss.90- Exporting before fields, references, or TOC are updated -> stale output delivered as final.91- Closing an attached user session after automation -> unrelated writing work is interrupted.92- Ignoring protected view or tracked-change mode -> edits silently fail or create the wrong markup history.9394## Security & Privacy9596**Data that stays local:**97- Document paths, environment notes, and reusable fixes in `~/word/`.98- Document contents accessed through local Word automation.99100**Data that may leave your machine:**101- Nothing by default from this skill itself.102- A document's own links, add-ins, macros, or cloud-backed autosave behavior may contact external systems.103104**This skill does NOT:**105- Use Microsoft Graph, cloud document APIs, or OAuth flows.106- Disable review warnings silently.107- Accept destructive document-wide changes without explicit confirmation.108- Bypass Word protection prompts.109110## Related Skills111Install with `clawhub install <slug>` if user confirms:112- `word-docx` — Offline DOCX generation and editing when Word does not need to stay open.113- `office` — Broader Office task routing across documents, spreadsheets, and presentations.114- `applescript` — macOS app automation patterns when Word dictionary work needs deeper script design.115116## Feedback117118- If useful: `clawhub star word`119- Stay updated: `clawhub sync`