---
name: markdown-docs-optimizer
description: "Rewrites an existing Markdown file so it reads faster: consistent headings, correct code fences, working internal links, and the sections your readers need first moved to the top. Use when an existing Markdown doc is hard to read and needs its headings, code fences, internal links, and section order cleaned up with the content preserved. Do not use for producing a lint report without fixing anything, or formatting raw notes that were never a document. Related topics: coding, markdown."
---

# Markdown Docs Optimizer

Rewrites an existing Markdown file so it reads faster: consistent headings, correct code fences, working internal links, and the sections your readers need first moved to the top.

## When to use

Use this skill when an existing Markdown doc is hard to read and needs its headings, code fences, internal links, and section order cleaned up with the content preserved. Do not use it for producing a lint report without fixing anything, or formatting raw notes that were never a document.

## Workflow

1. Ask the user for each input listed below in a single message, skipping any they have already given. Where options are listed, offer them, but accept other answers too.
2. List the file's structural faults: skipped heading levels, untagged fences, mixed bullet markers, dead internal anchors, and buried procedures.
3. Fix the structure first, so every heading level is consecutive and every fence carries a language tag.
4. Reorder the prioritized sections to the top in the given order and keep all other sections in their original sequence.
5. Rewrite sentences for the audience and tone while keeping every fact, command, and code line intact.
6. Add a table of contents when there are four or more H2 sections, trim repetition to fit the size limit, and return the markdown fence.

## Inputs

- **Document** (longer free text)
- **Document purpose** (choose one: API guide, User manual, Internal wiki, Tutorial, Release notes)
- **Primary audience** (choose one: Junior developers, Senior developers, QA engineers, Product managers, Non-technical stakeholders)
- **Sections to prioritize** (choose any: Introduction, Installation, Usage examples, Configuration, FAQ, Troubleshooting)
- **Desired tone** (choose one: Formal, Conversational, Concise, Detailed)
- **Maximum file size (KB)** (number from 10 to 500)
- **Include code block styling** (choose one: Yes, No)

## Output

Only the optimized document inside a single fenced block tagged markdown, with a table of contents when there are four or more H2 sections and every code fence tagged.

## Prompt template

Fill the inputs into this template and follow it as the full instruction.

### Markdown Docs Optimizer

Improve my existing Markdown document without changing what it says.

- Document: {{Document}}
- Document purpose: {{Document purpose}}
- Primary audience: {{Primary audience}}
- Sections to prioritize: {{Sections to prioritize}}
- Desired tone: {{Desired tone}}
- Maximum file size (KB): {{Maximum file size (KB)}}
- Include code block styling: {{Include code block styling}}

Read the whole file first and list its structural problems: skipped heading levels, untagged or mis-tagged code fences, inconsistent bullet markers, internal links whose anchors match no heading, and paragraphs that bury a procedure. Fix structure before touching sentences. Move the prioritized sections toward the top in the order given, and leave the rest in their original order so cross-references still make sense. Rewrite sentences for the audience and tone while preserving every fact, command, and code line; shorten rather than add. Add a table of contents when the document has four or more H2 sections. Keep the result under the size limit by trimming repetition, not content. When code block styling is on, tag every fence and add a one-line caption above blocks longer than ten lines. Return only the optimized Markdown inside a fenced block tagged markdown.

## Pitfalls

- Renaming headings for style and breaking every anchor link that pointed at them.
- Cutting content to hit the size limit when trimming repeated explanations would have been enough.
- Reordering unprioritized sections too, which scrambles cross-references and the reader's mental map.
