CLI

The editkraft CLI sets editkraft up in your Next.js project and checks its state. No global install needed — npx is enough.

npx editkraft <command> [options]

| Command | Purpose | | -------- | ---------------------------------------------------------- | | init | Sets editkraft up in the current project | | doctor | Checks migration state, env, and registry consistency | | scan | Read-only scan for collection candidates (--json for CI) |

Options: --yes/-y (non-interactive), --force (overwrite), --json (machine-readable, scan), --cwd <dir> (target directory), --help/-h.

#init

Scaffolds everything an App Router project needs to host editkraft content:

npx editkraft init
  • Migrationsek_pages, ek_page_versions, ek_assets (published-only RLS), the locale contract and collections. Additive and safe on existing installs.
  • editkraft.config.ts — registry path and allowed Studio origin.
  • blocks/registry.ts + blocks/Hero.tsx — an example registry and block showing the data-ek-field contract.
  • app/[...slug]/page.tsx — the public render route (published pages only; your static routes win).
  • app/api/editkraft/revalidate/route.ts — the ISR revalidate webhook.
  • app/editkraft/preview/… — the draft preview route for the Studio.
  • .env.editkraft.example — the environment variables editkraft needs.

init is idempotent: created for new files, identical when content matches, skipped when a file exists with different content (--force overwrites). Re-running reuses the existing migration timestamp.

#doctor

Run it after setup (or when something’s off) to check that migrations are applied, the env is complete, and the registry is consistent with the schemas.

npx editkraft doctor

#scan

Finds read-only candidates for collections in your repo (frontmatter dirs, object arrays). --json prints machine-readable output for further processing.

#Next steps

  • Deploy — env variables and revalidation in production.