agentleFS
fabioc-alohafabioc-aloha/Alex_ACT_ONE/skills/docx-to-md/SKILL.md

docx-to-md

Skill0 starsChanged 9 days agoMITView on GitHub

Convert Word documents (.docx) to clean Markdown with image extraction and pandoc cleanup. Use when the user asks to convert a Word doc, convert docx to md, or import a .docx into markdown.

2 other projects use a version of this, 2 of them edited.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Headers/footers: Not extracted (document body only)

    line 227

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Docx To Md

Ingest Word documents into your Markdown workflow — clean, linted, version-control ready

Convert .docx files into clean, linted Markdown with extracted images, normalized headings, and cleaned table formatting. The reverse converter for ingesting external documents into a Markdown-based workflow.


When to Use

  • Importing Word documents from stakeholders into a Markdown-based workflow
  • Converting legacy documentation to Markdown for version control
  • Extracting content from .docx for further processing (presentations, email, web)
  • Onboarding external resources (SOWs, RFPs, specs) into project repositories
  • Migrating from Word-based documentation to docs-as-code
  • Preparing content for static site generators (VitePress, Docusaurus, etc.)

Supported Content

Content TypeStatusNotes
Headings✅Hierarchy normalized to start at H1
Bold/Italic✅Converted to Markdown syntax
Links✅Preserved as Markdown links
Images✅Extracted to images/<output filename>/
Tables✅Cleaned and aligned
Lists✅Ordered, unordered, nested
Code blocks⚠️Detected if styled as code
Footnotes✅Converted to Markdown footnotes
Comments⚠️Stripped with --strip-comments
Track changes❌Accept/reject before converting
Embedded objects❌Extract manually

Key Features

FeatureDetails
Image extractionEmbedded images saved to images/<output filename>/ with sequential naming
Pandoc cleanupRemoves escaped brackets, span classes, trailing backslashes
Table normalizationAligns columns, adds proper separators
Heading fixNormalizes hierarchy to start at H1
FrontmatterOptional YAML frontmatter with title and date
Comment strippingRemoves Word review comments

Cleanup and image extraction leave inline, fenced, and indented code unchanged, including examples nested in blockquotes and lists. Heading normalization and comment removal apply outside code. Real media references are copied and verified, including images nested in lists.

Each output owns a separate media directory named after its complete output filename. Converting or reconverting another document in the same folder does not replace the first document's images. Links URL-encode special characters in that directory name. Existing shared images from older conversions are not deleted automatically.

The converter stages Markdown and extracted images together before publishing them. A conversion failure leaves the prior document and media unchanged; handled publication failures roll back files already replaced. If rollback itself fails, the error names retained recovery copies. This is not a power-loss or process-crash transaction guarantee. Windows UNC/network and device image paths are rejected before filesystem access.


Usage

# Basic conversion
node skills/docx-to-md/scripts/docx-to-md.cjs report.docx

# With frontmatter and heading normalization
node skills/docx-to-md/scripts/docx-to-md.cjs spec.docx --add-frontmatter --fix-headings

# Strip review comments
node skills/docx-to-md/scripts/docx-to-md.cjs reviewed.docx --strip-comments

# Custom output path
node skills/docx-to-md/scripts/docx-to-md.cjs input.docx output/document.md

# Debug mode (keeps raw pandoc output)
node skills/docx-to-md/scripts/docx-to-md.cjs input.docx --debug

# Full cleanup pipeline
node skills/docx-to-md/scripts/docx-to-md.cjs spec.docx --add-frontmatter --fix-headings --strip-comments --clean-tables

Options Reference

OptionDefaultDescription
--extract-imagestrueExtract images to images/<output filename>/
--no-extract-images-Keep images inline in Pandoc's Markdown output
--add-frontmatteroffGenerate YAML frontmatter with title/date
--clean-tablestrueNormalize table column widths
--no-clean-tables-Keep pandoc raw table output
--fix-headingsoffNormalize heading hierarchy to start at H1
--wrap N0Wrap lines at N characters (0 = no wrap)
--strip-commentsoffRemove Word comment annotations
--debugoffKeep intermediate pandoc output

Post-Processing Pipeline

The conversion follows a multi-stage cleanup:

.docx → pandoc → raw MD → cleanup → clean MD
                            ↓
                    1. Escaped brackets removed
                    2. Trailing backslashes removed
                    3. Span classes stripped
                    4. Image attributes cleaned
                    5. Comments stripped (optional)
                    6. Headings normalized (optional)
                    7. Tables reformatted
                    8. Images extracted
                    9. Frontmatter added (optional)

