@solid-stack/create
v1.0.7
Published
An interactive, type-safe CLI generator for scaffolding Solid Stack Clean Architecture features, usecases, domain entities, infrastructure, interfaces, httpHandlers, and injectables.
Readme
@solid-stack/create
An interactive, type-safe CLI for scaffolding and bootstrapping everything in the Solid Stack Clean Architecture ecosystem. Built with TypeScript, tsup, cac, and @clack/prompts.
🏗️ Clean Architecture Principles
@solid-stack/create enforces the architectural conventions of Solid Stack services (@solid-stack/agnos, @solid-stack/agnos-express, and @solid-stack/di):
features/<feature>/
├── domain/ # Zero DI dependencies! Pure interfaces & entities
│ ├── <Entity>.ts # Domain entity model / value object
│ └── I<Entity>Repository.ts # Domain repository / service abstract class (DI token & type)
├── infrastructure/ # Implementations of domain interfaces (@MakeInjectable)
│ └── Stub<Entity>Repository.ts # In-memory stub with test helpers (clear, setError, etc.)
├── useCases/ # Business logic (@MakeInjectable)
│ ├── <UseCase>.ts # Use case class with typed input/output DTOs & execute()
│ └── <UseCase>.test.ts # Vitest unit test with DI container & mock stubs
├── pxExpress/ # Express presentation layer (@solid-stack/agnos-express)
│ ├── index.ts # Route prefix (export const path = "/<feature>")
│ └── handlers/ # Route handlers extending ExpressRoute
│ └── <Handler>Http.ts # HTTP endpoint with @MakeInjectable & Zod validation
└── diProvider.ts # Feature DI module registering domain interface -> infrastructure bindings🚀 Installation & Quick Start
Run interactively via npx or pnpm dlx:
# Launch interactive wizard
npx @solid-stack/create
# Or run specific commands directly
npx @solid-stack/create feature users
npx @solid-stack/create usecase CreateUser -f users
npx @solid-stack/create domain User -f users
npx @solid-stack/create infrastructure StubUserRepository -f users
npx @solid-stack/create interface IUserRepository -f users
npx @solid-stack/create httpHandler CreateUserHttp -f users
npx @solid-stack/create injectable PasswordHasher🛠️ Commands Reference
1. @solid-stack/create feature [name]
Scaffolds a complete Clean Architecture vertical slice with domain models, interface abstract classes, infrastructure stubs, use cases, Express presentation routes, and a feature DI provider.
# Interactive prompt for feature details
npx @solid-stack/create feature
# Specify feature name directly
npx @solid-stack/create feature billing
# Non-interactive mode with default choices
npx @solid-stack/create feature orders --yes
# Exclude Express presentation layer
npx @solid-stack/create feature auth --no-expressPrompts:
- Feature name (e.g.
users,auth,billing) - Target directory (defaults to
./features/<feature>) - Include Express presentation (
pxExpress) and route prefix path - Include initial Domain Entity
- Include initial Domain Interface
- Include initial Infrastructure Stub
- Include initial Use Case and Vitest test
- Include feature DI Provider (
diProvider.ts)
2. @solid-stack/create usecase [name]
Creates a business logic use case decorated with @MakeInjectable, typed input/output DTOs, constructor dependency injection via DepsType, and optional Vitest tests and HTTP route handlers.
npx @solid-stack/create usecase CreateUser -f usersPrompts:
- Target feature (scans existing features under
./features/) - Use Case name (e.g.
CreateUser,GetUser,CancelOrder) - Injected dependencies (scans existing domain interfaces
I*.tsfor multi-selection) - Input DTO properties
- Output DTO properties
- Generate Vitest unit test (
<UseCase>.test.ts) - Generate matching Express HTTP handler in
pxExpress/handlers/
3. @solid-stack/create domain [name]
Creates a domain entity, model, or value object. Enforces the strict rule: zero DI dependence (@solid-stack/di or @MakeInjectable are never imported into domain entities).
npx @solid-stack/create domain User -f usersPrompts:
- Target feature
- Model name (e.g.
User,Invoice,CartItem) - Model type:
TypeScript Interface: Lightweight data structureEntity Class: Class with constructor and typed propertiesValue Object: Immutable class with private constructor, staticcreate(), andequals()
- Interactive property definitions (name, type, optional)
4. @solid-stack/create interface [name]
Creates a domain repository or service interface abstract class. In Solid Stack, abstract classes are preferred over plain interfaces because they exist at runtime and serve directly as type-safe DI tokens.
npx @solid-stack/create interface IUserRepository -f usersPrompts:
- Target feature
- Interface name (automatically formats to
I<Name>RepositoryorI<Name>Service) - Style: Abstract Class (recommended for DI) or TypeScript Interface
- Associated domain entity (scans existing entities in
domain/) - Method signature preset (Standard CRUD or custom)
- Auto-generate infrastructure Stub (
Stub<Name>) - Auto-register binding in
diProvider.ts
5. @solid-stack/create infrastructure [name]
Creates an infrastructure adapter or in-memory stub implementing a domain interface.
# In-memory stub with test helpers
npx @solid-stack/create infrastructure StubUserRepository -f users
# Concrete production adapter
npx @solid-stack/create infrastructure PostgresUserRepository -f users
# Global infrastructure (e.g. ConsoleLogger in infrastructure/)
npx @solid-stack/create infrastructure ConsoleLogger --globalPrompts:
- Scope: Feature-level (
features/<feature>/infrastructure) or Global (infrastructure/) - Target feature
- Class name (e.g.
StubUserRepository,PostgresUserRepository) - Implemented domain interface (scans
domain/I*.ts) - Kind: In-Memory Stub (with in-memory Map, test helper methods
clear(),setError(),getAll()) or Concrete Adapter Skeleton - Auto-register in feature
diProvider.ts
6. @solid-stack/create httpHandler [name]
Creates an Express route handler extending ExpressRoute for @solid-stack/agnos-express, decorated with @MakeInjectable and exported as default. Automatically creates pxExpress/index.ts route prefix if missing.
npx @solid-stack/create httpHandler GetUserHttp -f users -m get -p /:idPrompts:
- Target feature
- Handler class name (e.g.
CreateUserHttp,GetUserHttp) - HTTP method:
GET,POST,PUT,PATCH,DELETE - Route subpath (e.g.
/,/:id) - Connect to domain Use Case (scans existing use cases in the feature)
- Inbound validation with Zod (
req.body,req.query, orreq.params) - Schema field definitions
7. @solid-stack/create injectable [name]
Creates a generic @MakeInjectable class for services, transformers, or utilities across the architecture.
npx @solid-stack/create injectable PasswordHasher
npx @solid-stack/create injectable UserTransformer -f usersPrompts:
- Class name
- Architectural location:
- Feature Service (
features/<feature>/services/) - Feature Transformer (
features/<feature>/pxExpress/transformers/) - Shared Service (
shared/<name>/) - Core Module (
modules/<name>/) - Custom path
- Feature Service (
- Injected dependencies
- Generate runtime abstract class interface / DI token
💻 Programmatic Usage
You can import generators directly into scripts or build pipelines:
import {
generateFeature,
generateUseCase,
generateDomain,
generateInterface,
generateInfrastructure,
generateHttpHandler,
generateInjectable,
updateOrGenerateDiProvider,
} from "@solid-stack/create";
// Scaffold feature programmatically
const files = generateFeature({
name: "billing",
includeExpress: true,
includeTests: true,
});🏗️ Development & Scripts
| Command | Description |
| --- | --- |
| pnpm dev | Starts tsup in watch mode |
| pnpm build | Compiles ESM/CJS bundles and declaration files to dist/ |
| pnpm test | Runs the full Vitest test suite |
| pnpm typecheck | Typechecks using TypeScript (tsc --noEmit) |
| pnpm check | Runs typecheck, tests, and build in sequence |
📄 License
UNLICENSED © Solid Stack Digital
