Generate and Run
Generation is the step that turns your Typeweaver spec into runnable code. In the normal workflow, you update the spec, regenerate clients and server artifacts, then use that generated code from your app or runtime.
Run the generator
For a todo spec at ./api/spec/index.ts:
npx typeweaver generate --input ./api/spec/index.ts --output ./api/generated --plugins clients,hono
If you want the dependency-free server output instead of Hono:
npx typeweaver generate --input ./api/spec/index.ts --output ./api/generated --plugins clients,server
How to choose plugins
clientsgenerates contract-aware clients and request commands.honogenerates Hono integration artifacts such as<ResourceName>Hono.servergenerates dependency-free server artifacts such as<ResourceName>RouterandTypeweaverApp.
You can combine plugins in one run as long as they fit your setup.
What the generated folder contains
The exact files depend on your plugins, but a generated folder usually includes:
- a folder per resource, such as
todo/ - request and response types
- request and response validators
- generated clients when
clientsis enabled - generated server or Hono integration files when those plugins are enabled
In practice, your application code imports from ./api/generated and treats it as generated source.
When to regenerate
Regenerate whenever the spec changes.
That includes changes to:
- operation paths or methods
- request schemas
- response schemas
- resource names or
operationIdvalues - enabled plugins or output location
If the contract changed, regenerate before running the app, tests, or committing generated output.
Using a config file
If you prefer a config file, use JavaScript: .js, .mjs, or .cjs. TypeScript config files are not supported by the published CLI.
// typeweaver.config.mjs
export default {
input: "./api/spec/index.ts",
output: "./api/generated",
plugins: ["clients", "server"],
};
npx typeweaver generate --config ./typeweaver.config.mjs
See CLI Reference for the full config surface.