forgedb generate

Transpile a .forge schema into tailored Rust, a REST API, OpenAPI, stubs, or a language runtime binding.

Transpile your schema into code. A target is either a standalone artifact (all, rust, api, openapi, stubs, ffi, transform) or a runtime (python, node, bun, go, rust, browser) paired with a mode flag (--sdk, --runtime, or --replica). The REST client SDKs (--sdk) ship for TypeScript, Python, Rust, and Go.

Synopsis#

forgedb generate [target] [--sdk|--runtime|--replica] [flags]

The target defaults to all.

Targets#

TargetKindProduces
allstandaloneEvery default artifact (rust, typescript, api, openapi, stubs) — plus the opt-in wasm/ffi when listed in [generate].targets.
ruststandalonedatabase.rs — the tailored Rust database.
apistandaloneapi.rs — the REST API + OpenAPI document.
openapistandaloneopenapi.json — the OpenAPI 3.1 document (offline).
stubsstandaloneplaceholder stubs README (no UI codegen today).
ffistandaloneC-ABI FFI bindings.
transformstandaloneThe offline migration transformer crate (requires --from/--to; see migrations).
node --sdk / bun --sdkruntimeTypeScript REST client SDK.
python --sdkruntimePython REST client (stdlib urllib).
rust --sdkruntimeRust REST client crate (reqwest). Bare rust is the standalone database above.
go --sdkruntimeGo REST client package (stdlib net/http).
python --runtimeruntimePyO3 in-process native binding.
node --runtime / bun --runtimeruntimeNAPI-RS in-process native binding.
go --runtimeruntimeExperimental cgo in-process binding over the FFI cdylib.
browser --replicaruntimeWASM in-process read-replica follower.

Standalone targets take no mode

Passing --sdk/--runtime/--replica to a bare standalone target (e.g. api --sdk) is an error, and a runtime target requires a mode. The one crossover is rust: bare rust emits the standalone database, while rust --sdk emits the REST client crate. The node|bun --replica combination (server-side WASM replica) is not yet implemented and errors explicitly. The old flat verbs generate typescript / generate wasm were renamed — use node --sdk / browser --replica.

Flags#

FlagType / defaultMeaning
[target]string (all)The artifact or runtime to generate.
--sdkboolMode (runtime targets): network REST client.
--runtimeboolMode (runtime targets): in-process native FFI binding.
--replicaboolMode (runtime targets): in-process read-replica follower.
--checkbool (false)Verify nothing needs regeneration (CI mode); do not write.
-o, --output <DIR>string ([generate].output, else generated)Output directory.
-s, --schema <PATH>string (auto-discover)Schema file path. Auto-discovery looks for schema.forge, schema.lang, schema.forgedb.
-f, --forcebool (false)Regenerate even if up-to-date; overwrite existing output.
--from <N>u32Origin format version — transform target only.
--to <N>u32Destination format version — transform target only.

Generate-time config is baked in

The schema-blind [runtime]/[storage] knobs in forgedb.toml are baked into database.rs at generate time, so the emitted code carries the behavior you configured. See configuration.

Examples#

Generate everything into ./generated:

forgedb generate all --output ./generated

Generate only the Rust database from a specific schema:

forgedb generate rust --schema ./schema.forge

Generate the TypeScript REST SDK for Node:

forgedb generate node --sdk

Generate a REST client SDK for another language on your stack:

forgedb generate python --sdk   # -> python-sdk/  (urllib)
forgedb generate rust --sdk     # -> rust-sdk/    (reqwest)
forgedb generate go --sdk       # -> go-sdk/      (net/http)

Fail CI if generated code is stale:

forgedb generate all --check

Search documentation

Find pages across the ForgeDB docs