zudo-doc
GitHub repository

Type to search...

to open search from anywhere

/packages/create-zudo-doc/CLAUDE.md

CLAUDE.md at /packages/create-zudo-doc/CLAUDE.md

Path: packages/create-zudo-doc/CLAUDE.md

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:

  1. Copy a minimal base template (templates/base/) — core files with injection anchors
  2. Generate astro.config.ts, content.config.ts, settings.ts, package.json programmatically
  3. Compose selected features — copy feature files + inject code into shared files at anchor points
  4. 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

FileRole
src/scaffold.tsOrchestrates the scaffold pipeline: copy base, generate configs, compose features
src/compose.tsComposition engine: injection system, anchor cleanup, feature resolution
src/features/*.tsFeature modules defining injections for each optional feature (10 modules)
src/astro-config-gen.tsProgrammatic astro.config.ts generator (conditional imports/integrations)
src/content-config-gen.tsProgrammatic content.config.ts generator (locale/version collections)
src/settings-gen.tsGenerates src/config/settings.ts with user-chosen options
src/constants.tsFeature definitions, color scheme lists, light-dark pairings
src/utils.tsShared utilities (patchFile, patchDefaultLang, getSecondaryLang)
src/cli.tsCLI argument parsing (commander)
src/api.tsProgrammatic API (createZudoDoc())
src/prompts.tsInteractive prompts (inquirer)
src/index.tsEntry point

Template Directories

DirectoryRole
templates/base/Minimal project with injection anchors (73 files, no optional feature code)
templates/features/*/files/Feature-specific files copied when a feature is selected

Injection Anchors

Shared files in templates/base/ have anchor comments where features inject code:

  • src/layouts/doc-layout.astro — 16 anchors (imports, head scripts, sidebar, breadcrumb, footer, body-end)
  • src/components/header.astro — 4 anchors (imports, actions, after-theme-toggle)
  • src/styles/global.css — 2 anchors (theme tokens, feature styles)

Testing

Unit tests

pnpm test

Runs vitest tests in src/__tests__/.

Generator CLI integration tests

Two Claude Code skills test the full scaffold-build-run cycle:

  • /l-generator-cli-tester <pattern> — Test a single generation pattern
  • /l-run-generator-cli-whole-test — Run all 9 patterns, fix bugs, verify everything

Test patterns

PatternDescription
bareboneEverything OFF — minimal project
searchOnly search enabled
i18nOnly i18n enabled
sidebar-filterOnly sidebar filter enabled
claude-resourcesOnly Claude Resources enabled
design-token-panelOnly design token panel enabled (API only, no CLI flag)
light-darkLight-dark color scheme mode
lang-jaJapanese as default language
all-featuresEverything ON

Always rebuild the CLI before testing:

pnpm build

Adding a New Feature

When adding a feature to the main zudo-doc project that the generator should support:

  1. src/constants.ts — Add feature to FEATURES array if it needs a CLI flag
  2. src/features/<name>.ts — Create a feature module defining injections for shared files
  3. src/features/index.ts — Register the feature module
  4. templates/features/<name>/files/ — Add feature-specific files to copy
  5. src/scaffold.ts — Add dependencies in generatePackageJson() if needed
  6. src/astro-config-gen.ts — Add conditional imports/integrations if the feature affects astro.config.ts
  7. src/content-config-gen.ts — Add collections if the feature affects content config
  8. src/settings-gen.ts — Add the setting field to generated settings.ts
  9. src/__tests__/scaffold.test.ts — Update tests

After changes, run /l-update-generator to verify no drift remains between the main project and the generator.

Revision History

AI Assistant

Ask a question about the documentation.