Scaffold a New Module
You are generating a new module under src/ that fully complies with the mission-critical coding standard.
Module name
The module name is: $ARGUMENTS
Instructions
Parse the module name — The name should be in
kebab-case. Convert toPascalCasefor type names andcamelCasefor variable names. For example:user-profile→ types:UserProfile, variables:userProfile, directory:src/user-profile/
Check for conflicts — Verify
src/${MODULE_NAME}/does not already exist. If it does, ask the user whether to overwrite or abort.Load the coding standard (optional reference) — Check if
.claude/docs/TypeScript Coding Standard for Mission-Critical Systems.mdexists. Use it as context for generating compliant code.Ask the user about the module — Gather:
- What does this module do? (brief description)
- What are the key domain types? (e.g., "User has id, email, name" or "Payment has amount, currency, status")
- What are the main operations? (e.g., "create, validate, process")
Read the templates — Read the following templates from
.claude/skills/scaffold-module/templates/:module.ts.template— Main module logicmodule.test.ts.template— Test filemodule.schema.ts.template— Zod schemas and branded types
Generate the module files — Create the following files, using the templates as structural guides but filling in actual domain-specific code based on the user's answers:
src/${MODULE_NAME}/schema.tsBased on
module.schema.ts.template:- Zod schemas for all domain types (Rule 7.2)
- Branded types for domain primitives (Rule 7.3)
- Factory functions returning
Result<T>(Rule 6.2) - All types exported with
readonlyproperties (Rule 7.1)
src/${MODULE_NAME}/${MODULE_NAME}.tsBased on
module.ts.template:- Import types and schemas from
./schema.js - Import
Resulttype from../utils/result.js - All functions return
Result<T>for fallible operations (Rule 6.2) - Functions ≤ 40 lines, ≤ 4 parameters (Rule 8.4)
readonlyon all data (Rule 7.1)- Exhaustive switch with
assertUnreachablefor any unions (Rule 8.3) - TSDoc on all public functions (Rule 10.1)
- No
any, noenum, novar, no recursion
src/${MODULE_NAME}/${MODULE_NAME}.test.tsBased on
module.test.ts.template:- Import from the module under test
- Unit tests for every exported function
- Edge cases: empty input, null/undefined, boundary values (Rule 9.1)
- Property-based tests with
fast-checkfor data transformation functions (Rule 9.1) - Test both success and error paths of Result-returning functions
- Use
describe/itblocks with descriptive names
src/${MODULE_NAME}/index.tsBarrel export re-exporting public types and functions from the module files.
Update parent barrel export — If
src/index.tsexists, appendexport * from './${MODULE_NAME}/index.js';. If it doesn't exist, create it.Summary — List all created files and suggest the user run tests with
npm test.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.