docx

Utilisez cette compétence pour créer, lire, modifier ou manipuler des documents Word (.docx) ou des modèles Word (.dotx).

Qu'est-ce que docx ?

Cette compétence permet à un agent IA de traiter des documents Word (format .docx) en utilisant plusieurs approches adaptées à chaque tâche. Pour la création de nouveaux documents, un script Node.js utilisant la bibliothèque `docx` (préinstallée) peut être généré, en respectant des règles précises pour la mise en page, les tableaux, les listes, les sauts de page et les tables des matières. Pour l'édition de documents existants, la compétence guide le décompression du fichier .docx (qui est une archive ZIP), la modification directe du XML dans `word/document.xml` après fusion des fragments de texte avec `merge_runs.py`, puis la re-compression et la validation. La lecture du contenu textuel peut être effectuée simplement avec `pandoc`. La compétence inclut également des utilitaires pour gérer les commentaires (avec un script dédié qui crée tous les fichiers XML nécessaires) et les modifications suivies (validation avec `--author`, acceptation des changements). Enfin, un processus de vérification visuelle est proposé : conversion en PDF via LibreOffice, puis transformation en images avec `pdftoppm` pour inspection. Les plateformes supportées sont les environnements avec Node.js, Pandoc, LibreOffice et Poppler installés.

Compatible avec~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/anthropics/skills/tree/main/skills/docx

Installed? Explore more Développement et programmation skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

Demander à votre IA préférée

Ouvre une nouvelle conversation avec cette compétence d'agent déjà préchargée.

Documentation

Création, édition et analyse de documents DOCX

Un fichier .docx est une archive ZIP contenant des fichiers XML. Choisissez votre approche selon la tâche :

TâcheApproche
Créer un nouveau documentÉcrire un script docx (npm) — voir les pièges ci-dessous
Modifier un document existantunzip → modifier word/document.xml → zip (docx-js ne peut pas ouvrir les fichiers existants)
Lire le contenupandoc -t markdown fichier.docx

Les chemins des scripts ci-dessous sont relatifs au répertoire de cette compétence.

Créer avec docx-js — pièges

docx est préinstallé — n'exécutez pas npm install d'abord ; écrivez le script et utilisez require('docx') directement. Ce n'est qu'en cas d'échec de cette instruction : npm install docx. Le modèle connaît l'API ; voici les pièges à éviter :

  • Le format de page par défaut est A4. Pour du format US Letter, définissez page: { size: { width: 12240, height: 15840 } } (en DXA ; 1440 = 1 pouce).
  • Paysage : passez les dimensions portrait et orientation: PageOrientation.LANDSCAPE — docx-js échange la largeur/hauteur en interne.
  • Les tableaux nécessitent deux largeurs : définissez columnWidths sur le tableau ET width sur chaque cellule, les deux en WidthType.DXA (POURCENTAGE ne fonctionne pas dans Google Docs). Les largeurs de colonnes doivent totaliser la largeur du tableau.
  • Ombrer un tableau : utilisez ShadingType.CLEAR, jamais SOLID (rendu en noir).
  • Listes : n'insérez jamais littéralement • ; utilisez une configuration numbering avec LevelFormat.BULLET.
  • ImageRun nécessite type: ("png", "jpg", …).
  • PageBreak doit être à l'intérieur d'un Paragraph.
  • N'utilisez jamais \n — utilisez des éléments Paragraph séparés.
  • TDM : les titres doivent utiliser les HeadingLevel.* intégrés ; les styles de titre personnalisés nécessitent outlineLevel défini, sinon ils n'apparaissent pas.
  • N'utilisez pas un tableau comme filet horizontal — utilisez plutôt une bordure inférieure de paragraphe.
  • Points de suite / aligné à droite sur la même ligne : utilisez PositionalTab (alignment: PositionalTabAlignment.RIGHT, leader: PositionalTabLeader.DOT) dans un TextRun, pas de . littéral ou d'espacement.

Vérifier la sortie

Après avoir écrit un fichier .docx, rendez-le et examinez-le :

python scripts/office/soffice.py --headless --convert-to pdf output.docx
pdftoppm -jpeg -r 100 output.pdf page
ls page-*.jpg   # puis Lisez les images

pdftoppm ajoute des zéros non significatifs aux numéros de page pour correspondre à la largeur du nombre de pages (page-01.jpg…page-12.jpg).

Modifier des documents existants

Les fichiers .doc hérités doivent d'abord être convertis : python scripts/office/soffice.py --headless --convert-to docx fichier.doc.

unzip -q doc.docx -d unpacked/
find unpacked -type l -delete   # supprimer les entrées de liens symboliques — les docx de sources externes ne sont pas fiables
python scripts/merge_runs.py unpacked/   # fusionner les fragments de texte pour que le texte soit trouvable
# modifier unpacked/word/document.xml sur place — NE PAS reformater ni "pretty-print"
(cd unpacked && rm -f ../out.docx && zip -Xr ../out.docx .)
python scripts/office/validate.py out.docx --original doc.docx   # vérifications XSD ; --auto-repair corrige les problèmes courants
# marquage ? ajoutez --author "<le nom sous lequel vous avez marqué>" pour vérifier que chaque modification est suivie

Word fragmente le texte entre de nombreuses balises <w:r> (identifiants de révision, marqueurs de correction orthographique), donc une phrase que vous voyez dans le document n'existe souvent pas en tant que chaîne contiguë dans le XML. merge_runs.py fusionne les fragments adjacents de même formatage dans word/document.xml sans modifier le contenu ni le rendu ; il accepte également un fichier .docx directement (python scripts/merge_runs.py doc.docx -o merged.docx).

