.claude/skills/registry-system/SKILL.md
Auto-generated registry system for this Next.js application. Covers Data-Only pattern, zero dynamic imports policy, registry structure, and rebuild process. Use this skill when working with registries or understanding import patterns.
npx skillsauth add NextSpark-js/nextspark registry-systemInstall 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.
Patterns for working with the auto-generated registry system that provides O(1) lookups for blocks, entities, themes, and more.
REGISTRY SYSTEM (Pre-built at build time):
core/lib/registries/
├── block-registry.ts # BLOCK_REGISTRY - Page builder blocks
├── entity-registry.ts # ENTITY_REGISTRY - Entity configurations
├── entity-registry.client.ts # Client-safe entity registry
├── theme-registry.ts # THEME_REGISTRY - Theme configurations
├── plugin-registry.ts # PLUGIN_REGISTRY - Plugin configurations
├── namespace-registry.ts # NAMESPACE_REGISTRY - Route namespaces
├── scope-registry.ts # SCOPE_REGISTRY - API scopes
├── route-handlers.ts # ROUTE_HANDLERS - API route handlers
├── middleware-registry.ts # MIDDLEWARE_REGISTRY - Middleware configs
├── permissions-registry.ts # PERMISSIONS_REGISTRY - Permission matrix
├── billing-registry.ts # BILLING_REGISTRY - Plans and billing
├── translation-registry.ts # TRANSLATION_REGISTRY - i18n configs
├── testing-registry.ts # TESTING_REGISTRY - Test fixtures
├── docs-registry.ts # DOCS_REGISTRY - Documentation index
└── index.ts # Unified exports
Build script: node core/scripts/build/registry.mjs
📍 Context-Aware Paths: Registries are auto-generated from core + theme. In consumer projects, theme configs go in
contents/themes/{theme}/config/. Core registries are read-only. Seecore-theme-responsibilitiesskill for complete rules.
Registries = Data (pre-computed, static)
Services = Logic (methods that use registries)
Registries provide:
Services provide:
| Approach | Time | Notes | |----------|------|-------| | Dynamic Import | ~140ms | Per operation, I/O bound | | Static Registry | ~6ms | O(1) lookup | | Improvement | ~17,255x | Build-time vs runtime |
// ✅ CORRECT - Import from registries
import { BLOCK_REGISTRY } from '@/core/lib/registries/block-registry'
import { ENTITY_REGISTRY } from '@/core/lib/registries/entity-registry'
import { THEME_REGISTRY } from '@/core/lib/registries/theme-registry'
// Access by key
const heroBlock = BLOCK_REGISTRY['hero']
const customerEntity = ENTITY_REGISTRY['customers']
// ✅ CORRECT - Use services for logic
import { BlockService } from '@/core/lib/services/block.service'
import { EntityTypeService } from '@/core/lib/services/entity-type.service'
const heroConfig = BlockService.getBySlug('hero')
const allEntities = EntityTypeService.getAll()
// ❌ FORBIDDEN - Direct imports from @/contents
import { hero } from '@/contents/themes/default/blocks/hero'
import { customerEntityConfig } from '@/contents/themes/default/entities/customers'
import * as theme from '@/contents/themes/default'
// ❌ FORBIDDEN - Dynamic imports from @/contents
const module = await import('@/contents/themes/default/blocks/hero')
const config = await import(`@/contents/themes/${themeName}/config`)
// ❌ FORBIDDEN - Dynamic registry imports
const { ENTITY_REGISTRY } = await import('@/core/lib/registries/entity-registry')
| Registry | Key Type | Value Type | Purpose |
|----------|----------|------------|---------|
| BLOCK_REGISTRY | slug | BlockConfig | Page builder blocks |
| ENTITY_REGISTRY | slug | EntityRegistryEntry | Entity configurations |
| THEME_REGISTRY | name | ThemeConfig | Theme settings |
| PLUGIN_REGISTRY | name | PluginConfig | Plugin configurations |
| NAMESPACE_REGISTRY | namespace | NamespaceConfig | Route namespaces |
| SCOPE_REGISTRY | scope | ScopeConfig | API permission scopes |
| PERMISSIONS_REGISTRY | permission | PermissionConfig | Permission definitions |
| BILLING_REGISTRY | planSlug | PlanConfig | Billing plans |
| MIDDLEWARE_REGISTRY | name | MiddlewareConfig | Route middlewares |
| ROUTE_HANDLERS | path | RouteHandler | API route handlers |
/**
* Auto-generated Entity Registry
* Generated at: 2025-12-30T21:56:23.717Z
* Entities discovered: 4
* DO NOT EDIT - This file is auto-generated by scripts/build-registry.mjs
*/
// 1. Static imports (generated)
import { customerEntityConfig } from '@/contents/themes/default/entities/customers/customers.config'
import { taskEntityConfig } from '@/contents/themes/default/entities/tasks/tasks.config'
// 2. TypeScript interface
export interface EntityRegistryEntry {
name: string
config: EntityConfig
tableName?: string
relativePath: string
depth: number
parent: string | null
children: string[]
source: 'core' | 'theme' | 'plugin'
}
// 3. Main registry object
export const ENTITY_REGISTRY: Record<string, EntityRegistryEntry> = {
'customers': {
name: 'customers',
config: customerEntityConfig,
tableName: 'customers',
relativePath: 'customers',
depth: 0,
parent: null,
children: [],
source: 'theme'
},
// ... more entries
}
// 4. Type export
export type EntityName = keyof typeof ENTITY_REGISTRY
// 5. Metadata
export const ENTITY_METADATA = {
totalEntities: 4,
generatedAt: '2025-12-30T21:56:23.717Z',
entities: ['customers', 'pages', 'posts', 'tasks']
}
# One-time build (default)
node core/scripts/build/registry.mjs
# Watch mode (auto-rebuild on changes)
node core/scripts/build/registry.mjs --watch
# Build with verbose output
node core/scripts/build/registry.mjs --verbose
When to rebuild:
const messages = await import(`@/core/messages/${locale}/${namespace}.json`)
const HeavyChart = lazy(() => import('./HeavyChart'))
export type Messages = typeof import('./es/index.ts').default
// core/scripts/build-theme.ts
const config = await import(`./${themeName}/theme.config`)
if (process.env.NODE_ENV === 'development') {
const benchmark = await import('./dev-tools/benchmark')
}
export async function extractTextFromPDF(file: File) {
const pdfjsLib = await import('pdfjs-dist') // ~2MB, only when needed
}
import { BlockService } from '@/core/lib/services/block.service'
// Get block by slug
const hero = BlockService.getBySlug('hero')
// Get all blocks
const blocks = BlockService.getAll()
// Get blocks by category
const heroBlocks = BlockService.getByCategory('hero')
// Get blocks by scope
const pageBlocks = BlockService.getByScope('pages')
import { EntityTypeService } from '@/core/lib/services/entity-type.service'
// Get entity config
const customerConfig = EntityTypeService.getBySlug('customers')
// Get all entities
const entities = EntityTypeService.getAll()
// Check if entity exists
const exists = EntityTypeService.exists('customers')
// NEVER: Import directly from contents
import { hero } from '@/contents/themes/default/blocks/hero'
// CORRECT: Use registry
import { BLOCK_REGISTRY } from '@/core/lib/registries/block-registry'
const hero = BLOCK_REGISTRY['hero']
// NEVER: Dynamic import from contents
const block = await import(`@/contents/themes/${theme}/blocks/${slug}`)
// CORRECT: Use service
import { BlockService } from '@/core/lib/services/block.service'
const block = BlockService.getBySlug(slug)
// NEVER: Modify registry files manually
// Registry files have "DO NOT EDIT" header
// CORRECT: Modify source files and rebuild
// node core/scripts/build/registry.mjs
// NEVER: Store logic in registries
export const ENTITY_REGISTRY = {
customers: {
validate: (data) => { ... } // Logic doesn't belong here!
}
}
// CORRECT: Logic goes in services
export class CustomerService {
static validate(data: CreateCustomer) { ... }
}
Before working with registries:
@/core/lib/registries/ not @/contents/node core/scripts/build/registry.mjs)ENTITY_REGISTRY['customers'])monorepo-architecture - Package hierarchy, dependency rules, Model B distributionentity-system - Entity configuration patternspage-builder-blocks - Block configuration patternsservice-layer - Service patterns with registriesdevelopment
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.