Sync public docs

From Caldis/react-zmage · View interactive version

Sync public docs is an AI agent skill from the GitHub repository Caldis/react-zmage. Use when modifying public API in packages/core (types/global.ts, types/default.ts, index.ts, or package.json `exports` field), adding/renaming/removing props, changing default values, before publishing a new react-zmage version, or when the user says "sync docs" / "update public docs" / "propagate t

How to use this skill

Skill file

Sync public docs (react-zmage)

Why this skill exists

The repo has four "outward-facing" documentation surfaces and only two of them are guarded automatically:

| Destination | Source of truth | Auto-guard? |

|---|---|---|

| packages/core/src/types/ | itself | — (this IS the source) |

| packages/home/src/schema/param-schema.ts | imports BaseType from react-zmage (typed) but defaults are hand-copied | ✅ types only; ❌ default values |

| packages/home/src/docs/sections/*.tsx + i18n keys | hand-written prose | ❌ |

| packages/home/src/playground/* + routes/playground/* | hand-written examples | ❌ |

| docs/llms.txt | checked-in file served as /llms.txt | ✅ static contract tests, ❌ content is still hand-written |

| packages/llms-eval/eval.test.mjs (11-item contract) | llms.txt ↔ core | ✅ but manual run only |

| README.md / AGENTS.md | hand-written | ❌ |

When core's public API changes, drift across these surfaces is silent — TS will flag a renamed type symbol but won't flag a stale default value, an outdated prop description in Props.tsx, or a removed prop still mentioned in README.md.

The cost of drift is real: README is what npm shows; llms.txt is what AI agents read; home/docs is what the live site renders. They can each go wrong independently.

When to invoke

Strong triggers (just do it):

Weak triggers (consider, then judge):

The 6-step flow

These steps are deliberately separated so each one can be paused for human review. The reason for splitting "draft" from "write" is that drafts are cheap to throw away; writes touch many files and are expensive to revert.

Step 1 — Diagnose what changed

Read the diff. List every change to public API surface, grouped by category:

Use git diff against master (the default branch is master, not main). If the user is mid-refactor and the change is uncommitted, use the working tree.

If nothing on this list moved, stop here. Tell the user the change doesn't affect public surface, no sync needed.

Step 2 — Enumerate sync destinations

For each change, identify which destinations need updating. Use this map. Each cell = "yes" unless marked –.

| Change category | home/schema (ParamDef + i18n) | home/docs/sections | home/playground | docs/llms.txt | README.md | AGENTS.md | llms-eval/eval.test.mjs |

|---|---|---|---|---|---|---|---|

| Add prop | ✓ ParamDef + i18n keys in all 7 home/src/i18n/*.ts | ✓ Props.tsx table row + Examples.tsx if non-trivial usage | ✓ ParamPanel.tsx + new control under playground/controls/ if user-tunable | ✓ API table | ✓ "API > 基础/功能/界面 Props" section + 示例 | ✓ if it changes the public-API contract | ✓ add an assertion proving the prop is documented |

| Rename prop | ✓ ParamDef name + all i18n key referrers | ✓ all sections (Props, Examples, Theming, Migration, FAQ) — grep the old name | ✓ all playground/** and routes/playground/** — grep the old name | ✓ | ✓ grep the old name everywhere | ✓ | ✓ |

| Remove prop | ✓ delete ParamDef + i18n keys | ✓ delete from Props.tsx; add entry to Migration.tsx | ✓ delete control; remove from ParamPanel.tsx | ✓ | ✓ delete + Migration note if breaking | ✓ | ✓ delete the assertion |

| Default value changed | ✓ defProp (or defPreset) hand-copy — see comment at top of param-schema.ts | ✓ Props.tsx "默认" column; Theming.tsx if it's backdrop-class; FAQ.tsx if a common-pitfall default flips | ✓ initial state in playground/seed/* (the WYSIWYG seed reflects defaults) | ✓ API table Default column | ✓ "默认" column in API tables | – usually | ✓ if there's a default-value assertion (e.g. backdrop hex) |

| Add static method on Zmage | – | ✓ ThreeModes.tsx if it's a new mode; otherwise the most relevant section | ✓ if it can be exercised from playground UI | ✓ Quick start + Choosing a usage mode | ✓ Quick Contract table + 使用 section | ✓ | ✓ runtime assertion that the static exists |

| Add subpath in exports | – | ✓ Installation.tsx and/or TypeScript.tsx | – | ✓ | ✓ Quick Contract | – usually | ✓ VALID_SUBPATHS set |

| peerDep range change | – | – | – | ✓ "Supports React X through Y" line | ✓ "React 版本兼容" table + badge | – | ✓ peer-range assertion bounds |

| Behavior/visual change (no API change) | – | ✓ Theming.tsx / FAQ.tsx if user-visible; Migration.tsx if behaviorally breaking | ✓ playground hint copy if behavior was demoed there | – usually | – usually | – | – |

Multi-language parity (hard rule, not optional)

Any prose change in home/src/docs/sections/*.tsx or any user-visible label in home/src/playground/ MUST land in all 7 home/src/i18n/*.ts files: en, de, es, fr, ja, ko, zh-CN. Divergent key sets break useT() lookups silently — there is no compiler error for a missing key. Untranslated entries may use the English source verbatim as a placeholder (better) or omit the value (worse, but acceptable temporarily) — but the key itself must exist in every file.

Verify before committing:

for lang in en de es fr ja ko zh-CN; do
  count=$(grep -cE "^[[:space:]]+'[^']+':" "packages/home/src/i18n/$lang.ts")
  echo "$lang: $count keys"
done

All 7 numbers must match. If they diverge, find the missing key with diff <(grep ... en.ts) <(grep ... <other>.ts) and add the placeholder.

Other edge cases

Step 3 — Draft the patches

Write out — in your reply, not yet on disk — the exact intended diff for each destination. This is the human review checkpoint: it's much cheaper to revise prose at this stage than to revise after files are written.

Keep drafts terse: file path + before/after snippet, not full file content. The user should be able to skim and approve in one read.

If a destination needs more than ~30 lines of prose, flag it as "needs careful writing" rather than rushing through it.

Step 4 — Dispatch parallel write subagents

Once drafts are approved, write the changes. Prefer parallelism — most destinations are independent.

Group rules:

Dispatch one Agent per destination in Group A in a single tool-call message; do docs/llms.txt separately. Each subagent's prompt should include:

Step 5 — Re-eval the result

Two evaluation layers, both in packages/llms-eval/:

Static contract (always run after docs/llms.txt changes):

pnpm --filter llms-eval run test

This is the 11-item check that llms.txt's factual claims match core's reality. If any assertion fails, the sync is incomplete — go back to Step 3 for the affected destination.

Behavioral eval (run when public surface changed materially — new modes, props, subpaths, or anything an AI integrator would notice):

  1. Delete packages/llms-eval/agent-onboarding/output/ and report.json from the previous run.
  2. Dispatch a fresh subagent with the brief at packages/llms-eval/agent-onboarding/prompt.md. The subagent must obey the META section's information-source constraints (only the deployed llms.txt URL, fall back to local docs/llms.txt if WebFetch fails, no other repo files, no GitHub).
  3. Run node packages/llms-eval/agent-onboarding/rubric.mjs to score the output (target ≥ 90/100).
  4. Read packages/llms-eval/agent-onboarding/output/SELF_CRITIQUE.md — this is the qualitative signal (rubric-100 doesn't mean docs are good; SELF_CRITIQUE shows what the integrator had to guess).

Skip the behavioral eval for tiny changes (e.g., a typo fix, a peerDep bump from <20 to <21); the static contract suffices.

Step 6 — Main-agent synthesis

Compile a final report for the user with:

If anything is red, recommend a specific next action — don't just list problems.

Final checklist

Before claiming sync is done:

Anti-patterns

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.