CLI
The createcms command-line interface.
@createcms/core ships one CLI binary, createcms, with two subcommands: init (scaffold a project) and generate (write the Drizzle schema). Run them with npx (or your runner of choice):
npx createcms --helpcreatecms init
Scaffolds a CMS config, a collection preset, and a Next.js route handler into your project, and adds a cms:generate script to package.json.
npx createcms init [--cwd <dir>] [--preset <name>]| Flag | Type | Default | Description |
|---|---|---|---|
--cwd | path | current directory | Project root to scaffold into. |
--preset | name | Collection preset to scaffold. |
createcms generate
Generates a Drizzle schema from your CMS config (core tables plus any plugin schema). The schema is content-agnostic, so you re-run it only when you add or change a plugin that ships schema, not when you edit a collection.
npx createcms generate [config] [--output <path>]| Argument / flag | Type | Default | Description |
|---|---|---|---|
config | path | auto-discovered | Path to your CMS config file. |
--output | path | ./cms-schema.ts | Where to write the generated schema. |
--check | flag | Verify the on-disk schema matches your config without writing. Exits non-zero on drift. Use in CI. |
When config is omitted, the CLI searches these paths in order and uses the first that exists:
cms.ts, cms.js, src/cms.ts, src/cms.js, src/lib/cms.ts, src/lib/cms.js, lib/cms.ts, lib/cms.jsThe output path falls back to the config's schema.output when set, otherwise ./cms-schema.ts. If the output file already exists, the CLI asks before overwriting. Loading your config does not open a database connection or contact S3: the CLI stubs every installed package, so a run only confirms the config file loads and the schema emits.
npx createcms generate
# config /app/src/lib/cms.ts
# output /app/cms-schema.ts
# plugins abTest, multi-tenant
# ✓ Schema generated
# file /app/cms-schema.ts
# tables 18
# enums 4After generating, apply the schema with your Drizzle migration workflow. The drizzle-kit commands read a drizzle.config.ts at your project root — see the Quickstart for the one to create:
npx drizzle-kit generate && npx drizzle-kit migrateGuard against a stale schema in CI
Fail the build if the committed schema drifted from your config:
npx createcms generate --checkIt reruns the generator in memory and compares the result to your committed schema file — no database or server needed. Exit code 0 when they match, non-zero (with a diff hint) when they don't.
Re-run createcms generate after adding or changing a plugin that contributes schema, not when you edit a collection.