Skip to content

chkit codegen

Shortcut for chkit plugin codegen codegen. Generates TypeScript row types, optional Zod schemas (in Python: Pydantic models), typed insert helpers, and runtime migration modules from schema definitions.

chkit codegen [flags]
FlagTypeDefaultDescription
--checkbooleanfalseValidate generated artifacts are up-to-date without writing
--out-file <path>string—Override output file path
--emit-zodboolean—Enable Zod validator generation
--no-emit-zodboolean—Disable Zod validator generation
--emit-ingestboolean—Enable typed insert helper generation
--no-emit-ingestboolean—Disable typed insert helper generation
--ingest-out-file <path>string—Override the generated insert helper file path
--emit-migrationsboolean—Enable runtime migration module generation
--no-emit-migrationsboolean—Disable runtime migration module generation
--migrations-out-file <path>string—Override migrations output file path
--bigint-mode <mode>string—Large integer mapping: string or bigint
--include-viewsbooleanfalseInclude views in generated output

Global flags documented on CLI Overview.

This command delegates to the codegen plugin’s codegen command. The codegen plugin must be registered in your config’s plugins array with manifest.name equal to "codegen".

If the codegen plugin is not configured, the command fails with: “Codegen plugin is not configured. Add a plugin with manifest.name “codegen” to config.plugins.”

Generated insert helpers, named ingest<TableName>, pass typed rows to the supplied Ingestor.insert implementation. Request-body compression is enabled by default. Pass { compressed: false } as the third argument to opt out for a specific call.

With --check, the command validates that generated artifacts are current without writing files. This is useful in CI to detect stale types. Failure codes include:

  • codegen_missing_output — types file missing
  • codegen_stale_output — types content has drifted
  • codegen_missing_ingest_output — generated insert helper file missing (when emitIngest is enabled)
  • codegen_stale_ingest_output — generated insert helper content has drifted
  • codegen_missing_migrations_output — migrations file missing (when emitMigrations is enabled)
  • codegen_stale_migrations_output — migrations content has drifted
Terminal window
chkit codegen
Terminal window
chkit codegen --check
Terminal window
chkit codegen --emit-zod --include-views
CodeMeaning
0Success
1Error (including stale check)
2Invalid plugin options