stack88
Browse the documentation

Guides

Code generators

kit writes new API domains the way the repository expects, and its output passes every check.

kit is a command-line tool that ships inside every project. Its generators write code that follows the repository’s conventions, so the result passes pnpm check with no hand edits. The templates belong to your project: when your conventions change, change them too.

Generate an API domain

Terminal
pnpm kit generate api-domain blog-posts

The name is the plural, kebab-case domain. The entity defaults to its singular, blog-post; pass --entity when the singular is irregular. Without flags, kit asks for whatever it was not told.

It writes With --table, also
a schema, its constants and types, and a schema test a Drizzle table in the API’s database
a contract for GET /v1/blog-posts the row type and a row-to-response helper
a Nest module, controller and service, and a service test a service that reads the table

It also registers the new schema, contract and module where they need to be imported. It refuses to overwrite a file that exists or to register a module twice.

Migrations stay a manual step, printed with the other next steps:

Terminal
pnpm --filter @my-app/api db:generate

Without prompts

Every prompt has a flag. With -y, or when there is no terminal, as in CI, scripts and coding agents, kit never prompts and takes the defaults:

Terminal
pnpm kit generate api-domain blog-posts --table -y
pnpm kit generate api-domain news --entity story --dry-run

--dry-run lists the files kit would create or change and writes nothing.

How the output stays correct

The templates are plain functions that return source text, formatted with the project’s own Prettier configuration. Edits to existing files go through the TypeScript compiler rather than text markers.

pnpm test:gate proves the output: it copies the repository to a temporary directory, generates a table-backed domain and a plain one, then builds, typechecks, lints and tests the result. It runs as its own CI job. Run it after changing a template, or a convention a template follows. See the kit README for how the generators are built.