Skip to content

chkit init

Scaffolds a chkit project in the current directory: writes a clickhouse.config.ts and an example schema file, installs dependencies if the project has none, and — on an interactive run — offers to connect a database.

chkit init [flags]
FlagTypeDefaultDescription
--connect <choice>stringPreselect a connection path: claim, account, clickhouse, or later. Skips the interactive prompt.
--email <email>stringEmail for the ObsessionDB claim / account paths (implies an interactive connect step).
--code <code>stringOne-time email code, to verify a signup without re-prompting.
--org-name <name>stringOverride the auto-created ObsessionDB organization name.
--yes, -ybooleanfalseSkip the connect prompt and just write files — keeps init a silent scaffolder for scripts.

See global flags.

chkit init runs three steps in order. Each is idempotent, so re-running on an existing project is safe.

Writes two files relative to the current working directory, leaving any that already exist untouched:

  1. clickhouse.config.ts — project config with sensible defaults: schema: './src/db/schema/**/*.ts', outDir: './chkit', migrationsDir: './chkit/migrations', metaDir: './chkit/meta', an empty plugins array, and a clickhouse block reading from CLICKHOUSE_URL, CLICKHOUSE_USER, CLICKHOUSE_PASSWORD, and CLICKHOUSE_DB.
  2. src/db/schema/example.ts — a starter MergeTree table named events with columns id (UInt64), source (String), and ingested_at (DateTime64(3)).

If @chkit/core does not already resolve from the project, init makes the project runnable: it writes a minimal package.json when none exists, then installs chkit, @chkit/core, and @chkit/plugin-obsessiondb as dev dependencies using the detected package manager (npm, pnpm, yarn, or bun; defaults to bun). This is why init works in a brand-new empty folder, not just an existing project. A failed install never aborts init — it prints the manual install command and continues.

On a TTY — or when --connect / --email is passed — init runs the ObsessionDB onboarding prompt:

Claim a free ObsessionDB dev instance email code, ready in seconds
I already have an ObsessionDB account log in and pick a service
I already have a ClickHouse instance connect with env vars
Configure later

Claiming or logging in registers the @chkit/plugin-obsessiondb plugin in your config and writes the selected service to .chkit/obsessiondb.json. See Getting Started with ObsessionDB for each path in detail, including the non-interactive and agent-friendly (--json) variants.

Pass --yes to skip this step and just write files. In a non-interactive environment (no TTY) without connect flags, init skips onboarding entirely — it writes files and prints static next steps (set CLICKHOUSE_URL, edit the schema, then generate and migrate). When an explicit connect path is requested but cannot complete — for example --connect claim with no email, or a wrong code — init exits non-zero so scripts can detect the failure.

Scaffold and connect interactively:

Terminal window
chkit init

Scaffold only, no prompt (CI / scripts):

Terminal window
chkit init --yes

Preselect the claim path (still prompts for the emailed code):

Terminal window
chkit init --connect claim --email you@example.com

For a fully scripted claim with no prompts, use the two-step OTP flow in Getting Started with ObsessionDB.

CodeMeaning
0Success
non-zeroAn explicitly requested connect path could not complete