Markdown to X Article agent skill
If you already draft technical posts in Markdown or Obsidian and work inside Claude Code, Codex, or another coding agent that reads SKILL.md, you do not have to copy and upload assets by hand. The open-source md2xarticle agent skill checks your Markdown locally, resolves local images and covers, drives md2xarticle.com in your Chrome session, and returns an unpublished X Article draft URL.
The skill never publishes automatically and never modifies your original Markdown file. Lossless rewrites such as flattening simple nested lists or turning footnotes into endnotes run on a temporary copy, and publishing stays a manual step in X.
What the skill handles
- Local and Obsidian images: resolves relative paths, Obsidian
![[image.png]]embeds, SVG images (rendered to PNG), and remotehttpsimages (downloaded locally so host CORS rules do not block upload). - Native tables and code blocks: keeps Markdown pipe tables and fenced code blocks as native X Markdown entities, or converts tables to PNG images when needed.
- Mermaid diagrams and X post embeds: renders standalone Mermaid blocks to 2× PNG images in the browser and converts standalone X status URLs into native post embeds.
- Cover image detection: picks up
--cover, frontmattercover:, or a siblingcover.png|jpg|jpeg|webpfile and sets it on the draft via companion 0.1.2+. - Lossless preflight fixes: flags unsupported constructs with line numbers before opening Chrome, with optional
--flatten-listsand--endnotesflags.
Requirements
node20 or newer andplaywright-cli.- Desktop Chrome with the Playwright Extension and the md2xarticle Chrome companion (version 0.1.2 or later for covers and optional automatic draft creation).
- A signed-in X account in that Chrome profile with access to X Articles.
Install the skill
Clone the repository and copy or symlink skills/md2xarticle into your agent's skills folder (for example ~/.claude/skills/md2xarticle or ~/.agents/skills/md2xarticle):
git clone https://github.com/geoqiao/x-article-studio.git
ln -s "$PWD/x-article-studio/skills/md2xarticle" ~/.agents/skills/md2xarticle
No extra npm install is required to run the skill: scripts/studio-core.mjs is pre-bundled from the website's own Markdown checker and runs directly with Node 20+.
How the workflow runs
- Preflight and prepare: run
prepare.mjsagainst your Markdown file. It validates the article without opening a browser, resolves images and cover candidates, and outputs JSON containing paths to generatedcreateandwaitbrowser scripts.
node skills/md2xarticle/scripts/prepare.mjs /path/to/article.md \
--images /path/to/attachments \
--cover /path/to/cover.png \
--endnotes --flatten-lists
- Stage and create the draft in your Chrome: attach to your signed-in Chrome profile and run the generated script.
playwright-cli attach --extension=chrome --session=md2x-run
playwright-cli -s=md2x-run run-code --filename=<create-script-path>
playwright-cli -s=md2x-run tab-close
- First-run confirmation: on the first run, the companion opens its review page and stops at
awaiting-confirmation. Click Create X draft there—and optionally tick Create drafts without this review once—so later agent runs complete without an extra click.
Returned stages
| Result | Meaning and next step |
|---|---|
ok: true | Draft created in X. Open the returned draftUrl to review and publish. |
awaiting-confirmation | Companion review tab is open. Confirm Create X draft (and optionally enable skip-review), then run the generated wait script. |
issues | The website detected content that would lose data (such as an image that failed to load). Fix the listed line numbers and rerun step 1. |
failed | No draft was created. For X_FIREWALL_BLOCKED, reword shell-pipe text such as curl … | sh; for sign-in errors, sign in to X and retry. |
uncertain | X returned no clear confirmation. Do not blindly retry—check x.com/compose/articles first to avoid duplicate drafts. |
companion-missing | Install or enable the Chrome companion in that profile and reload md2xarticle.com. |
Boundaries and safety
- Human approval stays in control: the browser session only sees the tab it opened and cannot toggle the companion's review setting on its own.
- No silent publishing or source edits: drafts remain unpublished in X, and original Markdown files on disk are never overwritten.
- Same format limits as the web editor: up to 40 prepared images and 20 MiB total (images between 5 and 40 MiB are downscaled automatically); ALT text, GIF, and video are not set by this tool; X's firewall may block shell commands piped into a shell (
curl … | sh), whichprepare.mjswarns about ahead of time.
Related guides
- Add a table to an X Article
- Add Mermaid diagrams to X Articles
- Markdown images in X Articles, including Obsidian notes
- Full Markdown to X Articles guide
- Source code on GitHub
md2xarticle is an independent tool and is not affiliated with or endorsed by X Corp. X controls Articles access and final rendering; check each draft in X before publishing.