Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ronaldjdev/forge/llms.txt
Use this file to discover all available pages before exploring further.
cast creates a complete vertical slice for a new business domain. Rather than generating a skeleton you have to fill in manually, it scaffolds every hexagonal layer in one operation: the domain entity and repository interface, application use cases and mapper, HTTP controller and routes, the persistence adapter, and the DI wiring that ties everything together. The result is a feature that is architecturally correct from the very first commit, with zero violations against Forge’s 13 dependency rules.
Usage
Generated Structure
For a feature namedusers, cast produces the following layout inside src/features/:
templates/feature/). The exact content of each file — DI decorators, persistence patterns, controller style — adapts to the active technology profile.
Naming Conventions
| Artifact | Format | Example |
|---|---|---|
| Feature directory | kebab-case/ | credit-card/ |
| Entity | <Name>.entity.ts | User.entity.ts |
| Repository interface | I<Name>.repository.ts | IUser.repository.ts |
| Repository implementation | <Name>.repository.ts | User.repository.ts |
| Use case | <Action>.uc.ts | CreateUser.uc.ts |
| Mapper | <Name>.mapper.ts | User.mapper.ts |
| Controller | <Name>.controller.ts | User.controller.ts |
| Routes | <Name>.routes.ts | User.routes.ts |
| Schema | <Name>.schema.ts | User.schema.ts |
Pre-Cast Verification
Before creating any files,cast verifies that the three shared layers exist. If any is missing, Forge bootstraps it automatically before proceeding:
Platform layer
Checks that
src/platform/ exists with its core subdirectories (config/, database/, http/, server/, logger/, di/, etc.). Creates them if absent.Shared layer
Checks that
src/shared/ exists with errors/, contracts/, types/, and utils/. Creates them if absent.Post-Cast Checklist
After the files are generated, the following steps are mandatory before the feature is considered complete:Entity Discovery
Before using the scaffolded
<Name>.entity.ts, check whether the entity already exists as a shared entity in src/platform/domain/entities/. If it does, do not create a local entity. Instead, import from @/domain/entities/<Name>.js (path alias) in all generated files. Also check src/shared/contracts/ for existing DTOs or interfaces.DI Wiring
Create
src/features/<name>/di.ts following the templates/feature/di.ts.md template. If a src/platform/setting/dependencies/<name>.di.js already exists, point controllers there instead. Controllers must never import from bootstrap.di.js (violates R12).Tests
Create
src/features/<name>/__tests__/Create<Name>.test.ts following templates/feature/test.ts.md. Tests use node:test (no external test runner required). Key conventions: .js extension on all imports, as const for union type literals, result! for non-null assertions, (result as any)._id when _id is not on the domain type.Import Validation
Before marking the feature done, verify every generated file passes these checks:
- R10: All local imports use
./,../, or@/as a prefix — no bare specifiers likeimport X from "domain/..." - R11: All local imports use
.jsextension — never.ts - R12: Controllers import from
./di.jsor@/setting/dependencies/— never frombootstrap.di.js - Controller method names match the route handler references (e.g.,
createHandlerin controller →controller.createHandlerin routes)
Templates
Forge ships 19 TypeScript templates for feature scaffolding undertemplates/feature/. Each template adapts its content to the active technology profile — for example, a fastify-prisma profile generates a different controller style and persistence layer than express-mongodb. Templates cover:
- Entity, repository interface, repository implementation
- Use cases (Create, Get, List, Update, Delete)
- Mapper (toDomain / toPersistence)
- Schema (Mongoose schema or Prisma model)
- HTTP controller and routes
- DI wiring (
di.ts) - Unit test scaffold