CLI Reference
The CLI scaffolds source files, manages the standard runtime, and returns JSON-friendly operational output that agents and scripts can use directly.
Command Types
- Project setup:
init - Scaffolding:
add - Schema management:
generate,migrate - Runtime operations:
plug,plug vars,wire,flows,mappings
Rule of thumb:
- If you are creating files, use
add. - If you are applying DB table changes, use
generateormigrate. - If you are debugging or operating live integrations, use
plug,wire, andflows, plusmappings.
init
$ npx khotan init
$ npx khotan init --full
$ npx khotan init --yeskhotan.config.ts— CLI config that setsoutputDir{outputDir}/khotan.ts— factory config where you register resources and plugssrc/app/api/khotan/[...all]/route.tsorapp/api/khotan/[...all]/route.ts— catch-all runtime routeAGENTS.md— root router for built-in khotan skills when skills are installed
The --full flag also installs Drizzle, Postgres, and Drizzle Kit, initializes shadcn, and scaffolds a drizzle.config.ts plus a db instance so the factory's @/db import resolves and migrate works out of the box.
add
$ npx khotan add <name> [flags]-f, --force— overwrite existing files-y, --yes— auto-accept all prompts--without-ui— skip React component scaffolding
add is safe to run non-interactively (agents, CI, piped stdin): with no TTY it skips existing files instead of blocking on an overwrite prompt — pass --force to overwrite. add schema also never writes over your factory config: with no drizzle.config.ts it falls back to a conventional db/schema directory.
Installable components
Data and runtime foundations:
schemaplugwirecatchpassinflowoutflowrelay
UI and operations:
hubmapping-browserrunslogsplug-debugger
Built-in agent skills:
skill-build— end-to-end integration workflow (orchestrator)skill-setupskill-plugagent-skillskill-flowskill-webhookskill-cacheskill-mappingsskill-frontend
Installable blocks
config-page-1— ready-made/configpage with Hubmappings-page-1— ready-made/mappingspage with the mappings browsergraph— ready-made/graphpage with topology canvaslogs-page-1— ready-made/logspagedebug-page-1— ready-made/debugroutes
Components auto-resolve dependencies. Running npx khotan add wire --yes will also add plug and schema if missing.
generate
$ npx khotan generate # non-destructive — refuses to clobber
$ npx khotan generate --force # overwrite an existing schema fileDetects your Drizzle schema directory, writes khotan table definitions, updates the Drizzle config glob if needed, and adds the barrel re-export.
generate is non-destructive: if the schema file already exists it stops and asks you to pass --force (or --yes) rather than overwriting your edits.
migrate
$ npx khotan migrate
$ npx khotan migrate --pushRequires DATABASE_URL. Runs generate first if the schema file does not exist.
plug
Inspect and test plugs through the debug route. Output is JSON on stdout.
$ npx khotan plug --list
$ npx khotan plug <plugName> --info
$ npx khotan plug <plugName> GET /products
$ npx khotan plug <plugName> POST /items --body '{}'
$ npx khotan plug <plugName> --endpoint listProducts
$ npx khotan plug <plugName> --endpoint listProducts --compare--port <n>--base-path <p>--list--info--endpoint <name>--compare--body <json>--params <json>--headers <json>
plug vars
$ npx khotan plug vars --list
$ npx khotan plug vars <plugName>
$ npx khotan plug vars <plugName> --show-secrets
$ npx khotan plug vars <plugName> set --json '{"apiKey":"secret"}'
$ npx khotan plug vars <plugName> clearManage stored plug variables through the standard Khotan API. This does not require KHOTAN_DEBUG=1. Secret fields are redacted by default — pass --show-secrets to reveal them in plaintext.
wire
Inspect, connect, and disconnect wires through the running Khotan API. Output is JSON on stdout.
$ npx khotan wire --list
$ npx khotan wire pollinate --info
$ npx khotan wire pollinate connect
$ npx khotan wire pollinate connect --webhook-origin https://x.ngrok.app
$ npx khotan wire pollinate connect --callback-url https://x.ngrok.app/api/khotan/webhook/pollinate
$ npx khotan wire pollinate disconnectUnlike plug, wire does not require KHOTAN_DEBUG=1.
flows
Inspect and operate registered flows through the running Khotan API. Output is JSON on stdout.
$ npx khotan flows list
$ npx khotan flows list --plug pollinate
$ npx khotan flows info pollinate-products --plug pollinate
$ npx khotan flows trigger pollinate-products --plug pollinate --variant full
$ npx khotan flows trigger pollinate-products --plug pollinate --variant delta
$ npx khotan flows runs pollinate-products --plug pollinate
$ npx khotan flows cancel <runId>list— list all registered flows, optionally scoped to one pluginfo— show one flow by name or IDtrigger— start a run for a variant (run mode). Pass the variant as a positional argument (khotan flows trigger <flow> delta) or via--variant <name>. It setsctx.variant, which your flow branches on to control what gets fetched, written, or skipped (e.g.default,delta,full,healthcheck). With no variant, thedefaultvariant runs.--run-typeis a deprecated alias that maps to--variant.runs— list historical runs for one flowcancel— cancel a running Workflow-backed run
mappings
Inspect and operate first-class mappings through the running Khotan API. All mappings commands emit JSON on stdout for both success and failure cases.
$ npx khotan mappings list customers
$ npx khotan mappings list customers --limit 25 --offset 50 --search "alice@example.com"
$ npx khotan mappings lookup customers --connect-value "alice@example.com"
$ npx khotan mappings lookup customers --plug shopify --ref "gid://shopify/Customer/123"
$ npx khotan mappings upsert customers --connect-value "alice@example.com" --refs '{"shopify":"gid://shopify/Customer/123"}'
$ npx khotan mappings update mapping-1 --resource customers --connect-value "alice@example.com" --refs '{"shopify":"gid://shopify/Customer/123","cin7":"cust_456"}'
$ npx khotan mappings delete mapping-1list— resolve a resource by name, then return paginated mapping rows plus paging metadatalookup— resolve one mapping either by canonicalconnectValueor byplug + refupsert— create or update one mapping usingconnectValue,refs, and optionalmetadataupdate— replace one mapping row by IDdelete— delete one mapping row by ID
Notes:
list,lookup, andupsertresolve the resource from the registered runtime config before issuing the request--refsand--metadataaccept JSON objects- composite resource identities still resolve to one canonical stored
connectValue
Agent Skills
$ npx khotan add skill-build
$ npx khotan add skill-setup
$ npx khotan add skill-plug
$ npx khotan add agent-skill
$ npx khotan add skill-flow
$ npx khotan add skill-webhook
$ npx khotan add skill-cache
$ npx khotan add skill-mappings
$ npx khotan add skill-frontendDuring npx khotan init, khotan prompts to install all skills automatically. With --yes, that prompt is auto-accepted.
.cursor/skills/....claude/skills/....agents/skills/....github/skills/....kiro/skills/....roo/rules/...
Environment Variables
DATABASE_URL— Postgres connection stringKHOTAN_SECRET— encryption key for plug and wire variablesKHOTAN_DEBUG— enables debug routesKHOTAN_WEBHOOK_URL— public origin for default webhook callbacksPORT— dev server port detection