culvii dev
Start the live development sync loop.
Synopsis
culvii dev
Description
Starts the live development sync loop. Local .culvii.ts files are the authoring surface; all execution and state live on the Culvii platform's dev environment. Every file save streams a definition payload over a persistent WebSocket to the platform, which upserts it as draft state. The UI reads from the same database and reflects changes immediately.
Always connects to http://localhost:3000. The --env flag has no effect on this command — it is intentionally hardcoded to the local dev server. Use culvii deploy to target sandbox or prod.
On first run: auto-provisions a workspace named dev-{user-id} (derived from the first 12 characters of your user ID) and creates a developer-scoped API key for it. Both are cached in ~/.culvii/config.
Draft state is ephemeral. It exists only while the WebSocket connection is open. On Ctrl+C, all draft rows owned by this session are soft-deleted. Draft state never reaches sandbox or production.
File discovery
By default, recursively finds all *.culvii.ts files in the current directory, skipping node_modules/, dist/, and .git/.
Override with a culvii.yaml in the project root:
entrypoints:
- src/agents/payment-processor.ts
- src/workflows/onboarding.ts
If culvii.yaml exists and has at least one entrypoint, the glob is skipped entirely.
How it works
- Reads active tenant context from
~/.culvii/config. - Auto-provisions a
dev-{user-id}workspace if needed (idempotent — returns existing if slug taken). - Reads or creates a developer-scoped API key for the workspace.
- Opens a WebSocket to
GET /api/dev/syncauthenticated via the API key. - On session start, the platform soft-deletes any stale draft rows from previous crashed sessions (different
sessionId). - Starts file watcher. On each save: evaluates the
.culvii.tsfile, computes aconfigHash, sends asyncmessage if hash changed. - Platform upserts the definition as a draft row. Last write wins.
- When a definition is deleted from code: sends an
orphanmessage; platform setsorphanedAt. - On Ctrl+C: WebSocket closes, platform soft-deletes all draft rows owned by this session.
Examples
culvii dev
# → tenant: culvii-dev | workspace: dev-culvii-dev | env: dev
# → Watching ./... Connected to dev-culvii-dev (dev)
# → ✓ synced payment-processor
# → ✓ synced onboarding-flow
# → ^C
# → Disconnected. Draft state discarded.
Error behaviour
| Condition | Message | Exit |
|---|---|---|
| No OAuth session | "No active context. Run culvii login first." | 1 |
| Workspace auto-provisioning fails | "Failed to auto-provision workspace: <reason>" | 1 |
| API key auto-creation fails | "Failed to auto-create API key: <reason>" | 1 |
| Workspace mismatch on WebSocket | "Workspace mismatch. Connection closed." | 1 (fatal) |
| Invalid slug in definition | "⚠ Sync failed for <slug>: <reason>" | — (loop continues) |
Related commands
culvii deploy, culvii workspace create, culvii key create