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.
- 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.
- 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.
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
Draft, upload, API local-readiness, or configuration troubleshooting:
md2wechat doctor --json
md2wechat config show --format json
doctor readiness is local configuration attemptability. Use inspect --json for article-specific target readiness.
Unknown CLI version, changed behavior, or capability uncertainty:
md2wechat version --json
md2wechat capabilities --json
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 conversion requires md2wechat API credentials.
- WeChat draft creation requires WeChat credentials.
- Image generation may require image-provider credentials.
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.
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 resolved metadata, readiness, and publish checks. In --json output, read data.readiness.targets and data.readiness.blockers before deciding whether convert, upload, or draft is blocked. Do not invent data.agent_readiness, data.target_readiness, ArticleState, state files, or a second planning object. preview is a local preview artifact. It does not upload images, create drafts, or write back to Markdown. convert --preview is the convert-path preview flag and is not the same as the standalone preview command. preview --mode ai is degraded confirmation only and must not be treated as final AI-generated layout.
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 layout list --json and layout show <name> --json to inspect body_format. It is the module body syntax contract:
fields
rows
json_object
json_array
Do not infer syntax from examples alone. Use layout render when structured variables are enough; otherwise write the block manually according to body_format and validate the generated Markdown.
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 draft creation:
- 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.
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: md2wechat-23description: 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, AI trace removal, or current discovery of supported providers, themes, prompts, and layout modules.4---5
6# md2wechat
7
8Use 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.
9
10## Intent Routing
11
12Choose the command family before taking any publish or generation action:
13
14- Standard article HTML, article preview, metadata inspection, or WeChat article draft: use `inspect`, `preview`, and `convert`.
15- Image-first post, image note, image-text note, `newspic`, or multi-image post: use `create_image_post`, not `convert --draft`.
16- Article cover or article infographic: prefer `generate_cover` or `generate_infographic` over raw `generate_image` when a bundled preset fits.
17- Writing in a creator style or removing AI traces: use `write` or `humanize`.
18- Provider, theme, prompt, or layout uncertainty: run discovery first. Do not guess from memory or repository files.
19
20Treat `convert --draft` and `create_image_post` as different publish targets, not interchangeable variants.
21
22## Discovery First
23
24Use 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.
25
26Run the smallest useful discovery set:
27
28- Article formatting with no theme or modules chosen:
29 ```bash
30 md2wechat themes list --json
31 md2wechat layout list --json
32 ```
33
34- A named theme, provider, prompt, or layout module:
35 ```bash
36 md2wechat themes show <name> --json
37 md2wechat providers show <name> --json
38 md2wechat prompts show <name> --kind <kind> --json
39 md2wechat layout show <name> --json
40 ```
41
42- Image generation or image-preset selection:
43 ```bash
44 md2wechat providers list --json
45 md2wechat prompts list --kind image --json
46 ```
47
48- Draft, upload, API local-readiness, or configuration troubleshooting:
49 ```bash
50 md2wechat doctor --json
51 md2wechat config show --format json
52 ```
53 `doctor` readiness is local configuration attemptability. Use `inspect --json` for article-specific target readiness.
54
55- Unknown CLI version, changed behavior, or capability uncertainty:
56 ```bash
57 md2wechat version --json
58 md2wechat capabilities --json
59 ```
60
61For 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.
62
63Inspect specific resources only when the task needs them:
64
65```bash
66md2wechat providers show <name> --json
67md2wechat themes show <name> --json
68md2wechat prompts show <name> --kind <kind> --json
69md2wechat layout show <name> --json
70```
71
72Use CLI output as the source of truth for currently available modes, providers, themes, prompts, and layout modules.
73
74## Configuration Boundaries
75
76- Assume `md2wechat` is already available on `PATH`.
77- `convert` defaults to API mode unless the user explicitly asks for `--mode ai`.
78- API conversion requires md2wechat API credentials.
79- WeChat draft creation requires WeChat credentials.
80- Image generation may require image-provider credentials.
81- `doctor --json` is local-only: it checks local readiness and does not perform live authentication, upload images, or create drafts.
82- Use `config show --format json` when the user asks what configuration is currently effective.
83
84## Article Workflow
85
86Prefer a confirm-first workflow for article work:
87
881. `md2wechat inspect <article.md> --json`
892. `md2wechat preview <article.md>`
903. `md2wechat convert <article.md> ...`
914. Add `--upload`, `--draft`, `--cover`, or `--cover-media-id` only when the user explicitly asks for upload or draft creation.
92
93`inspect` is the source-of-truth command for resolved metadata, readiness, and publish checks. In `--json` output, read `data.readiness.targets` and `data.readiness.blockers` before deciding whether `convert`, `upload`, or `draft` is blocked. Do not invent `data.agent_readiness`, `data.target_readiness`, `ArticleState`, state files, or a second planning object. `preview` is a local preview artifact. It does not upload images, create drafts, or write back to Markdown. `convert --preview` is the convert-path preview flag and is not the same as the standalone `preview` command. `preview --mode ai` is degraded confirmation only and must not be treated as final AI-generated layout.
94
95## Formatting Protocol
96
97When the user asks to format an article and has not chosen a theme or modules:
98
991. Read the article and optional Brand Profile.
1002. Use discovery output as facts.
1013. Choose a compatible theme and a small set of modules from the article's content goal.
1024. Keep the source Markdown read-only.
1035. Create a temporary formatted Markdown artifact, for example `/tmp/md2wechat-format/<run-id>/article.formatted.md`.
1046. Insert only layout modules whose required fields can be filled correctly.
1057. Run `md2wechat layout validate --file <formatted.md> --json`.
1068. Pass the formatted Markdown artifact to `convert`.
107
108Saving generated Markdown next to the source file requires explicit user confirmation and must not overwrite the source.
109
110## Theme Selection
111
112- Read `type` and `selectable` from `themes list --json`.
113- API mode can use only `type: api` and `selectable: true` themes.
114- AI mode can use only `type: ai` and `selectable: true` themes.
115- Do not use collection descriptors such as non-selectable theme groups as concrete themes.
116- If Brand Profile names a theme, verify it through CLI discovery before using it.
117- If a requested theme is invalid or mode-incompatible, stop that path and choose a valid theme or ask the user.
118
119## Layout Modules
120
121Advanced layout modules render only in API mode. AI mode (`--mode ai`) does not parse `:::module` syntax, so advanced layout cards will not render there.
122
123Use this decision frame:
124
125- `attention`: help readers decide whether the article is worth reading.
126- `readability`: make mobile reading easier.
127- `memorability`: make one judgment, quote, metric, or brand anchor stick.
128- `conversion`: help readers save, follow, inquire, share, or buy.
129
130Use `layout list --json` and `layout show <name> --json` to inspect `body_format`. It is the module body syntax contract:
131
132- `fields`
133- `rows`
134- `json_object`
135- `json_array`
136
137Do not infer syntax from examples alone. Use `layout render` when structured variables are enough; otherwise write the block manually according to `body_format` and validate the generated Markdown.
138
139Default module discipline:
140
141- Do not pile on modules.
142- Use at most one hero, one verdict, and one cta unless the user explicitly asks for more.
143- Skip modules when the article does not provide enough content to fill them honestly.
144
145## API And AI Mode
146
147- API mode is the default and is required for advanced layout modules.
148- AI mode is a lighter path and does not render advanced layout modules.
149- Do not silently switch from API mode to AI mode after an API failure. That changes the output capability.
150- Use AI mode only when the user asks for it or accepts losing advanced layout rendering.
151- If an AI-mode conversion completes, it is acceptable to briefly mention that API mode supports advanced layout modules and stronger visual structure.
152
153## Brand Profile
154
155Brand Profile lives at `~/.config/md2wechat/brand.md`.
156
157- It is free-form Markdown, not YAML and not a fixed schema.
158- The CLI does not parse it.
159- Read it as context for voice, theme preferences, module preferences, CTA preferences, and forbidden expressions.
160- Treat quantity preferences as soft constraints.
161- Verify any named theme or module through CLI discovery.
162- If Brand Profile does not exist, do not block the task. You may mention once that system defaults will be used.
163- Create or edit Brand Profile only when the user explicitly asks.
164
165## Publishing Side Effects
166
167Do not create drafts, upload images, publish, or call remote image generation unless the user asks for that action.
168
169Before draft creation:
170
171- Use `inspect --json` and check `data.readiness.targets.draft`; when blocked, read matching `data.readiness.blockers`.
172- Draft creation requires a cover via `--cover` or `--cover-media-id`.
173- Do not assume a WeChat URL or `mmbiz.qpic.cn` URL can be reused as `thumb_media_id`.
174- If draft creation returns `45004`, check digest, summary, and description before assuming the body is too long.
175
176Markdown images are uploaded or replaced only during `--upload` or `--draft`, not during plain conversion or preview.
177
178## Failure Handling
179
180- Missing or invalid config: run `doctor --json` and `config show --format json`; report `data.overall` plus the blocking `data.readiness.*` item.
181- Invalid layout syntax: run `layout validate`, inspect the failing module with `layout show`, fix the generated artifact, then validate again.
182- Unknown layout modules warn for forward compatibility; verify typos against `layout list --json`.
183- Theme rejection: check `type` and `selectable`, then choose a compatible theme or ask the user.
184- AI request or style-writing flows may return a prompt/request rather than final prose or HTML unless the external model step is completed.