.claude/skills/monorepo-architecture/SKILL.md
# NextSpark Monorepo Architecture ## Overview NextSpark uses a pnpm monorepo with strict separation of concerns between packages. ## Directory Structure ``` repo/ ├── packages/ │ ├── core/ # @nextsparkjs/core - Library only (no CLI) │ ├── cli/ # @nextsparkjs/cli - All CLI commands, wizard │ └── create-nextspark-app/ # Wrapper that installs CLI + runs init ├── themes/ │ ├── default/ # @nextsparkjs/theme-default │ ├── blog/ # @nextsparkjs/theme-
npx skillsauth add NextSpark-js/nextspark .claude/skills/monorepo-architectureInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
NextSpark uses a pnpm monorepo with strict separation of concerns between packages.
repo/
├── packages/
│ ├── core/ # @nextsparkjs/core - Library only (no CLI)
│ ├── cli/ # @nextsparkjs/cli - All CLI commands, wizard
│ └── create-nextspark-app/ # Wrapper that installs CLI + runs init
├── themes/
│ ├── default/ # @nextsparkjs/theme-default
│ ├── blog/ # @nextsparkjs/theme-blog
│ ├── crm/ # @nextsparkjs/theme-crm
│ └── productivity/ # @nextsparkjs/theme-productivity
├── plugins/
│ ├── ai/ # @nextsparkjs/plugin-ai
│ ├── langchain/ # @nextsparkjs/plugin-langchain
│ ├── walkme/ # @nextsparkjs/plugin-walkme
│ └── ...
└── apps/
└── dev/ # Development app (monorepo only)
┌─────────────────────────────────────────────────────────────────┐
│ User Project (npm install) │
│ └── @nextsparkjs/cli (has wizard, commands) │
│ └── @nextsparkjs/core (library, components, hooks) │
├─────────────────────────────────────────────────────────────────┤
│ Themes depend on: @nextsparkjs/core (peerDependency) │
│ Plugins depend on: @nextsparkjs/core (peerDependency) │
└─────────────────────────────────────────────────────────────────┘
Is this dependency...?
│
├── Framework/platform shared by all (react, next, zod)?
│ └── YES → peerDependency
│
├── Core library that user's project controls (@nextsparkjs/core)?
│ └── YES → peerDependency (workspace:* in monorepo)
│
├── Something specific to this theme/plugin that users don't manage?
│ └── YES → dependencies (regular)
│
└── Already provided by core (next-themes, lucide-react, etc)?
└── YES → DO NOT ADD - import from core instead
CORRECT - Theme package.json:
{
"dependencies": {
"some-markdown-library": "^1.0.0" // Theme-specific, users don't care
},
"peerDependencies": {
"@nextsparkjs/core": "workspace:*", // Framework
"next": "^15.0.0", // Platform
"react": "^19.0.0", // Platform
"react-dom": "^19.0.0", // Platform
"zod": "^4.0.0" // Shared utility
}
}
INCORRECT:
{
"peerDependencies": {
"next-themes": "^0.4.0" // WRONG! Core already has this
}
}
When set, the registry build filters to only include:
requiredPlugins in theme config)# Only includes blog theme and its plugins
NEXT_PUBLIC_ACTIVE_THEME=blog pnpm build
# Without this, ALL themes/plugins are included (development mode)
pnpm build
discoverThemes() - Only discovers active theme when env is setdiscoverPlugins() - Already scoped, but route-handlers filters furthergenerateRouteHandlersRegistry() - Filters based on theme's plugins array// In route-handlers.mjs
if (config.activeTheme) {
filteredThemes = themes.filter(t => t.name === config.activeTheme)
// Get required plugins from theme's plugins array
const activeTheme = filteredThemes[0]
if (activeTheme?.plugins?.length > 0) {
requiredPluginNames = activeTheme.plugins.map(p =>
p.replace('@nextsparkjs/plugin-', '')
)
filteredPlugins = plugins.filter(p => requiredPluginNames.includes(p.name))
} else {
filteredPlugins = []
}
}
Before next build, registries must be regenerated:
# Regenerate with active theme filtering
NEXT_PUBLIC_ACTIVE_THEME=blog node packages/core/scripts/build/registry.mjs
# Then build
NEXT_PUBLIC_ACTIVE_THEME=blog pnpm build
The registries are written to: apps/dev/.nextspark/registries/
| Package Type | Version Pattern | Notes | |-------------|-----------------|-------| | Core packages | 0.1.0-beta.X | Increment X for each release | | Themes | 0.1.0-beta.1 | Start at beta.1, match when stable | | Plugins | 0.1.0-beta.1 | Start at beta.1, match when stable |
development
Zod validation patterns for this Next.js application. Covers schema definition, API validation, form integration, error formatting, and type inference. Use this skill when implementing validation for APIs, forms, or entity schemas.
development
Review UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "check accessibility", "audit design", "review UX", or "check my site against best practices".
testing
Test coverage metrics and registry system for this Next.js application. Covers FEATURE_REGISTRY, FLOW_REGISTRY, TAGS_REGISTRY, and coverage metrics interpretation. Use this skill when evaluating test coverage, identifying gaps, or planning testing priorities.
development
TanStack Query (React Query) patterns for data fetching in this Next.js application. Covers useQuery, useMutation, optimistic updates, cache invalidation, and anti-patterns. Use this skill when implementing data fetching or state management with server data.