creating-modules

Creates new modules within existing packages following project conventions. Handles file structure, barrel exports, namespace files, package.json imports/exports, and internal import patterns.

⭐4stars🔀0forks📁View on GitHub🕐Updated Dec 22, 2025⬇️1downloads

When & Why to Use This Skill

This Claude skill automates the end-to-end creation of new modules within existing packages, ensuring strict adherence to project-specific conventions. It streamlines the development workflow by handling complex scaffolding tasks, including directory setup, implementation files, barrel exports, and namespace definitions, while automatically managing package.json configurations and internal import patterns.

Use Cases

  • Rapid Feature Scaffolding: Instantly generate standardized directory structures and boilerplate files for new components or features in a TypeScript/Node.js environment.
  • Automated Configuration Management: Eliminate manual errors by automatically updating package.json 'imports' and 'exports' fields to support modern subpath patterns.
  • Consistency Enforcement: Ensure all team members follow uniform naming conventions (kebab-case for directories, PascalCase for namespaces) and export structures across a large codebase.
  • Monorepo Optimization: Simplify the process of adding and linking sub-modules within complex package structures while maintaining clean internal reference patterns using '#' imports.
namecreating-modules
descriptionCreates new modules within existing packages following project conventions. Handles file structure, barrel exports, namespace files, package.json imports/exports, and internal import patterns.

Creating Modules

Steps

  1. Create module directory: packages/<pkg>/src/<module-name>/

  2. Create implementation files: <module-name>.ts or split across multiple files

  3. Create barrel file __.ts:

    export * from './implementation.js'
    export type * from './types.js'
    
  4. Create namespace file _.ts:

    export * as ModuleName from './__.js'
    
  5. Add to package.json imports:

    {
      "imports": {
        "#module-name": "./build/module-name/_.js",
        "#module-name/*": "./build/module-name/*.js"
      }
    }
    
  6. Add to package.json exports:

    {
      "exports": {
        "./module-name": "./build/module-name/__.js"
      }
    }
    
  7. Sync tsconfig paths (run syncing-tsconfig-paths skill script)

  8. Add to main exports in src/index.ts:

    export * from '#module-name'
    

Reference

Module Structure

src/module-name/
├── _.ts              # Namespace file - exports the namespace
├── _.test.ts         # Module tests
├── __.ts             # Barrel file - exports all functions/types
└── *.ts              # Implementation files

Import System

Use # imports for internal module references within a package:

// Correct - use # imports
import { Fn } from '#fn'
import { Obj } from '#obj'

// Incorrect - don't use relative or package imports internally
import { Fn } from '../fn/_.js'
import { Obj } from '@kitz/core/obj'

Naming

  • Directory: kebab-case (group-by/)
  • Namespace export: PascalCase (GroupBy)
  • Functions: camelCase, no namespace prefix (by, not groupBy)

Notes

  • Each package defines its own # imports in package.json
  • Cross-package # imports are not valid - use package name imports