CLI commands

5 min read

PlatformKit commands for developing, testing, building and deploying sites.

Run platformkit from a site directory for site commands, or pass --site <path> to select a site explicitly. At the workspace root, site commands and root npm shortcuts use PLATFORMKIT_DEFAULT_SITE, which defaults to sites/docs; it may be a site name or a path to a tracked or separately linked site. --site takes precedence. Workspace dev uses that default unless PLATFORMKIT_SITES explicitly selects multiple sites; sites and stop operate on the workspace. The root registry is platformkit.sites.json; fetched repositories live in sites/external/<name>, outside the tracked fixture sites and npm workspaces.

From a checked-out site repository, install the site's dependencies, then use the Core GitHub source to build or deploy without waiting for a Core npm release:

npm ci
npx --yes --package=github:platform-kit/core platformkit build
DEPLOY=1 npx --yes --package=github:platform-kit/core platformkit deploy

Run these commands from the site's root. Every command except help, sites and stop first keeps the site's .env out of its repository: it writes .env and .env.* (not .env.example) into the clone's .git/info/exclude, and refuses to run while such a file is tracked, naming git rm --cached as the fix (build/env-guard.mts). The GitHub source installs platformkit into the site's node_modules without changing its manifest or lockfile, compiling the kit's TypeScript to JavaScript first (build/compile.mjs), since Node does not strip types inside node_modules. The receipt compares the installed packages with the exact files npm packs from that source, excluding development-only checkout files; deploy preflight verifies the receipt before deployment steps begin. The site continues to own and install its other dependencies. This avoids publishing the Core packages to npm, but still uses npm to install dependencies and fetch the GitHub-hosted CLI.

Command What it does Script
dev At the workspace root, starts selected sites behind one front door; inside a site, starts that site. A restart takes over from an abandoned run of this checkout and names the resources it stops. --port:auto and --front-door-port:auto explicitly enable port search. --single, --no-functions, --no-start and --no-stack are also available. build/dev.mjs, build/dev-workspace.mjs
stop Stops PlatformKit-managed development processes and their local Supabase stacks after verifying recorded process identity. build/dev-stop.mjs, build/dev-owner.mjs
sites [--json] Lists local and registered sites, their checkout state, and available paths. build/sites.mjs
sites fetch <name> [--url <git-url>] [--ref <commit>] Fetches a site at a full 40-character commit SHA into sites/external/<name>. The URL may come from PLATFORMKIT_SITE_<NAME>_GIT_URL; a registered remote and pin may be reused. Credentials are read from the environment and are never stored in the registry. It does not install dependencies or run package scripts. build/sites.mjs
sites update <name> --ref <commit> Updates a registered checkout to an explicitly selected full commit SHA. Refuses checkouts with local changes. build/sites.mjs
site-run <script> [args...] Runs an npm script from the selected site package; useful for site-specific commands without hardcoding a site in workspace scripts. bin/platformkit.mjs
build [--outDir dist] Runs the content build, preparation steps, bundle, prerender and site build steps. build/steps.mjs, build/prerender.mjs
steps [--phase p] [--check] Lists build steps, their state and required tools; --check fails when an enabled step is missing a need. build/steps.mjs
run <key> Runs one build step and reports why if it is disabled. build/steps.mjs --only
deploy Verifies the installed PlatformKit source or package pins, then runs provider-aware preflight for the selected site's required configuration and payment-provider secrets before its existing deployment steps. build/deploy.mjs, build/deploy-pins.mjs
test Runs module-appropriate kit checks, the site's declared tests and its OpenSpec validation, every one of them, then lists every failure together (--bail stops at the first). With --e2e, every stack-backed check on stacks built for the run from each site's files (--only <sites>, --jobs <n>, --keep, --run <script> in place of the suite); see Testing. build/test.mjs
migrate [--plan] [--linked] [--json] Assembles the database declaration and plans or applies it locally; --linked targets SUPABASE_DB_URL. build/plan.mjs
migrate reset Resets and seeds the local Supabase database from its declared schema and data. supabase db reset
db-types [--check] Writes the kit's database types from its schema, in a throwaway Postgres; --check fails when they are out of date.
dev-account Creates the configured local development account. build/dev-account.mjs
functions [deploy] Assembles and serves functions locally, or deploys them when deploy is supplied. Supabase CLI
assemble [--check] [--off <keys>] [--out <dir>] Assembles the site's Supabase tree from PlatformKit declarations and site-owned sources: core, the modules that are on and the glue between them; --check detects drift, --off assembles as though those modules were off, --out writes elsewhere. build/assemble.mjs
module drop <key> [--linked] [--plan] Drops the tables of a module that is off, after listing them with their rows; a table with rows needs PLATFORMKIT_ALLOW_DESTRUCTIVE. Switching a module off keeps its tables. build/module-drop.mts
print -- [options] Renders or sets print editions when that module is enabled. build/print.mjs
tts -- [options] Generates spoken book audio when that module is enabled. modules/tts/build/tts.mjs
tts-setup Prepares the spoken-book engine and browser weights. modules/tts/build/setup.mjs
enrich -- [options] Generates book introductions and companions when enrichment is enabled. modules/enrichment/build/enrich.mjs
share-images Photographs the site's share cards and favicon. build/share-images.mjs
probe --url <url> --routes <paths> Runs the phone probe against a served site. build/phone-probe.mjs
spec Validates the site's OpenSpec requirements. OpenSpec CLI
check [--production] [--db] [--online] Checks the machine (Node, Docker, the Supabase CLI, the test browser), the site's config and PlatformKit version, that every module is imported only through its front doors (the site's own code, and the kit where it is a checkout), the settings its switched-on features need, and the local database, then lists every problem at once with its fix. On a development machine a missing setting is a warning; --production checks .env.production as the deploy will and fails on every gap; --db compares the database with its declaration (about a minute); --online asks Stripe, the mail relay and AI providers whether they accept their keys, with read-only calls, and warns about any Stripe webhook endpoint on an older API version than the kit's. Exits 1 when anything fails. build/check.mjs
generate <kind> <name> [--level site|core] [--module <key>] [--dry-run] Writes a new module, page, content type, backend function, test or build step and registers it: in the site and its platformkit.config.js by default, or with --level core in PlatformKit itself (refused outside a PlatformKit checkout). Never overwrites; --dry-run lists what it would do. See Modules. build/generate.mjs

Other scripts

Run a script from the site root with node packages/kit/build/<script> when using a PlatformKit workspace, or node node_modules/platformkit/build/<script> from a standalone installation. Optional module tools are required only when the corresponding module is enabled. platformkit test reports missing requirements before the relevant build step.

Installing a separately fetched site

After fetching a site, install its own dependencies from its checkout:

cd sites/external/<name>
npm ci # or npm install when the site does not commit a lockfile

The site's package manifest and lockfile are the build contract. Local fetch/update commands only change the managed checkout and its pin; they do not publish packages, run tests, or deploy the site.