doc-to-word-rtl
Skill4 starsChanged 34 days agoMITView on GitHub
Exports a Claude Doc (claude.ai artifact link) to a Word .docx, Arabic docs in a right-to-left Saudi thesis house style and English docs in APA 7. Use when asked to turn a Claude Doc into Word, docx, ملف وورد or تحويل المستند إلى ورد.
- Installs packages
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 21
Locate: Call Claude Docs read with ref: {object: "project", id: <doc id>}.
- Very specific: line 24
Read the tab with payload: {"projection": "outline"}.
- Very specific: line 27
Write <scratch>/images.json as a list of {"alt": "<alt or caption>", "path": "<file>"} in the order they appear.
- Distinctive: line 36
no box glyphs or reversed words.
- Distinctive: line 39
Lesson: Every run that hit a defect (a failed step, a wrong render, a user correction to the output) ends with a lesson for this skill.
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Claude Doc → Word
Turn a Claude Doc into a .docx that opens in Word already in its house style. Two scripts in this skill's scripts/ folder, one per language; each is the single source of truth for its house style, and its options override it when a client's template differs:
- Arabic doc →
md_to_docx_rtl.py(right-to-left paragraphs and tables, Traditional Arabic, thesis spacing) - English doc →
md_to_docx_en.py(APA 7 student paper)
The doc's language is the one most of its prose is written in; the client's instructions win when they name a style.
Build the final file with the script. The connector's own docx export carries no bidi settings, so its Arabic tables and paragraphs come out mirrored.
Steps
- Locate. Call Claude Docs
readwithref: {object: "project", id: <doc id>}. For a shortclaude.ai/artifact/...link,Artifactread it first to get the doc id. Done when you hold the doc id and the file id of every tab. - Export. For each tab, call Claude Docs
exportwithformat: "markdown". Large results are saved to a JSON file and the tool message names its path: that path is the script input as is. Small inline results: write{"data":{"bytes_b64":"<the value>"}}to<scratch>/<tab>.json. Done when every tab has an input file on disk. - Pictures. The export's
noteslist each dropped construct; images become[image: <alt>\]lines and charts or other widgets become[embedded content: <caption>\]. When the notes report any, fetch every one, in document order:- Read the tab with
payload: {"projection": "outline"}. Each picture is a<media blob='blob/<id>' alt='…'/>, each chart an<embed ref='node/<id>' caption='…'/>. A<gap>inside a list or table hides its blocks; read that block with{"kind": "view", "parentId": "<its id>"}when the outline shows fewer pictures than the notes count. - Picture:
readref: {object: "blob", id: "<id>"}gives itsasset; thenArtifactread with the doc's link andpath: "<asset>"saves the file and prints its path. - Chart:
readref: {object: "node", id: "<id>"},engine: "widget",payload: {"kind": "screenshot"}saves a PNG and prints its path. - Write
<scratch>/images.jsonas a list of{"alt": "<alt or caption>", "path": "<file>"}in the order they appear. Done when the list holds one entry per dropped picture and chart.
- Read the tab with
- Pick the script.
<base dir>/scripts/<script>, where<base dir>is the "Base directory for this skill" line shown when this skill loads and<script>is the one for the doc's language. Run it in place (pip install python-docx --break-system-packagesif the import fails). Done whenpython3 <base dir>/scripts/<script> -hprints usage. - Convert.
python3 <base dir>/scripts/<script> <input> "<doc title>.docx" [--images <scratch>/images.json] [options], passing an option for every client-template value that differs from the house style. Done when the script printsOK -> ...andimages: N embedded, 0 missingfor every tab;direction: LTRfrom the Arabic script on an Arabic doc means the script is damaged: stop and tell the user. - Verify.
soffice --headless --convert-to pdf, thenpdftoppm -r 60 -pngand view a body page, a table page, a numbered-list page, and a page with a picture when there is one. Done when every page viewed passes every check:- layout matches the house-style table for the doc's language (Arabic: first table column on the right, grey header row; English: rules only above, below the header and at the bottom of tables);
- headings placed per the house style (right-aligned Arabic headings sit on the right edge);
- each picture centered within the margins, its caption under it;
- each numbered list starts at 1;
- no box glyphs or reversed words. The render box usually lacks Traditional Arabic and substitutes a fallback face; judge layout, not typeface.
- Deliver. SendUserFile, file named after the doc title. Name anything still missing (comments, a picture that could not be fetched) so the user can add it by hand.
- Lesson. Every run that hit a defect (a failed step, a wrong render, a user correction to the output) ends with a lesson for this skill. Done when each defect is either fixed in the skill's source or the user declined the fix:
- Name the defect and its root cause in one line each, then propose the smallest change that prevents it: the script, the house-style table, or a step here.
- Make the change only after the user approves the proposal.
- Apply it in a working copy of this skill, rerun steps 5 and 6 on the same doc, and send the user the new .docx.
- Once the user confirms the new output is correct, write the change into the skill's source,
EngDawood/claude-doc-to-docx-arabic: a pull request that bumpsversionin.claude-plugin/plugin.json. For a copy installed in Claude (claude.ai / Cowork) as a.pluginfile, also repackage it with thecowork-pluginskill (customize mode). - A defect the user declines stays as it is; keep the deliverable from step 7.
Arabic house style (md_to_docx_rtl.py)
Taken from a hand-formatted Saudi master's thesis chapter.
| Element | Style | Option |
| Page | A4, margins 2.54 cm, centered page number | --paper, --margins |
| Body | Traditional Arabic 16, colour 0D0D0D, justified, line 1.08, 8 pt after | --ar-font, --en-font, --size, --color, --line |
# | 22 bold, centered | derives from --size |
## | 18 bold | derives from --size |
### | 16 bold | derives from --size |
| Heading alignment | centered when it opens with المحور / الفصل / مراجع / المراجع; right otherwise (أولاً، 1.، خلاصة) | CENTER_H_RE in script |
Caption جدول (n): … | 16 bold centered, kept with the table | |
| Table | full width, 14 pt, header bold on E7E6E6 repeated each page, rows unsplit, cells vertically centered, text right, numbers centered | --table-size |
| After a table | 10 pt space before the next paragraph | |
| Lists | 16 pt, 4 pt after, every numbered list restarts at 1 | |
| References (under a heading with المراجع / References) | right-aligned, hanging indent 0.635 cm | |
| English-only paragraph | left-to-right, same font | |
| Pictures and charts | centered, scaled to the text width (at most 18 cm tall); a chart's caption under it | --images |
| Right-aligned text | no jc set, so Word aligns it to the start (right) of the RTL line; jc="right" would land on the left | |
date · @name line under the title | removed | --keep-byline |
--- | page break |
English house style (md_to_docx_en.py, APA 7)
| Element | Style | Option |
| Page | US Letter, margins 2.54 cm, page number top right | --paper, --margins |
| Body | Times New Roman 12, double-spaced, left-aligned, first line indented 1.27 cm, no space between paragraphs | --font, --size, --line |
# | paper title, bold centered | |
## | APA Level 1, bold centered | |
### | Level 2, bold flush left | |
#### | Level 3, bold italic flush left | |
##### | Level 4, bold indented | |
Table n: Title | "Table n" bold on its own line, title italic on the next | |
| Table | horizontal rules only (top, under header, bottom), header row repeats, rows unsplit | --table-size |
Note. line after a table | "Note." italic, then the text | |
| Lists | double-spaced, every numbered list restarts at 1 | |
References heading | starts a new page; entries hanging indent 1.27 cm | |
| Pictures and charts | centered, scaled to the text width (at most 18 cm tall); a chart's caption under it | --images |
date · @name line under the title | removed | --keep-byline |
In this repository4 other files it gives its agents.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

