{"id":"03b74997-02e9-4fc8-a1ca-1e2dfcd9c476","shortId":"ym2vyf","kind":"skill","title":"docx-official","tagline":"A user may ask you to create, edit, or analyze the contents of a .docx file. A .docx file is essentially a ZIP archive containing XML files and other resources that you can read or edit. You have different tools and workflows available for different tasks.","description":"# DOCX creation, editing, and analysis\n\n## Overview\n\nA user may ask you to create, edit, or analyze the contents of a .docx file. A .docx file is essentially a ZIP archive containing XML files and other resources that you can read or edit. You have different tools and workflows available for different tasks.\n\n## Workflow Decision Tree\n\n### Reading/Analyzing Content\nUse \"Text extraction\" or \"Raw XML access\" sections below\n\n### Creating New Document\nUse \"Creating a new Word document\" workflow\n\n### Editing Existing Document\n- **Your own document + simple changes**\n  Use \"Basic OOXML editing\" workflow\n\n- **Someone else's document**\n  Use **\"Redlining workflow\"** (recommended default)\n\n- **Legal, academic, business, or government docs**\n  Use **\"Redlining workflow\"** (required)\n\n## Reading and analyzing content\n\n### Text extraction\nIf you just need to read the text contents of a document, you should convert the document to markdown using pandoc. Pandoc provides excellent support for preserving document structure and can show tracked changes:\n\n```bash\n# Convert document to markdown with tracked changes\npandoc --track-changes=all path-to-file.docx -o output.md\n# Options: --track-changes=accept/reject/all\n```\n\n### Raw XML access\nYou need raw XML access for: comments, complex formatting, document structure, embedded media, and metadata. For any of these features, you'll need to unpack a document and read its raw XML contents.\n\n#### Unpacking a file\n`python ooxml/scripts/unpack.py <office_file> <output_directory>`\n\n#### Key file structures\n* `word/document.xml` - Main document contents\n* `word/comments.xml` - Comments referenced in document.xml\n* `word/media/` - Embedded images and media files\n* Tracked changes use `<w:ins>` (insertions) and `<w:del>` (deletions) tags\n\n## Creating a new Word document\n\nWhen creating a new Word document from scratch, use **docx-js**, which allows you to create Word documents using JavaScript/TypeScript.\n\n### Workflow\n1. **MANDATORY - READ ENTIRE FILE**: Read [`docx-js.md`](docx-js.md) (~500 lines) completely from start to finish. **NEVER set any range limits when reading this file.** Read the full file content for detailed syntax, critical formatting rules, and best practices before proceeding with document creation.\n2. Create a JavaScript/TypeScript file using Document, Paragraph, TextRun components (You can assume all dependencies are installed, but if not, refer to the dependencies section below)\n3. Export as .docx using Packer.toBuffer()\n\n## Editing an existing Word document\n\nWhen editing an existing Word document, use the **Document library** (a Python library for OOXML manipulation). The library automatically handles infrastructure setup and provides methods for document manipulation. For complex scenarios, you can access the underlying DOM directly through the library.\n\n### Workflow\n1. **MANDATORY - READ ENTIRE FILE**: Read [`ooxml.md`](ooxml.md) (~600 lines) completely from start to finish. **NEVER set any range limits when reading this file.** Read the full file content for the Document library API and XML patterns for directly editing document files.\n2. Unpack the document: `python ooxml/scripts/unpack.py <office_file> <output_directory>`\n3. Create and run a Python script using the Document library (see \"Document Library\" section in ooxml.md)\n4. Pack the final document: `python ooxml/scripts/pack.py <input_directory> <office_file>`\n\nThe Document library provides both high-level methods for common operations and direct DOM access for complex scenarios.\n\n## Redlining workflow for document review\n\nThis workflow allows you to plan comprehensive tracked changes using markdown before implementing them in OOXML. **CRITICAL**: For complete tracked changes, you must implement ALL changes systematically.\n\n**Batching Strategy**: Group related changes into batches of 3-10 changes. This makes debugging manageable while maintaining efficiency. Test each batch before moving to the next.\n\n**Principle: Minimal, Precise Edits**\nWhen implementing tracked changes, only mark text that actually changes. Repeating unchanged text makes edits harder to review and appears unprofessional. Break replacements into: [unchanged text] + [deletion] + [insertion] + [unchanged text]. Preserve the original run's RSID for unchanged text by extracting the `<w:r>` element from the original and reusing it.\n\nExample - Changing \"30 days\" to \"60 days\" in a sentence:\n```python\n# BAD - Replaces entire sentence\n'<w:del><w:r><w:delText>The term is 30 days.</w:delText></w:r></w:del><w:ins><w:r><w:t>The term is 60 days.</w:t></w:r></w:ins>'\n\n# GOOD - Only marks what changed, preserves original <w:r> for unchanged text\n'<w:r w:rsidR=\"00AB12CD\"><w:t>The term is </w:t></w:r><w:del><w:r><w:delText>30</w:delText></w:r></w:del><w:ins><w:r><w:t>60</w:t></w:r></w:ins><w:r w:rsidR=\"00AB12CD\"><w:t> days.</w:t></w:r>'\n```\n\n### Tracked changes workflow\n\n1. **Get markdown representation**: Convert document to markdown with tracked changes preserved:\n   ```bash\n   pandoc --track-changes=all path-to-file.docx -o current.md\n   ```\n\n2. **Identify and group changes**: Review the document and identify ALL changes needed, organizing them into logical batches:\n\n   **Location methods** (for finding changes in XML):\n   - Section/heading numbers (e.g., \"Section 3.2\", \"Article IV\")\n   - Paragraph identifiers if numbered\n   - Grep patterns with unique surrounding text\n   - Document structure (e.g., \"first paragraph\", \"signature block\")\n   - **DO NOT use markdown line numbers** - they don't map to XML structure\n\n   **Batch organization** (group 3-10 related changes per batch):\n   - By section: \"Batch 1: Section 2 amendments\", \"Batch 2: Section 5 updates\"\n   - By type: \"Batch 1: Date corrections\", \"Batch 2: Party name changes\"\n   - By complexity: Start with simple text replacements, then tackle complex structural changes\n   - Sequential: \"Batch 1: Pages 1-3\", \"Batch 2: Pages 4-6\"\n\n3. **Read documentation and unpack**:\n   - **MANDATORY - READ ENTIRE FILE**: Read [`ooxml.md`](ooxml.md) (~600 lines) completely from start to finish. **NEVER set any range limits when reading this file.** Pay special attention to the \"Document Library\" and \"Tracked Change Patterns\" sections.\n   - **Unpack the document**: `python ooxml/scripts/unpack.py <file.docx> <dir>`\n   - **Note the suggested RSID**: The unpack script will suggest an RSID to use for your tracked changes. Copy this RSID for use in step 4b.\n\n4. **Implement changes in batches**: Group changes logically (by section, by type, or by proximity) and implement them together in a single script. This approach:\n   - Makes debugging easier (smaller batch = easier to isolate errors)\n   - Allows incremental progress\n   - Maintains efficiency (batch size of 3-10 changes works well)\n\n   **Suggested batch groupings:**\n   - By document section (e.g., \"Section 3 changes\", \"Definitions\", \"Termination clause\")\n   - By change type (e.g., \"Date changes\", \"Party name updates\", \"Legal term replacements\")\n   - By proximity (e.g., \"Changes on pages 1-3\", \"Changes in first half of document\")\n\n   For each batch of related changes:\n\n   **a. Map text to XML**: Grep for text in `word/document.xml` to verify how text is split across `<w:r>` elements.\n\n   **b. Create and run script**: Use `get_node` to find nodes, implement changes, then `doc.save()`. See **\"Document Library\"** section in ooxml.md for patterns.\n\n   **Note**: Always grep `word/document.xml` immediately before writing a script to get current line numbers and verify text content. Line numbers change after each script run.\n\n5. **Pack the document**: After all batches are complete, convert the unpacked directory back to .docx:\n   ```bash\n   python ooxml/scripts/pack.py unpacked reviewed-document.docx\n   ```\n\n6. **Final verification**: Do a comprehensive check of the complete document:\n   - Convert final document to markdown:\n     ```bash\n     pandoc --track-changes=all reviewed-document.docx -o verification.md\n     ```\n   - Verify ALL changes were applied correctly:\n     ```bash\n     grep \"original phrase\" verification.md  # Should NOT find it\n     grep \"replacement phrase\" verification.md  # Should find it\n     ```\n   - Check that no unintended changes were introduced\n\n\n## Converting Documents to Images\n\nTo visually analyze Word documents, convert them to images using a two-step process:\n\n1. **Convert DOCX to PDF**:\n   ```bash\n   soffice --headless --convert-to pdf document.docx\n   ```\n\n2. **Convert PDF pages to JPEG images**:\n   ```bash\n   pdftoppm -jpeg -r 150 document.pdf page\n   ```\n   This creates files like `page-1.jpg`, `page-2.jpg`, etc.\n\nOptions:\n- `-r 150`: Sets resolution to 150 DPI (adjust for quality/size balance)\n- `-jpeg`: Output JPEG format (use `-png` for PNG if preferred)\n- `-f N`: First page to convert (e.g., `-f 2` starts from page 2)\n- `-l N`: Last page to convert (e.g., `-l 5` stops at page 5)\n- `page`: Prefix for output files\n\nExample for specific range:\n```bash\npdftoppm -jpeg -r 150 -f 2 -l 5 document.pdf page  # Converts only pages 2-5\n```\n\n## Code Style Guidelines\n**IMPORTANT**: When generating code for DOCX operations:\n- Write concise code\n- Avoid verbose variable names and redundant operations\n- Avoid unnecessary print statements\n\n## Dependencies\n\nRequired dependencies (install if not available):\n\n- **pandoc**: `sudo apt-get install pandoc` (for text extraction)\n- **docx**: `npm install -g docx` (for creating new documents)\n- **LibreOffice**: `sudo apt-get install libreoffice` (for PDF conversion)\n- **Poppler**: `sudo apt-get install poppler-utils` (for pdftoppm to convert PDF to images)\n- **defusedxml**: `pip install defusedxml` (for secure XML parsing)\n\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.","tags":["docx","official","antigravity","awesome","skills","sickn33","agent-skills","agentic-skills","ai-agent-skills","ai-agents","ai-coding","ai-workflows"],"capabilities":["skill","source-sickn33","skill-docx-official","topic-agent-skills","topic-agentic-skills","topic-ai-agent-skills","topic-ai-agents","topic-ai-coding","topic-ai-workflows","topic-antigravity","topic-antigravity-skills","topic-claude-code","topic-claude-code-skills","topic-codex-cli","topic-codex-skills"],"categories":["antigravity-awesome-skills"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/sickn33/antigravity-awesome-skills/docx-official","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add sickn33/antigravity-awesome-skills","source_repo":"https://github.com/sickn33/antigravity-awesome-skills","install_from":"skills.sh"}},"qualityScore":"0.700","qualityRationale":"deterministic score 0.70 from registry signals: · indexed on github topic:agent-skills · 34831 github stars · SKILL.md body (10,121 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-04-24T06:51:05.751Z","embedding":null,"createdAt":"2026-04-18T21:36:18.962Z","updatedAt":"2026-04-24T06:51:05.751Z","lastSeenAt":"2026-04-24T06:51:05.751Z","tsv":"'-10':566,767,931 '-3':812,967 '-5':1246 '-6':817 '1':312,434,680,775,787,809,811,966,1140 '150':1164,1176,1180,1235 '2':355,476,701,777,780,791,814,1153,1204,1208,1237,1245 '3':381,482,565,766,818,930,943 '3.2':730 '30':638,654,674 '4':499,816,888 '4b':887 '5':782,1046,1217,1221,1239 '500':320 '6':1067 '60':641,659,675 '600':442,830 'academ':149 'accept/reject/all':218 'access':113,221,226,425,521 'across':996 'action':1343 'actual':595 'adjust':1182 'allow':303,532,922 'alway':1022 'amend':778 'analysi':54 'analyz':13,65,160,1127 'api':467 'appear':606 'appli':1096 'applic':1337 'approach':912 'apt':1281,1300,1310 'apt-get':1280,1299,1309 'archiv':27,79 'articl':731 'ask':7,59,1381 'assum':367 'attent':848 'automat':410 'avail':46,98,1277 'avoid':1260,1267 'b':998 'back':1059 'bad':647 'balanc':1185 'bash':198,692,1062,1083,1098,1145,1160,1231 'basic':135 'batch':557,563,577,718,763,771,774,779,786,790,808,813,892,917,927,936,976,1052 'best':348 'block':749 'boundari':1389 'break':608 'busi':150 'chang':133,197,205,209,217,279,538,550,555,561,567,590,596,637,665,678,690,696,705,712,723,769,794,806,855,879,890,894,932,944,949,953,963,968,979,1010,1041,1087,1094,1118 'check':1073,1114 'clarif':1383 'claus':947 'clear':1356 'code':1247,1253,1259 'comment':228,268 'common':516 'complet':322,444,548,832,1054,1076 'complex':229,421,523,796,804 'compon':364 'comprehens':536,1072 'concis':1258 'contain':28,80 'content':15,67,106,161,172,254,266,340,462,1038 'convers':1306 'convert':178,199,684,1055,1078,1121,1130,1141,1149,1154,1201,1214,1242,1319 'convert-to':1148 'copi':880 'correct':789,1097 'creat':10,62,116,120,285,291,306,356,483,999,1168,1294 'creation':51,354 'criteria':1392 'critic':344,546 'current':1032 'current.md':700 'date':788,952 'day':639,642,655,660,676 'debug':570,914 'decis':103 'default':147 'definit':945 'defusedxml':1323,1326 'delet':283,613 'depend':369,378,1271,1273 'describ':1344,1360 'detail':342 'differ':42,48,94,100 'direct':429,472,519 'directori':1058 'doc':153 'doc.save':1012 'document':118,124,128,131,142,175,180,191,200,231,248,265,289,295,308,353,361,391,397,400,418,465,474,479,491,494,503,507,528,685,708,743,820,851,860,939,973,1014,1049,1077,1080,1122,1129,1296 'document.docx':1152 'document.pdf':1165,1240 'document.xml':271 'docx':2,18,21,50,70,73,300,384,1061,1142,1255,1288,1292 'docx-j':299 'docx-js.md':318,319 'docx-offici':1 'dom':428,520 'dpi':1181 'e.g':728,745,941,951,962,1202,1215 'easier':915,918 'edit':11,39,52,63,91,126,137,387,393,473,586,601 'effici':574,926 'element':629,997 'els':140 'embed':233,273 'entir':315,437,649,825 'environ':1372 'environment-specif':1371 'error':921 'essenti':24,76 'etc':1173 'exampl':636,1227 'excel':187 'execut':1339 'exist':127,389,395 'expert':1377 'export':382 'extract':109,163,627,1287 'f':1196,1203,1236 'featur':241 'file':19,22,30,71,74,82,257,261,277,316,335,339,359,438,457,461,475,826,845,1169,1226 'final':502,1068,1079 'find':722,1007,1105,1112 'finish':326,448,836 'first':746,970,1198 'format':230,345,1189 'full':338,460 'g':1291 'generat':1252 'get':681,1004,1031,1282,1301,1311 'good':661 'govern':152 'grep':737,985,1023,1099,1107 'group':559,704,765,893,937 'guidelin':1249 'half':971 'handl':411 'harder':602 'headless':1147 'high':512 'high-level':511 'identifi':702,710,734 'imag':274,1124,1133,1159,1322 'immedi':1025 'implement':542,553,588,889,904,1009 'import':1250 'increment':923 'infrastructur':412 'input':1386 'insert':281,614 'instal':371,1274,1283,1290,1302,1312,1325 'introduc':1120 'isol':920 'iv':732 'javascript/typescript':310,358 'jpeg':1158,1162,1186,1188,1233 'js':301 'key':260 'l':1209,1216,1238 'last':1211 'legal':148,957 'level':513 'librari':401,404,409,432,466,492,495,508,852,1015 'libreoffic':1297,1303 'like':1170 'limit':331,453,841,1348 'line':321,443,754,831,1033,1039 'll':243 'locat':719 'logic':717,895 'main':264 'maintain':573,925 'make':569,600,913 'manag':571 'mandatori':313,435,823 'manipul':407,419 'map':759,981 'mark':592,663 'markdown':182,202,540,682,687,753,1082 'match':1357 'may':6,58 'media':234,276 'metadata':236 'method':416,514,720 'minim':584 'miss':1394 'move':579 'must':552 'n':1197,1210 'name':793,955,1263 'need':167,223,244,713 'never':327,449,837 'new':117,122,287,293,1295 'next':582 'node':1005,1008 'note':863,1021 'npm':1289 'number':727,736,755,1034,1040 'o':212,699,1090 'offici':3 'ooxml':136,406,545 'ooxml.md':440,441,498,828,829,1018 'ooxml/scripts/pack.py':505,1064 'ooxml/scripts/unpack.py':259,481,862 'oper':517,1256,1266 'option':214,1174 'organ':714,764 'origin':619,632,667,1100 'output':1187,1225,1366 'output.md':213 'overview':55,1347 'pack':500,1047 'packer.tobuffer':386 'page':810,815,965,1156,1166,1199,1207,1212,1220,1222,1241,1244 'page-1.jpg':1171 'page-2.jpg':1172 'pandoc':184,185,206,693,1084,1278,1284 'paragraph':362,733,747 'pars':1330 'parti':792,954 'path-to-file.docx':211,698 'pattern':470,738,856,1020 'pay':846 'pdf':1144,1151,1155,1305,1320 'pdftoppm':1161,1232,1317 'per':770 'permiss':1387 'phrase':1101,1109 'pip':1324 'plan':535 'png':1191,1193 'poppler':1307,1314 'poppler-util':1313 'practic':349 'precis':585 'prefer':1195 'prefix':1223 'preserv':190,617,666,691 'principl':583 'print':1269 'proceed':351 'process':1139 'progress':924 'provid':186,415,509 'proxim':902,961 'python':258,403,480,487,504,646,861,1063 'quality/size':1184 'r':1163,1175,1234 'rang':330,452,840,1230 'raw':111,219,224,252 'read':37,89,158,169,250,314,317,333,336,436,439,455,458,819,824,827,843 'reading/analyzing':105 'recommend':146 'redlin':144,155,525 'redund':1265 'refer':375 'referenc':269 'relat':560,768,978 'repeat':597 'replac':609,648,801,959,1108 'represent':683 'requir':157,1272,1385 'resolut':1178 'resourc':33,85 'reus':634 'review':529,604,706,1378 'reviewed-document.docx':1066,1089 'rsid':622,866,873,882 'rule':346 'run':485,620,1001,1045 'safeti':1388 'scenario':422,524 'scope':1359 'scratch':297 'script':488,869,910,1002,1029,1044 'section':114,379,496,729,773,776,781,857,897,940,942,1016 'section/heading':726 'secur':1328 'see':493,1013 'sentenc':645,650 'sequenti':807 'set':328,450,838,1177 'setup':413 'show':195 'signatur':748 'simpl':132,799 'singl':909 'size':928 'skill':1335,1351 'skill-docx-official' 'smaller':916 'soffic':1146 'someon':139 'source-sickn33' 'special':847 'specif':1229,1373 'split':995 'start':324,446,797,834,1205 'statement':1270 'step':886,1138 'stop':1218,1379 'strategi':558 'structur':192,232,262,744,762,805 'style':1248 'substitut':1369 'success':1391 'sudo':1279,1298,1308 'suggest':865,871,935 'support':188 'surround':741 'syntax':343 'systemat':556 'tackl':803 'tag':284 'task':49,101,1355 'term':652,657,672,958 'termin':946 'test':575,1375 'text':108,162,171,593,599,612,616,625,670,742,800,982,987,993,1037,1286 'textrun':363 'togeth':906 'tool':43,95 'topic-agent-skills' 'topic-agentic-skills' 'topic-ai-agent-skills' 'topic-ai-agents' 'topic-ai-coding' 'topic-ai-workflows' 'topic-antigravity' 'topic-antigravity-skills' 'topic-claude-code' 'topic-claude-code-skills' 'topic-codex-cli' 'topic-codex-skills' 'track':196,204,208,216,278,537,549,589,677,689,695,854,878,1086 'track-chang':207,215,694,1085 'treat':1364 'tree':104 'two':1137 'two-step':1136 'type':785,899,950 'unchang':598,611,615,624,669 'under':427 'unintend':1117 'uniqu':740 'unnecessari':1268 'unpack':246,255,477,822,858,868,1057,1065 'unprofession':607 'updat':783,956 'use':107,119,134,143,154,183,280,298,309,360,385,398,489,539,752,875,884,1003,1134,1190,1333,1349 'user':5,57 'util':1315 'valid':1374 'variabl':1262 'verbos':1261 'verif':1069 'verifi':991,1036,1092 'verification.md':1091,1102,1110 'visual':1126 'well':934 'word':123,288,294,307,390,396,1128 'word/comments.xml':267 'word/document.xml':263,989,1024 'word/media':272 'work':933 'workflow':45,97,102,125,138,145,156,311,433,526,531,679,1341 'write':1027,1257 'xml':29,81,112,220,225,253,469,725,761,984,1329 'zip':26,78","prices":[{"id":"c1ee15cc-0fea-415b-a9b2-5015bbbfbb6c","listingId":"03b74997-02e9-4fc8-a1ca-1e2dfcd9c476","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"sickn33","category":"antigravity-awesome-skills","install_from":"skills.sh"},"createdAt":"2026-04-18T21:36:18.962Z"}],"sources":[{"listingId":"03b74997-02e9-4fc8-a1ca-1e2dfcd9c476","source":"github","sourceId":"sickn33/antigravity-awesome-skills/docx-official","sourceUrl":"https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/docx-official","isPrimary":false,"firstSeenAt":"2026-04-18T21:36:18.962Z","lastSeenAt":"2026-04-24T06:51:05.751Z"}],"details":{"listingId":"03b74997-02e9-4fc8-a1ca-1e2dfcd9c476","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"sickn33","slug":"docx-official","github":{"repo":"sickn33/antigravity-awesome-skills","stars":34831,"topics":["agent-skills","agentic-skills","ai-agent-skills","ai-agents","ai-coding","ai-workflows","antigravity","antigravity-skills","claude-code","claude-code-skills","codex-cli","codex-skills","cursor","cursor-skills","developer-tools","gemini-cli","gemini-skills","kiro","mcp","skill-library"],"license":"mit","html_url":"https://github.com/sickn33/antigravity-awesome-skills","pushed_at":"2026-04-24T06:41:17Z","description":"Installable GitHub library of 1,400+ agentic skills for Claude Code, Cursor, Codex CLI, Gemini CLI, Antigravity, and more. Includes installer CLI, bundles, workflows, and official/community skill collections.","skill_md_sha":"b8c2bd3c1a67fb1a8a2bdb37c8f25f83fbe2818b","skill_md_path":"skills/docx-official/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/docx-official"},"layout":"multi","source":"github","category":"antigravity-awesome-skills","frontmatter":{"name":"docx-official","description":"A user may ask you to create, edit, or analyze the contents of a .docx file. A .docx file is essentially a ZIP archive containing XML files and other resources that you can read or edit. You have different tools and workflows available for different tasks."},"skills_sh_url":"https://skills.sh/sickn33/antigravity-awesome-skills/docx-official"},"updatedAt":"2026-04-24T06:51:05.751Z"}}