Pandoc Cleanup Details

Pandoc QuirkBeforeAfter
Escaped brackets\[text\][text]
Trailing backslashesline\line
Span classes{.underline}(removed)
Image attributes{width="5in"}(removed)
Heading anchors{#section-1}(removed)
Excessive blank lines\n\n\n\n\n\n

Image Extraction

Embedded images are extracted below a sibling images/ folder, namespaced by the output filename:

input/
├── document.docx
├── document.md (output)
└── images/
    └── document.md/
        ├── image-001.png
        ├── image-002.png
        └── image-003.jpg

Image references in markdown are updated automatically:

![](images/document.md/image-001.png)

Common Workflows

Stakeholder Document Ingestion

# Convert with full cleanup
node skills/docx-to-md/scripts/docx-to-md.cjs stakeholder-spec.docx \
  --add-frontmatter --fix-headings --strip-comments

# Review the generated markdown and extracted images
git diff -- stakeholder-spec.md images/

Legacy Documentation Migration

# Batch convert all Word docs
Get-ChildItem *.docx | ForEach-Object {
  node skills/docx-to-md/scripts/docx-to-md.cjs $_.FullName --add-frontmatter --fix-headings
}

Troubleshooting

ProblemCauseSolution
"pandoc not found"pandoc not installedRun /alex-act-one setup-dependencies
Images missingExtraction failedCheck images/ folder, re-run
Tables misalignedComplex table structureManual cleanup may be needed
Headings start at H3Original doc structureUse --fix-headings
Comments in outputTrack changes not strippedUse --strip-comments
Encoding issuesNon-UTF8 contentRe-save .docx as UTF-8

Limitations

  • Track changes: Accept or reject all changes in Word before converting
  • Embedded objects: Charts, SmartArt, etc. must be extracted manually
  • Complex tables: Merged cells may not convert cleanly
  • Styles: Word styles are lost (only structural elements preserved)
  • Headers/footers: Not extracted (document body only)

Requirements

  • Node.js 24+
  • pandoc — run /alex-act-one setup-dependencies to check and install

Muscle Scripts

skills/docx-to-md/scripts/docx-to-md.cjs

skills/docx-to-md/scripts/validate-md.cjs: post-conversion acceptance checks (heading continuity, footnote sequence, image existence)


Conversion Acceptance Decision Table

ConditionVerdictAction
All headings mapped to correct # levelsAcceptRun scripts/validate-md.cjs on the output; it asserts no skipped heading levels
Headings rendered as bold paragraphs instead of #RejectCheck pandoc --shift-heading-level and source styles
Tables converted to valid Markdown pipe tablesAcceptSpot-check alignment
Complex tables (merged cells) lose structureWarningManual restructure or use HTML table fallback
Images extracted and linked with relative pathsAcceptRun scripts/validate-md.cjs; it asserts every referenced image file exists in the output dir
Images lost or referenced with absolute Windows pathsRejectUse --extract-media with correct output dir
Footnotes converted to Markdown footnote syntaxAcceptRun scripts/validate-md.cjs; it asserts footnote definitions are sequential and every reference resolves
Footnotes lost or inlined as parenthetical textWarningCheck pandoc footnote handling
Code blocks preserve monospace and indentationAcceptVerify language fence tags present
Track changes / comments stripped from outputAcceptExpected — Markdown has no change tracking
Track changes rendered as visible markupRejectAccept or reject all changes before conversion
Bullet and numbered lists preserve nestingAcceptVerify indent levels match source
Output passes markdownlint with zero errorsAcceptReview against lint-clean-markdown guidance
Round-trip (docx→md→docx) preserves semantic contentAcceptFormatting differences OK; content loss is not

Related Skills

  • md-to-word - reverse direction (Markdown to Word)
  • Markdown linting - validate the output with the project's linter; when Core is installed, its lint-clean-markdown skill provides author-side guidance
  • md-to-html - convert result to HTML for web

Falsifiability

  • This skill is wrong if converted documents lose semantic structure (headings, lists, tables) that Pandoc preserves by default without the documented flags
  • The flag recommendations are stale if a Pandoc major version changes default behaviors for the documented options
  • The workflow is not earning its tokens if the user must manually fix the same structural issues on every conversion

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

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.