Modifications suivies : lors du marquage, validez avec --author "<le nom sous lequel vous avez marqué>" (nécessite --original) — il signale tout texte modifié sans balise <w:ins>/<w:del> autour, ce qui est facile à faire par accident et invisible dans la vue acceptée. Encadrez les fragments avec <w:ins>/<w:del> avec les attributs w:id, w:author, w:date. À l'intérieur de <w:del>, l'élément de texte est <w:delText>, pas <w:t>. Une marque de paragraphe supprimée (<w:pPr><w:rPr><w:del w:id=".." w:author=".." w:date=".."/></w:rPr></w:pPr>) signifie "fusionner ce paragraphe dans le suivant" — supprimer carrément un paragraphe revient donc à cela plus un <w:del> autour de chaque fragment. <w:del/> doit précéder les autres enfants de rPr ; leur ordre est imposé par le schéma.

Pour produire une copie propre avec toutes les modifications suivies acceptées : python scripts/accept_changes.py in.docx out.docx.

Accepter une marque de paragraphe supprimée devrait fusionner ce paragraphe avec celui du dessous, de sorte qu'un paragraphe dont tous les fragments sont supprimés disparaisse. Word fait cela ; accept_changes.py et pandoc --track-changes=accept ne le font pas toujours. Les deux échouent de la même manière — ils suppriment le texte supprimé mais laissent le paragraphe vide, ce qui apparaît comme une puce vide parasite lorsqu'il était numéroté automatiquement :

  • pandoc --track-changes=accept ne fusionne jamais les paragraphes.
  • accept_changes.py (LibreOffice) les fusionne correctement, sauf lorsque le paragraphe supprimé est suivi d'un paragraphe espaceur vide.

Une puce vide dans l'une ou l'autre vue est un artefact de cette vue, pas un défaut du document. Vérifiez les suppressions de paragraphe dans le XML.

Commentaires

Les commentaires nécessitent six fichiers liés entre eux. Utilisez l'assistant — mode répertoire lorsque vous allez également modifier document.xml (économise un cycle décompression/recompression), mode .docx direct sinon :

# Contre un répertoire déjà décompressé (préféré si vous placez aussi des marqueurs)
python scripts/comment.py unpacked/ "Le plafond des frais est trop bas"
python scripts/comment.py unpacked/ "D'accord" --parent 0

# Contre un .docx directement
python scripts/comment.py contrat.docx "Ce plafond est trop bas" -o annote.docx

Le script écrit comments.xml, commentsExtended.xml, commentsIds.xml, commentsExtensible.xml, les relations et les substitutions de type de contenu. Les ID de commentaires sont attribués automatiquement. Il imprime ensuite l'extrait <w:commentRangeStart>/<w:commentRangeEnd>/<w:commentReference> à ajouter à word/document.xml pour que le commentaire s'ancre à un texte spécifique — jusqu'à ce que vous placiez ces marqueurs, le commentaire existe mais n'est pas visible.

Dépendances

docx (npm, préinstallé — n'installer que si require('docx') échoue) · pandoc · LibreOffice (soffice) · pdftoppm (Poppler)

Individual skills in this repo

This repo contains 19 individual skills — each has its own dedicated page.

academy-guide

Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials, and use cases from Claude Academy (academy.claude.com), Anthropic's learning hub. Trigger on: "how do I", "how can I", "getting started with", "what can Claude do", "teach me", "learn to use"; questions about artifacts, projects, skills, plugins, connectors, MCP; requests about rolling Claude out to a team, class, or organization; and any ask for training materials, onboarding content, or learning resources. Use it when the user is learning how to use a feature or product — not when they are mid-task and just want the task done. This skill composes with other skills: after consulting product documentation to answer how a Claude feature works, also check here for a matching course or tutorial — a docs-grounded answer and an Academy recommendation belong together. Only recommend on a strong match; never invent Academy content.

algorithmic-art

Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems. Create original algorithmic art rather than copying existing artists

anthropics/template-skill

Replace with description of the skill and when Claude should use it.

brand-guidelines

Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.

canvas-design

Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists

claude-api

|-

discernment-nudge

After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals, or emails, estimates or projections, analysis or interpretation of data, factual claims they may rely on, or a multi-step argument — invoke this skill BEFORE finalizing your reply and then, if it applies, append 2-3 short follow-up questions, each tied to something specific in what you just produced, that help the user check key facts, probe the reasoning or assumptions, and notice missing context. Do this at most once per conversation. Skip it when the user asked a trivial how-to or simple lookup, wants a purely educational explanation, asked you only to format, convert, or assemble a file from content they provided, is writing code they will run, is doing creative writing or casual chat, or already asked you to double-check, cite, or review — the skill file explains these boundaries and the exact output format.

doc-coauthoring

Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks.

frontend-design

Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.

internal-comms

A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill whenever asked to write some sort of internal communications (status reports, leadership updates, 3P updates, company newsletters, FAQs, incident reports, project updates, etc.).

mcp-builder

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

pdf

Use this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.

pptx

Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill.

skill-creator

Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill

slack-gif-creator

Knowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like

theme-factory

Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with colors/fonts that you can apply to any artifact that has been creating, or can generate a new theme on-the-fly.

webapp-testing

Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.

web-artifacts-builder

Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use for complex artifacts requiring state management, routing, or shadcn/ui components - not for simple single-file HTML/JSX artifacts.

xlsx

Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.

Skills associés