/packages/create-zudo-doc/CLAUDE.md
CLAUDE.md at /packages/create-zudo-doc/CLAUDE.md
Path: packages/
create-zudo-doc
CLI scaffold tool for creating new zudo-doc documentation sites. Generates a project with configurable features, color schemes, and i18n support.
Architecture
The generator uses an additive composition approach:
Copy a minimal base template (
templates/base/) — core files with injection anchorsGenerate
zfb.config.ts,settings.ts,package.jsonprogrammaticallyCompose selected features — copy feature files + inject code into shared files at anchor points
Clean up unused anchors
This replaces the old "copy everything then strip" approach. Features are added, not removed — so dead code cannot remain.
Key Files
| File | Role |
|---|---|
src/ | Orchestrates the scaffold pipeline: copy base, generate configs, compose features |
src/ | Composition engine: injection system, anchor cleanup, feature resolution |
src/features/*.ts | Feature modules defining injections for each optional feature (15 modules) |
src/ | Programmatic zfb.config.ts generator — S5b: now emits a thin preset-based config that spreads zudoDocPreset() from @takazudo/; feature-agnostic (same output for all feature combinations) |
src/ | Generates src/ with user-chosen options |
src/ | Generates the per-project CLAUDE.md for the scaffolded site |
src/ | Resolves the user-chosen preset into a concrete feature set |
src/ | Feature definitions, color scheme lists, light-dark pairings |
src/ | Shared utilities (patchFile, patchDefaultLang, getSecondaryLang) |
src/ | CLI argument parsing (commander) |
src/ | Programmatic API (createZudoDoc()) |
src/ | Interactive prompts (inquirer) |
src/ | Entry point |
Template Directories
| Directory | Role |
|---|---|
templates/base/ | Minimal project with injection anchors (post-cutover: only .tsx, .ts, .css, .json — no .astro) |
templates/features/*/files/ | Feature-specific files copied when a feature is selected |
Injection Anchors
The files shipped with anchors in templates/base/ today are:
src/— 3 anchors (styles/ global. css @slot:global-css:imports,@slot:global-css:theme-tokens,@slot:global-css:feature-styles)pages/— anchors consumed by the imageEnlarge feature_ mdx- components. ts pages/— anchors consumed by the tauri and designTokenPanel featureslib/ _ body- end- islands. tsx src/— replace-range anchors (config/ settings- types. ts @slot:settings-types:trigger-names:start/:end) consumed by the designTokenPanel feature to inject"design-token-panel"intoHeaderRightTriggerName
The ANCHOR_FILES list in src/ is the source of truth for which files are anchor-cleaned after composition. Feature-specific files are copied wholesale from templates/features/<name>/files/; no anchor injection into doc-layout/header is required post-zfb-cutover.
src/ ANCHOR_LINE_RE accepts JSX-comment ({/* @slot:… */}), block-comment, line-comment, HTML-comment, and shell-comment forms so anchors work across .tsx, .ts, and .css.
Testing
Unit tests
pnpm testRuns vitest tests in src/__tests__/.
Generator CLI integration tests
Two Claude Code skills test the full scaffold-build-run cycle:
/— Test a single generation patternl- generator- cli- tester <pattern> /— Run all 9 patterns, fix bugs, verify everythingl- run- generator- cli- whole- test
Test patterns
| Pattern | Description |
|---|---|
barebone | Everything OFF — minimal project |
search | Only search enabled |
i18n | Only i18n enabled |
sidebar-filter | Only sidebar filter enabled |
claude-resources | Only Claude Resources enabled |
design-token-panel | Only design token panel enabled (API only, no CLI flag) |
light-dark | Light-dark color scheme mode |
lang-ja | Japanese as default language |
all-features | Everything ON |
Always rebuild the CLI before testing:
pnpm buildAdding a New Feature
When adding a feature to the main zudo-doc project that the generator should support:
src/— Add feature toconstants. ts FEATURESarray if it needs a CLI flagsrc/features/<name>.ts— Create a feature module defining injections for shared filessrc/— Register the feature modulefeatures/ index. ts templates/features/<name>/files/— Add feature-specific files to copy (use.tsxfor components,.tsfor utilities — no.astro)src/— Add dependencies inscaffold. ts generatePackageJson()if neededpackages/— If the feature introduces a new plugin or collection, add the settings-driven logic tozudo- doc/ src/ preset. ts zudoDocPreset(). The generatedzfb.config.tsis a thin preset-based file (S5b #2329) — it does NOT need updating for features that are settings-driven (the preset reads the newsettings.*field directly). Only updatesrc/if the generated config shape itself must change (rare).zfb- config- gen. ts src/— Add the setting field to generatedsettings- gen. ts settings.tssrc/— Update tests_ _ tests_ _ / scaffold. test. ts
After changes, run / to verify no drift remains between the main project and the generator.