Scaffolding and Development
Reference for TypoKit CLI commands that scaffold new projects and modules, run builds, and start the development server.
Every command accepts these global flags:
| Flag | Description |
|---|---|
--root <dir> | Project root directory (default: current working directory) |
--verbose, -v | Show detailed output including timing and file-level information |
Scaffolding Commands
Section titled “Scaffolding Commands”typokit init
Section titled “typokit init”Create a new TypoKit project from a starter template.
Syntax
typokit init [name]Arguments
| Argument | Description |
|---|---|
name | Project directory name (optional — prompts if omitted) |
Flags
| Flag | Description |
|---|---|
--verbose, -v | Show detailed output |
What it does
- Prompts for project name (if not provided as argument)
- Prompts for server adapter (Native, Fastify, Hono, or Express)
- Prompts for database adapter (Drizzle, Kysely, Prisma, or Raw SQL)
- Creates project directory with
src/types.ts, route modules, and configuration - Generates
typokit.config.tswith chosen adapters - Installs dependencies with the detected package manager
Example
typokit init my-api? Choose a server adapter: › Native (recommended)? Choose a database adapter: › Drizzle
✔ Created my-api/ ├── src/ │ ├── types.ts schema type definitions │ ├── app.ts app factory │ └── routes/ route contracts & handlers ├── typokit.config.ts └── package.json
✔ Dependencies installed✔ Ready! Run `cd my-api && typokit dev` to start.typokit add route
Section titled “typokit add route”Scaffold a new route module with contract and handler files.
Syntax
typokit add route <name>Arguments
| Argument | Description |
|---|---|
name | Route name (e.g., users, posts, auth/login) |
Flags
| Flag | Description |
|---|---|
--verbose, -v | Show detailed output |
What it does
- Creates
contracts.tsdefining route contracts with typed parameters, query, body, and response - Creates
handlers.tswith handler stubs matching the contracts - Places files under the configured
routeFilesglob path (default:packages/server/src/routes/<name>/)
Example
typokit add route users✔ Created packages/server/src/routes/users/ ├── contracts.ts Route contracts (GET, POST, GET/:id, PUT/:id, DELETE/:id) └── handlers.ts Handler implementations
Next: Define your types, then register the route group in app.ts.Generated contracts.ts:
import type { RouteContract } from "@typokit/core";
export const getUsers: RouteContract<void, { page?: number }, void, User[]> = { method: "GET", path: "/users",};
export const createUser: RouteContract<void, void, CreateUserInput, User> = { method: "POST", path: "/users",};
export const getUser: RouteContract<{ id: string }, void, void, User> = { method: "GET", path: "/users/:id",};
export const updateUser: RouteContract<{ id: string }, void, UpdateUserInput, User> = { method: "PUT", path: "/users/:id",};
export const deleteUser: RouteContract<{ id: string }, void, void, void> = { method: "DELETE", path: "/users/:id",};typokit add service
Section titled “typokit add service”Scaffold a new service file for shared business logic.
Syntax
typokit add service <name>Arguments
| Argument | Description |
|---|---|
name | Service name (e.g., email, auth, notifications) |
Flags
| Flag | Description |
|---|---|
--verbose, -v | Show detailed output |
What it does
- Creates a service file with a factory function and typed interface
- Places the file under
packages/server/src/services/<name>.ts
Example
typokit add service email✔ Created packages/server/src/services/email.ts
Next: Import and register the service in your app configuration.Generated email.ts:
export interface EmailService { send(to: string, subject: string, body: string): Promise<void>;}
export function createEmailService(): EmailService { return { async send(to, subject, body) { // TODO: Implement email sending throw new Error("Not implemented"); }, };}Development Commands
Section titled “Development Commands”typokit build
Section titled “typokit build”Run the full build pipeline — resolving type files, running the Rust transform, emitting plugin outputs, and compiling TypeScript.
Syntax
typokit buildFlags
| Flag | Description |
|---|---|
--verbose, -v | Show detailed timing and file-level output |
What it does
- Resolve files — Finds all type files and route files from
typokit.config.tsglobs - Rust transform — Parses TypeScript AST to extract type metadata, JSDoc tags, and route contracts
- Plugin hooks — Runs build pipeline hooks (
beforeTransform→afterTypeParse→afterValidators→afterRouteTable→emit→compile→done) - Emit artifacts — Generates validators, database schemas, OpenAPI spec, client code, and contract tests to the output directory (default:
.typokit/) - Compile — Runs the
compilehook, then the default TypeScript compiler (tsc). Plugins like@typokit/plugin-axumcan override this step to run their own compiler (e.g.,cargo build)
Example
typokit build● Resolving type files... 12 files found● Resolving route files... 8 files found● Running transform... done in 145ms● Emitting validators... 12 files● Emitting DB schema... 6 tables● Emitting OpenAPI spec... 24 operations● Emitting client... 8 modules● Emitting contract tests... 24 test files● TypeScript compile... done in 2.1s
✔ Build complete (2.4s)With --verbose:
typokit build --verbose● Resolving type files... packages/schema/src/user.ts packages/schema/src/post.ts packages/schema/src/comment.ts ... (12 files)● Running Rust transform (145ms) ├── Parse AST: 45ms ├── Extract metadata: 32ms └── Validate schemas: 68ms● Plugin: afterTypeParse (2 hooks) ├── plugin-debug: 1ms └── plugin-ws: 3ms● Emitting validators... .typokit/validators/user.ts (2.1kB) .typokit/validators/post.ts (1.8kB) ...✔ Build complete (2.4s)typokit dev
Section titled “typokit dev”Start the development server with file watching for incremental rebuilds.
Syntax
typokit dev [--debug-port <port>]Flags
| Flag | Description |
|---|---|
--debug-port <port> | Debug sidecar port (default: 9800) |
--verbose, -v | Show detailed rebuild output |
What it does
- Runs an initial full build (same as
typokit build) - Starts the server using the configured server adapter
- Watches type files and route files for changes
- On file change, performs an incremental rebuild using the AST cache and dependency graph — only re-processing affected files
- If
@typokit/plugin-debugis registered, starts the debug sidecar on the specified port
Example
typokit dev● Initial build... done in 2.4s● Server listening on http://localhost:3000● Debug sidecar on http://localhost:9800● Watching for changes...
[18:30:45] Changed: packages/schema/src/user.ts● Incremental rebuild... done in 89ms (3 files affected)● Server reloadedWith a custom debug port:
typokit dev --debug-port 9229● Initial build... done in 2.4s● Server listening on http://localhost:3000● Debug sidecar on http://localhost:9229● Watching for changes...See Also
Section titled “See Also”- Generate, Migrate, and Test — Code generation, migration, and testing commands
- Inspect Commands — Query framework state from the CLI
- Getting Started: Quickstart — End-to-end walkthrough using these commands
- Building Your First API — Step-by-step tutorial