md2wechat
Use this skill to operate the md2wechat CLI. Keep the skill focused on execution decisions. For full command tutorials, installation details, and FAQ-level explanations, refer users to the project docs instead of expanding this runtime protocol.
Intent Routing
Choose the command family before taking any publish or generation action:
- Standard article HTML, article preview, metadata inspection, or WeChat article draft: use
inspect, preview, and convert.
- Unpublished Zhihu, CSDN, or Toutiao draft: run
md2wechat skills read md2wechat references/sync/workflow.md --json for the current CLI's embedded workflow; the CLI prepares content and the Agent operates the browser.
- Image-first post, image note, image-text note,
newspic, or multi-image post: use create_image_post, not convert --draft.
- Article cover or article infographic: prefer
generate_cover or generate_infographic over raw generate_image when a bundled preset fits.
- Host-agent image generation request with no provider configured: use image plan mode (
--plan --json) to get prompt intent, then hand it to the host image-generation tool if one is available outside md2wechat.
- WeChat title candidates for an existing article: use
title suggest <article.md> --json; it emits a host-Agent AI request and does not choose or write the final title.
- Existing article or draft, user asks what to improve next: run
md2wechat advise <article.md> --json; treat it as recommendation-only and keep inspect --json data.readiness.targets/blockers as the publish gate.
- Writing in a creator style or removing AI traces: use
write or humanize.
- Provider, theme, prompt, or layout uncertainty: run discovery first. Do not guess from memory or repository files.
Treat convert --draft and create_image_post as different publish targets, not interchangeable variants.
Discovery First
Use CLI discovery as the source of truth, but keep it scoped to the next decision. Do not run the full catalog for tasks that do not need provider, theme, prompt, or layout selection.
Use capabilities for aggregate routing facts, resource list for lightweight selection fields, show for one full resource definition, and render for materialized prompt/layout output. JSON stdout is compact; use jq only when a human needs formatted output.
Run the smallest useful discovery set:
Article formatting with no theme or modules chosen:
md2wechat themes list --json
md2wechat layout list --json
A named theme, provider, prompt, or layout module:
md2wechat themes show <name> --json
md2wechat providers show <name> --json
md2wechat prompts show <name> --kind <kind> --json
md2wechat layout show <name> --json
Image generation or image-preset selection:
md2wechat providers list --json
md2wechat prompts list --kind image --json
Subject-reference (image-to-image) capability before using --subject-reference:
md2wechat providers show minimax --json
Read supports_subject_reference on the provider and on each entry of supported_models. Only the minimax provider and its image-01 model accept --subject-reference, and the reference must be a publicly reachable http(s) portrait image URL; inline data URLs and local paths are rejected. Unsupported provider/model combinations fail immediately with CONFIG_INVALID, so do not retry them as generation failures.
Title suggestion prompt selection:
md2wechat prompts list --kind title --json
md2wechat prompts show wechat-title-expert --kind title --json
Draft, upload, API local-readiness, or configuration troubleshooting:
md2wechat doctor --json
md2wechat config show --format json
md2wechat config wechat-accounts --json
doctor readiness is local configuration attemptability. config wechat-accounts is local-only and never prints WeChat secrets. Use inspect --json for article-specific target readiness.
Unknown CLI version, changed behavior, or capability uncertainty:
md2wechat version --json
md2wechat capabilities --json
md2wechat skills list --json
md2wechat skills read md2wechat --json
md2wechat skills read md2wechat --json reads the SOP embedded in the current CLI binary. Prefer it when the installed external skill, README, or repository checkout may be stale relative to the executable on PATH.
For simple local actions such as preview, humanize, or a user-specified command with explicit flags, do not run unrelated provider, theme, prompt, or layout discovery.
Inspect specific resources only when the task needs them:
md2wechat providers show <name> --json
md2wechat themes show <name> --json
md2wechat prompts show <name> --kind <kind> --json
md2wechat layout show <name> --json
Use CLI output as the source of truth for currently available modes, providers, themes, prompts, and layout modules.
Configuration Boundaries
- Assume
md2wechat is already available on PATH.
convert defaults to API mode unless the user explicitly asks for --mode ai.
- API-mode preview and conversion require a valid
MD2WECHAT_API_KEY.
- WeChat upload, article draft creation, and
create_image_post require WeChat credentials whenever the user explicitly requests those side effects.
- Read-only discovery,
inspect, preview, and plain conversion are free of any global WeChat publishing credential requirement; API-mode preview and conversion still require a valid MD2WECHAT_API_KEY.
- Named WeChat account execution requires a valid
MD2WECHAT_API_KEY; the CLI validates it before upload, draft, or create_image_post effects.
- Direct image generation requires image-provider credentials; image plan mode (
--plan --json) only emits prompt intent for a host Agent or external tool and does not require image-provider credentials.
title suggest --json only emits a title-generation prompt request for the host Agent or external model. It does not call a model, upload, create drafts, or write back to Markdown.
- For stronger factual title hooks, pass --hook-level 2 or 3; do not treat generated titles as confirmed publishing intent.
doctor --json is local-only: it checks local readiness and does not perform live authentication, upload images, or create drafts.
- Use
config show --format json when the user asks what configuration is currently effective.
- Use
config wechat-accounts --json when the user asks which local WeChat accounts are configured.
Article Workflow
Prefer a confirm-first workflow for article work:
md2wechat inspect <article.md> --json
md2wechat preview <article.md>
md2wechat convert <article.md> ...
- Add
--upload, --draft, --cover, or --cover-media-id only when the user explicitly asks for upload or draft creation.
inspect is the source-of-truth command for structured metadata, checks, readiness targets, and blockers. In --json output, read data.readiness.targets and data.readiness.blockers before deciding whether convert, upload, or draft is blocked. If the requested target is blocked, stop and report the matching blockers; do not continue by guessing from legacy booleans or checks alone. Do not invent data.agent_readiness, data.target_readiness, ArticleState, state files, or a second readiness/state object. preview writes only byte-identical final API HTML from a successful converter result; with --json, inspect diagnostics are returned in data.inspect and are never wrapped into that file. It does not upload images, create drafts, or write back to Markdown. convert performs conversion and only the explicitly requested upload/draft effects. convert --preview is the convert-path preview flag and is not the same as the standalone preview command. On PREVIEW_ACTION_REQUIRED or PREVIEW_FAILED, this invocation does not create or overwrite preview HTML. With --json, PREVIEW_ACTION_REQUIRED returns an empty data.output_file. Any pre-existing explicit output path is stale and must not be treated as this invocation's result; use the returned prompt for host-Agent work or report the failure.
When the intended execution path is convert --mode ai --custom-prompt ..., run inspect with the same --mode ai --custom-prompt ... before trusting readiness.
Formatting Protocol
When the user asks to format an article and has not chosen a theme or modules:
- Read the article and optional Brand Profile.
- Use discovery output as facts.
- Choose a compatible theme and a small set of modules from the article's content goal.
- Keep the source Markdown read-only.
- Create a temporary formatted Markdown artifact, for example
/tmp/md2wechat-format/<run-id>/article.formatted.md.
- Insert only layout modules whose required fields can be filled correctly.
- Run
md2wechat layout validate --file <formatted.md> --json.
- Pass the formatted Markdown artifact to
convert.
Saving generated Markdown next to the source file requires explicit user confirmation and must not overwrite the source.
Theme Selection
- Read
type and selectable from themes list --json.
- API mode can use only
type: api and selectable: true themes.
- AI mode can use only
type: ai and selectable: true themes.
- Do not use collection descriptors such as non-selectable theme groups as concrete themes.
- If Brand Profile names a theme, verify it through CLI discovery before using it.
- If a requested theme is invalid or mode-incompatible, stop that path and choose a valid theme or ask the user.
Layout Modules
Advanced layout modules render only in API mode. AI mode (--mode ai) does not parse :::module syntax, so advanced layout cards will not render there.
Use this decision frame:
attention: help readers decide whether the article is worth reading.
readability: make mobile reading easier.
memorability: make one judgment, quote, metric, or brand anchor stick.
conversion: help readers save, follow, inquire, share, or buy.
Use CLI discovery as the source of truth for layout syntax instead of memorizing or guessing body_format values:
- Inspect the opener, body schema, canonical executable example, and structurally distinct variants with
layout show <name> --json. Reuse the canonical witness.
- Use
layout render for structured fields and --body-file (or --body-file - for stdin) for complex bodies, then validate the generated Markdown.
- Default discovery returns recommended modules. Use
layout list --lifecycle compatibility --json only for old-content migration. Local validation proves syntax acceptance only; production support is a release-conformance fact.
Default module discipline:
- Do not pile on modules.
- Use at most one hero, one verdict, and one cta unless the user explicitly asks for more.
- Skip modules when the article does not provide enough content to fill them honestly.
API And AI Mode
- API mode is the default and is required for advanced layout modules.
- AI mode is a lighter path and does not render advanced layout modules.
- Do not silently switch from API mode to AI mode after an API failure. That changes the output capability.
- Use AI mode only when the user asks for it or accepts losing advanced layout rendering.
- If an AI-mode conversion completes, it is acceptable to briefly mention that API mode supports advanced layout modules and stronger visual structure.
Brand Profile
Brand Profile lives at ~/.config/md2wechat/brand.md.
- It is free-form Markdown, not YAML and not a fixed schema.
- The CLI does not parse it.
- Read it as context for voice, theme preferences, module preferences, CTA preferences, and forbidden expressions.
- Treat quantity preferences as soft constraints.
- Verify any named theme or module through CLI discovery.
- If Brand Profile does not exist, do not block the task. You may mention once that system defaults will be used.
- Create or edit Brand Profile only when the user explicitly asks.
Publishing Side Effects
Do not create drafts, upload images, publish, or call remote image generation unless the user asks for that action.
Before every explicit WeChat side effect—image upload, article draft creation, or create_image_post—require configured WeChat credentials and use the target-matched readiness/preflight path. Discovery and inspection remain non-publishing paths; preview and plain conversion are free of any global WeChat publishing credential requirement, while API mode still requires a valid MD2WECHAT_API_KEY.
Before WeChat article draft creation through convert:
- Use
inspect --json and check data.readiness.targets.draft; when blocked, read matching data.readiness.blockers.
- Draft creation requires a cover via
--cover or --cover-media-id.
- Do not assume a WeChat URL or
mmbiz.qpic.cn URL can be reused as thumb_media_id.
- If draft creation returns
45004, check digest, summary, and description before assuming the body is too long.
In the WeChat convert flow, Markdown images are uploaded or replaced only during --upload or --draft, not during plain conversion or preview.
Failure Handling
- Missing or invalid config: run
doctor --json and config show --format json; report data.overall plus the blocking data.readiness.* item.
- Invalid layout syntax: run
layout validate, inspect the failing module with layout show, fix the generated artifact, then validate again.
- Unknown layout modules warn for forward compatibility; verify typos against
layout list --json.
- Theme rejection: check
type and selectable, then choose a compatible theme or ask the user.
- AI request or style-writing flows may return a prompt/request rather than final prose or HTML unless the external model step is completed.
1---2name: md2wechat3description: Convert Markdown to WeChat Official Account HTML. Use this whenever the user wants WeChat article formatting, article preview, WeChat draft upload, image generation for articles, cover or infographic generation, image-post creation, writer-style drafting, title suggestions, AI trace removal, or current discovery of supported providers, themes, prompts, and layout modules. Also use for unpublished Zhihu, CSDN, or Toutiao drafts through a browser.4---56# md2wechat78Use this skill to operate the `md2wechat` CLI. Keep the skill focused on execution decisions. For full command tutorials, installation details, and FAQ-level explanations, refer users to the project docs instead of expanding this runtime protocol.910## Intent Routing1112Choose the command family before taking any publish or generation action:1314- Standard article HTML, article preview, metadata inspection, or WeChat article draft: use `inspect`, `preview`, and `convert`.15- Unpublished Zhihu, CSDN, or Toutiao draft: run `md2wechat skills read md2wechat references/sync/workflow.md --json` for the current CLI's embedded workflow; the CLI prepares content and the Agent operates the browser.16- Image-first post, image note, image-text note, `newspic`, or multi-image post: use `create_image_post`, not `convert --draft`.17- Article cover or article infographic: prefer `generate_cover` or `generate_infographic` over raw `generate_image` when a bundled preset fits.18- Host-agent image generation request with no provider configured: use image plan mode (`--plan --json`) to get prompt intent, then hand it to the host image-generation tool if one is available outside md2wechat.19- WeChat title candidates for an existing article: use `title suggest <article.md> --json`; it emits a host-Agent AI request and does not choose or write the final title.20- Existing article or draft, user asks what to improve next: run `md2wechat advise <article.md> --json`; treat it as recommendation-only and keep `inspect --json data.readiness.targets/blockers` as the publish gate.21- Writing in a creator style or removing AI traces: use `write` or `humanize`.22- Provider, theme, prompt, or layout uncertainty: run discovery first. Do not guess from memory or repository files.2324Treat `convert --draft` and `create_image_post` as different publish targets, not interchangeable variants.2526## Discovery First2728Use CLI discovery as the source of truth, but keep it scoped to the next decision. Do not run the full catalog for tasks that do not need provider, theme, prompt, or layout selection.2930Use `capabilities` for aggregate routing facts, resource `list` for lightweight selection fields, `show` for one full resource definition, and `render` for materialized prompt/layout output. JSON stdout is compact; use `jq` only when a human needs formatted output.3132Run the smallest useful discovery set:3334- Article formatting with no theme or modules chosen:35 ```bash36 md2wechat themes list --json37 md2wechat layout list --json38 ```3940- A named theme, provider, prompt, or layout module:41 ```bash42 md2wechat themes show <name> --json43 md2wechat providers show <name> --json44 md2wechat prompts show <name> --kind <kind> --json45 md2wechat layout show <name> --json46 ```4748- Image generation or image-preset selection:49 ```bash50 md2wechat providers list --json51 md2wechat prompts list --kind image --json52 ```5354- Subject-reference (image-to-image) capability before using `--subject-reference`:55 ```bash56 md2wechat providers show minimax --json57 ```58 Read `supports_subject_reference` on the provider and on each entry of `supported_models`. Only the `minimax` provider and its `image-01` model accept `--subject-reference`, and the reference must be a publicly reachable `http(s)` portrait image URL; inline data URLs and local paths are rejected. Unsupported provider/model combinations fail immediately with `CONFIG_INVALID`, so do not retry them as generation failures.5960- Title suggestion prompt selection:61 ```bash62 md2wechat prompts list --kind title --json63 md2wechat prompts show wechat-title-expert --kind title --json64 ```6566- Draft, upload, API local-readiness, or configuration troubleshooting:67 ```bash68 md2wechat doctor --json69 md2wechat config show --format json70 md2wechat config wechat-accounts --json71 ```72 `doctor` readiness is local configuration attemptability. `config wechat-accounts` is local-only and never prints WeChat secrets. Use `inspect --json` for article-specific target readiness.7374- Unknown CLI version, changed behavior, or capability uncertainty:75 ```bash76 md2wechat version --json77 md2wechat capabilities --json78 md2wechat skills list --json79 md2wechat skills read md2wechat --json80 ```8182`md2wechat skills read md2wechat --json` reads the SOP embedded in the current CLI binary. Prefer it when the installed external skill, README, or repository checkout may be stale relative to the executable on `PATH`.8384For simple local actions such as `preview`, `humanize`, or a user-specified command with explicit flags, do not run unrelated provider, theme, prompt, or layout discovery.8586Inspect specific resources only when the task needs them:8788```bash89md2wechat providers show <name> --json90md2wechat themes show <name> --json91md2wechat prompts show <name> --kind <kind> --json92md2wechat layout show <name> --json93```9495Use CLI output as the source of truth for currently available modes, providers, themes, prompts, and layout modules.9697## Configuration Boundaries9899- Assume `md2wechat` is already available on `PATH`.100- `convert` defaults to API mode unless the user explicitly asks for `--mode ai`.101- API-mode preview and conversion require a valid `MD2WECHAT_API_KEY`.102- WeChat upload, article draft creation, and `create_image_post` require WeChat credentials whenever the user explicitly requests those side effects.103- Read-only discovery, `inspect`, `preview`, and plain conversion are free of any global WeChat publishing credential requirement; API-mode preview and conversion still require a valid `MD2WECHAT_API_KEY`.104- Named WeChat account execution requires a valid `MD2WECHAT_API_KEY`; the CLI validates it before upload, draft, or `create_image_post` effects.105- Direct image generation requires image-provider credentials; image plan mode (`--plan --json`) only emits prompt intent for a host Agent or external tool and does not require image-provider credentials.106- `title suggest --json` only emits a title-generation prompt request for the host Agent or external model. It does not call a model, upload, create drafts, or write back to Markdown.107- For stronger factual title hooks, pass --hook-level 2 or 3; do not treat generated titles as confirmed publishing intent.108- `doctor --json` is local-only: it checks local readiness and does not perform live authentication, upload images, or create drafts.109- Use `config show --format json` when the user asks what configuration is currently effective.110- Use `config wechat-accounts --json` when the user asks which local WeChat accounts are configured.111112## Article Workflow113114Prefer a confirm-first workflow for article work:1151161. `md2wechat inspect <article.md> --json`1172. `md2wechat preview <article.md>`1183. `md2wechat convert <article.md> ...`1194. Add `--upload`, `--draft`, `--cover`, or `--cover-media-id` only when the user explicitly asks for upload or draft creation.120121`inspect` is the source-of-truth command for structured metadata, checks, readiness targets, and blockers. In `--json` output, read `data.readiness.targets` and `data.readiness.blockers` before deciding whether `convert`, `upload`, or `draft` is blocked. If the requested target is blocked, stop and report the matching blockers; do not continue by guessing from legacy booleans or `checks` alone. Do not invent `data.agent_readiness`, `data.target_readiness`, `ArticleState`, state files, or a second readiness/state object. `preview` writes only byte-identical final API HTML from a successful converter result; with `--json`, inspect diagnostics are returned in `data.inspect` and are never wrapped into that file. It does not upload images, create drafts, or write back to Markdown. `convert` performs conversion and only the explicitly requested upload/draft effects. `convert --preview` is the convert-path preview flag and is not the same as the standalone `preview` command. On `PREVIEW_ACTION_REQUIRED` or `PREVIEW_FAILED`, this invocation does not create or overwrite preview HTML. With `--json`, `PREVIEW_ACTION_REQUIRED` returns an empty `data.output_file`. Any pre-existing explicit output path is stale and must not be treated as this invocation's result; use the returned prompt for host-Agent work or report the failure.122When the intended execution path is `convert --mode ai --custom-prompt ...`, run `inspect` with the same `--mode ai --custom-prompt ...` before trusting readiness.123124## Formatting Protocol125126When the user asks to format an article and has not chosen a theme or modules:1271281. Read the article and optional Brand Profile.1292. Use discovery output as facts.1303. Choose a compatible theme and a small set of modules from the article's content goal.1314. Keep the source Markdown read-only.1325. Create a temporary formatted Markdown artifact, for example `/tmp/md2wechat-format/<run-id>/article.formatted.md`.1336. Insert only layout modules whose required fields can be filled correctly.1347. Run `md2wechat layout validate --file <formatted.md> --json`.1358. Pass the formatted Markdown artifact to `convert`.136137Saving generated Markdown next to the source file requires explicit user confirmation and must not overwrite the source.138139## Theme Selection140141- Read `type` and `selectable` from `themes list --json`.142- API mode can use only `type: api` and `selectable: true` themes.143- AI mode can use only `type: ai` and `selectable: true` themes.144- Do not use collection descriptors such as non-selectable theme groups as concrete themes.145- If Brand Profile names a theme, verify it through CLI discovery before using it.146- If a requested theme is invalid or mode-incompatible, stop that path and choose a valid theme or ask the user.147148## Layout Modules149150Advanced layout modules render only in API mode. AI mode (`--mode ai`) does not parse `:::module` syntax, so advanced layout cards will not render there.151152Use this decision frame:153154- `attention`: help readers decide whether the article is worth reading.155- `readability`: make mobile reading easier.156- `memorability`: make one judgment, quote, metric, or brand anchor stick.157- `conversion`: help readers save, follow, inquire, share, or buy.158159Use CLI discovery as the source of truth for layout syntax instead of memorizing or guessing `body_format` values:160161- Inspect the opener, body schema, canonical executable example, and structurally distinct variants with `layout show <name> --json`. Reuse the canonical witness.162- Use `layout render` for structured fields and `--body-file` (or `--body-file -` for stdin) for complex bodies, then validate the generated Markdown.163- Default discovery returns recommended modules. Use `layout list --lifecycle compatibility --json` only for old-content migration. Local validation proves syntax acceptance only; production support is a release-conformance fact.164165Default module discipline:166167- Do not pile on modules.168- Use at most one hero, one verdict, and one cta unless the user explicitly asks for more.169- Skip modules when the article does not provide enough content to fill them honestly.170171## API And AI Mode172173- API mode is the default and is required for advanced layout modules.174- AI mode is a lighter path and does not render advanced layout modules.175- Do not silently switch from API mode to AI mode after an API failure. That changes the output capability.176- Use AI mode only when the user asks for it or accepts losing advanced layout rendering.177- If an AI-mode conversion completes, it is acceptable to briefly mention that API mode supports advanced layout modules and stronger visual structure.178179## Brand Profile180181Brand Profile lives at `~/.config/md2wechat/brand.md`.182183- It is free-form Markdown, not YAML and not a fixed schema.184- The CLI does not parse it.185- Read it as context for voice, theme preferences, module preferences, CTA preferences, and forbidden expressions.186- Treat quantity preferences as soft constraints.187- Verify any named theme or module through CLI discovery.188- If Brand Profile does not exist, do not block the task. You may mention once that system defaults will be used.189- Create or edit Brand Profile only when the user explicitly asks.190191## Publishing Side Effects192193Do not create drafts, upload images, publish, or call remote image generation unless the user asks for that action.194195Before every explicit WeChat side effect—image upload, article draft creation, or `create_image_post`—require configured WeChat credentials and use the target-matched readiness/preflight path. Discovery and inspection remain non-publishing paths; preview and plain conversion are free of any global WeChat publishing credential requirement, while API mode still requires a valid `MD2WECHAT_API_KEY`.196197Before WeChat article draft creation through `convert`:198199- Use `inspect --json` and check `data.readiness.targets.draft`; when blocked, read matching `data.readiness.blockers`.200- Draft creation requires a cover via `--cover` or `--cover-media-id`.201- Do not assume a WeChat URL or `mmbiz.qpic.cn` URL can be reused as `thumb_media_id`.202- If draft creation returns `45004`, check digest, summary, and description before assuming the body is too long.203204In the WeChat `convert` flow, Markdown images are uploaded or replaced only during `--upload` or `--draft`, not during plain conversion or preview.205206## Failure Handling207208- Missing or invalid config: run `doctor --json` and `config show --format json`; report `data.overall` plus the blocking `data.readiness.*` item.209- Invalid layout syntax: run `layout validate`, inspect the failing module with `layout show`, fix the generated artifact, then validate again.210- Unknown layout modules warn for forward compatibility; verify typos against `layout list --json`.211- Theme rejection: check `type` and `selectable`, then choose a compatible theme or ask the user.212- AI request or style-writing flows may return a prompt/request rather than final prose or HTML unless the external model step is completed.