agentleFS
rstackjsrstackjs/agent-skills/.agents/skills/mdx-to-markdown/SKILL.md

mdx-to-markdown

Skill95 starsChanged 4 months agoMITView on GitHub

Convert `.mdx` to portable `.md`, cleaning MDX components, anchors, code titles, table-of-contents links, and root-relative docs links.

  • Installs packages

The file

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 5 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    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
  1. Distinctive:

    Use this skill to produce plain Markdown from MDX without requiring the target renderer to understand MDX imports, JSX components, Rspress …

    line 12
  2. Distinctive:

    Run the helper script when the requested conversion matches the default rules:

    line 25
  3. Distinctive:

    Remove Rspress heading anchor suffixes while keeping the heading text.

    line 40
  4. Very specific:

    Remove standalone <a id="..."></a> anchor lines.

    line 41
  5. Distinctive:

    Remove table-of-contents links that target in-page anchors, preserving the list text.

    line 42
  6. Very specific:

    Add /zh to the prefix when the MDX path contains a zh path segment.

    line 62
  7. Very specific:

    Use --link-prefix <prefix> only when the inferred domain is wrong or the user explicitly requests a custom prefix.

    line 63
  8. Distinctive:

    Run targeted checks after conversion:

    line 67

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

MDX to Markdown

Overview

Use this skill to produce plain Markdown from MDX without requiring the target renderer to understand MDX imports, JSX components, Rspress anchors, or code-block metadata.

Workflow

  1. Identify the source .mdx and target .md path. If the user gives only a source path, default the output to the same path with .md.
  2. Inspect the MDX for non-Markdown constructs:
    • YAML frontmatter.
    • top-level import lines.
    • custom components such as <BlogAuthors /> and <PackageManagerTabs />.
    • heading anchors like ### Title \{#title}.
    • standalone HTML anchors like <a id="title"></a>.
    • fenced code block titles such as a JavaScript fence with title="env.js".
    • HTML image wrappers such as centered <div><img ... /></div>.
  3. Run the helper script when the requested conversion matches the default rules:

    node /path/to/skills/mdx-to-markdown/scripts/convert_mdx_to_markdown.mjs input.mdx output.md
  4. Review the result with rg and a short diff. Confirm that no MDX-only syntax remains.
  5. Apply any user-requested follow-up edits, such as removing a generated table of contents or changing link policy.

Default conversion rules

  • Drop YAML frontmatter and top-level MDX imports.
  • Remove <BlogAuthors />.
  • Expand <PackageManagerTabs command="add pkg -D" /> to a bash code block using pnpm add pkg -D.
  • Convert centered HTML image blocks into Markdown image syntax.
  • Remove Rspress heading anchor suffixes while keeping the heading text.
  • Remove standalone <a id="..."></a> anchor lines.
  • Remove table-of-contents links that target in-page anchors, preserving the list text.
  • Convert code-fence titles or standalone bold filename captions into the first line of the code block as a comment, for example:

    // hello.js
    export function greet(name) {
      return `Hello, ${name}!`;
    }
    
    console.log(greet('world'));
  • Convert code blocks that contain markers such as // [!code highlight] to diff code blocks, remove the marker, and prefix highlighted lines with +.
  • Prefix Markdown links whose target starts with / using the current repository's site domain. Infer the product from the input file's Git repository, remote, package name, or path segment:
    • rspack -> rspack.rs
    • rsbuild -> rsbuild.rs
    • rspress -> rspress.rs
    • rslib -> rslib.rs
    • rsdoctor -> rsdoctor.rs
    • rstest -> rstest.rs
  • Add /zh to the prefix when the MDX path contains a zh path segment. For example, a Chinese Rspack document converts /guide/optimization/tree-shaking to https://rspack.rs/zh/guide/optimization/tree-shaking.
  • Use --link-prefix <prefix> only when the inferred domain is wrong or the user explicitly requests a custom prefix.

Validation checklist

Run targeted checks after conversion:

rg -n '<BlogAuthors|PackageManagerTabs|title="|\\{#|^<a id="|\\]\(/|!code highlight|^\*\*[^*]+\*\*$' output.md
rg -n '^```' output.md | wc -l

The first command should return no matches unless the user intentionally kept that syntax. The fence count should be even.

Resources

  • scripts/convert_mdx_to_markdown.mjs: deterministic converter for the common Rspack/Rstack release-blog MDX pattern.

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.