CLI Reference
The kirak command-line interface provides tools for project scaffolding, fact inspection, static validation, schema management, database migrations, and AI coding agent development.
kirak --helpkirak --version # prints e.g. "kirak 0.1.1"Machine-Readable JSON Contract
Section titled “Machine-Readable JSON Contract”Every kirak command supports a --json flag designed specifically for automation, CI/CD pipelines, and AI coding assistants. When invoked with --json, the command outputs a single unformatted JSON document to stdout following this canonical schema:
{ "kirak_version": "0.1.1", "command": "validate", "ok": true, "data": { "valid": true, "errors": 0, "warnings": 0 }, "problems": []}Exit Codes
Section titled “Exit Codes”| Exit Code | Name | Description |
|---|---|---|
0 |
SUCCESS |
Command completed successfully. The problems array may contain informational items or warnings, but zero errors. |
1 |
PROBLEMS_FOUND |
Command executed, but one or more critical errors were detected in project configuration, models, or migrations. |
2 |
USAGE_ERROR |
Command syntax error, invalid CLI flags, missing required arguments, or command invoked outside a Kirak project directory. |
Redaction & Zero-Leak Guarantee
Section titled “Redaction & Zero-Leak Guarantee”All CLI commands strictly sanitize output through developer_redactor(). Secret values (database passwords, API keys, JWT secrets) are never printed to stdout or logs, even when verbose or --json flags are active. The CLI reports boolean existence flags (set: true or set: false) rather than raw credential strings.
Command Pipeline Diagram
Section titled “Command Pipeline Diagram”flowchart TD CLI["kirak CLI Invocation"] --> DISPATCH{"Command Dispatcher"}
subgraph ProjectSetup["1. Project Creation"] DISPATCH --> NEW["kirak new <name>"] NEW --> SCAFFOLD["Scaffold Directory & JSON Schemas (.kirak/)"] end
subgraph Inspection["2. Facts & Discovery (Offline / Zero I/O)"] DISPATCH --> INFO["kirak info"] DISPATCH --> MODULES["kirak modules [NAME]"] DISPATCH --> PROVIDERS["kirak providers <module>"] DISPATCH --> CATALOG["kirak catalog"] DISPATCH --> ENV["kirak env"] end
subgraph Verification["3. Static Validation & Schema"] DISPATCH --> VALIDATE["kirak validate [--code]"] DISPATCH --> SCHEMA["kirak schema"] DISPATCH --> FMT["kirak fmt [--check]"] VALIDATE --> PROBLEMS{"Has Problems?"} PROBLEMS -->|Errors| EXIT1["Exit Code 1"] PROBLEMS -->|Clean| EXIT0["Exit Code 0"] end
subgraph DatabaseOps["4. Database Lifecycle"] DISPATCH --> DB_INIT["kirak db init"] DISPATCH --> DB_DIFF["kirak db makemigrations [--dry-run]"] DISPATCH --> DB_MIGRATE["kirak db migrate"] DISPATCH --> DB_STATUS["kirak db status"] end
subgraph AgentDev["5. AI Agent & MCP Tooling"] DISPATCH --> DEV_MCP["kirak dev mcp (stdio)"] DISPATCH --> MCP_INSPECT["kirak mcp inspect <name>"] end
subgraph CloudOps["6. Cloud Deployment"] DISPATCH --> DEPLOY["kirak deploy [--target] [--host] [--options]"] DISPATCH --> LOGS["kirak logs [--deploy] [--follow] [--app]"] DISPATCH --> ENV_PUSH["kirak env push"] DISPATCH --> AUTH_CLI["kirak login / logout"] endCore Commands
Section titled “Core Commands”kirak new
Section titled “kirak new”Scaffolds a new Kirak application directory with pre-configured schemas, models, hooks, and agent instructions.
# Standard scaffolding (defaults to MySQL)kirak new my-api
# PostgreSQL projectkirak new my-api --database postgres
# SQLite project (zero-server local setup)kirak new my-api --database sqlite
# Scaffold in current directory (preserves existing files)kirak new my-api --hereOptions
Section titled “Options”| Option | Flag | Description |
|---|---|---|
--database |
- |
Target database engine: mysql (default), postgres, or sqlite. Sets kirak.json database block and sets appropriate driver dependencies in pyproject.toml. On every database engine, .gitignore automatically lists /var/ (the isolated SQLite metrics store) and /logs/ (kirak.log): runtime output that holds request data, not application code. |
--dir |
-d |
Parent directory for the new project (defaults to current directory). |
--here |
- |
Scaffolds into the current directory instead of creating a subdirectory. Fails if kirak.json already exists. |
Generated Structure
Section titled “Generated Structure”my-api/+-- main.py # Application entry point with create_kirak_app()+-- kirak.json # Manifest configuration+-- .env.example # Required environment variables (secrets only)+-- .gitignore # Ignores DB files, /var/ (metrics store), /logs/ (kirak.log)+-- pyproject.toml # Project metadata and dependencies+-- AGENTS.md # Guidelines and instructions for AI coding assistants+-- KIRAK.md # Project doc for AI coding agents+-- CLAUDE.md # Imports AGENTS.md and KIRAK.md for Claude Code+-- GEMINI.md # Imports AGENTS.md and KIRAK.md for Gemini CLI+-- .kirak/ # Exported JSON Schemas for editor autocomplete+-- models/| +-- posts.json # Sample model with row-level access control+-- src/ # The project's Python: hooks, agent tools, routes, tasks, providers| +-- __init__.py # register(kirak), passed to create_kirak_app(on_kirak_ready=...) in main.py| +-- hooks.py # Sample lifecycle hook stubs+-- migrations/ # SQL migrations managed by Kiraksrc/ is the default place for Python, not a requirement: Kirak runs what on_kirak_ready registers, wherever the code is. See Where the Code Lives.
kirak info
Section titled “kirak info”Inspects and reports project facts by reading local files without importing project code or connecting to a database.
kirak infokirak info --jsonkirak info --dir ../other-projectReported Information (data object)
Section titled “Reported Information (data object)”kirak_version: Installed version of Kirak runtime.project_root: Absolute path to project root.manifest: Currentkirak.jsonconfiguration merged withkirak.local.json.modules: List of enabled modules.models: Model layout (directoryvsfile), path, and model names.agents: List of declared agent names (agents/*.json).mcp_servers: Declared MCP servers and their exposed tools (mcp/*.json).migrations: Pending migrations and snapshot state.
kirak validate
Section titled “kirak validate”Performs multi-layered static verification across models, manifest settings, agents, MCP tools, and Python code.
# Validate entire projectkirak validate
# Validate specific subsystemkirak validate modelskirak validate manifestkirak validate agentskirak validate mcp
# Test a draft file before writing it to diskkirak validate models --file ./draft_model.json
# Test a single file replacementkirak validate --override model:posts=./draft_posts.json
# Static code analysis (validates hook events, imports, and route conflicts)kirak validate --code
# Strict mode: treat all warnings as errorskirak validate --strict --jsonVerification Layers
Section titled “Verification Layers”- Schema Compliance: Validates every JSON file against
.kirak/*.schema.json. A project with no models is valid: amodels/folder that is missing or empty starts with only the built-in tables. - Referential Integrity: Verifies foreign keys, relation references, and hook names.
- Secret Leak Detection: Rejects credentials, private keys, or passwords written inside
kirak.jsonor model files. - Python Code Inspection (
--code): Uses AST parsing to check that hooks subscribe to valid events without executing arbitrary code.
kirak modules & kirak providers
Section titled “kirak modules & kirak providers”Explores the Kirak catalog of modules and pluggable backends.
# List all built-in moduleskirak modules
# Inspect a specific module in detailkirak modules paymentskirak modules payments --json
# List providers for a modulekirak providers storage
# Inspect a specific provider's configuration schemakirak providers storage aws_s3kirak providers storage aws_s3 --jsonkirak catalog
Section titled “kirak catalog”Dumps the complete Kirak runtime catalog as a single comprehensive document. Includes all modules, providers, parameter specifications, hook events, and social backends.
kirak catalog --json > catalog.jsonkirak env
Section titled “kirak env”Scans kirak.json and reports every environment variable required by enabled modules and configured providers.
kirak envkirak env --jsonOutput clearly indicates which variables are required, optional, set, or missing:
Required environment variables: [OK] KIRAK_AUTH_JWT_SECRET_KEY [MISSING] DB_PASSWORD [OK] KIRAK_PAYMENT_STRIPE_US_API_KEYkirak env push
Section titled “kirak env push”Pushes the project’s secrets from .env to a deployed target (e.g. production or staging), allowing the deployed application to read updated secrets without re-deploying code.
# Push secrets from .env in project root to production targetkirak env push
# Push to a specific deployment target (default: production)kirak env push --target staging
# Push from a custom env filekirak env push --file prod.env
# Dry run: view what variables would be pushed (values masked as ***)kirak env push --dry-runkirak env push --json- Targeted Transmission: Transmits only the secrets the project configuration actually reads: core and module secrets (
DB_PASSWORD,KIRAK_REDIS_URL,KIRAK_AUTH_*keys), AI model API keys (OPENAI_API_KEY, etc.), per-instance provider secrets fromkirak.json(KIRAK_PAYMENT_<INSTANCE>_SECRET_KEY, etc.), and active social login secrets (SOCIAL_AUTH_<NAME>_SECRET). - Skipped Variables: Every unread variable, and any variable with an empty value, is skipped and reported under
skipped. - Zero-Leak Output: The output names the variables only (
pushed_variables,skipped), never printing raw secret values. - Authentication: Requires an active login (
kirak loginorKIRAK_API_KEY) or an active deployment claim token. Without them, reportsnot_authenticatedorno_project(exit code 2).
kirak schema
Section titled “kirak schema”Exports JSON Schemas corresponding to the currently installed Kirak version into .kirak/.
# Export all schemas to .kirak/kirak schema
# Print a specific schema to stdoutkirak schema --print modelkirak schema --print manifestkirak run
Section titled “kirak run”Serves the project with uvicorn, in place of typing the uvicorn command. It finds the project root from the current directory (or --dir), runs from there, and needs uvicorn installed (pip install "uvicorn[standard]"; a project from kirak new already depends on it).
# Local development: http://127.0.0.1:8000, restarting when a project file changeskirak run
# Another app module, host or portkirak run --app main_auth:app --host 0.0.0.0 --port 8001
# Several worker processes (turns reload off)kirak run --no-reload --workers 4| Option | Default | Description |
|---|---|---|
--host |
127.0.0.1 |
Address to listen on; 0.0.0.0 accepts connections from other machines |
--port, -p |
$PORT, else 8000 |
Port to listen on |
--reload / --no-reload |
on | Restart when a project file changes. Changes under logs/, var/, .kirak/, .venv/ and migrations/ are ignored. Off with --workers |
--workers, -w |
1 | Number of worker processes |
--app |
main:app |
The ASGI app as module:attribute |
It exits with code 2 outside a project, when the --app module file is missing, when $PORT is not a number, or when uvicorn is not installed. For production process managers and worker counts, see Performance.
kirak fmt
Section titled “kirak fmt”Canonically formats kirak.json, models/*.json (or models.json), agents/*.json, and mcp/*.json with standard 2-space indentation and consistent key ordering.
# Format all project JSON declarations in placekirak fmt
# Check formatting without modifying files (exits 1 if unformatted files exist)kirak fmt --check
# Format a specific project directorykirak fmt --dir ./my-project- In-Place Formatting: Formats and writes updated files back to disk, printing each modified file path.
- CI Enforcement (
--check): In CI/CD pipelines or pre-commit hooks,--checkprints paths of unformatted files to stderr and exits with code1(or exit code0if all files conform). - JSON Syntax Errors: If any target file contains invalid JSON syntax, prints the parse error and exits with code
1.
kirak upgrade
Section titled “kirak upgrade”Moves a project’s files to the installed Kirak version. kirak.json kirak_version names the Kirak version the files are written for (kirak new sets it). A release that renames or removes something a project writes ships upgrade steps; kirak upgrade runs the steps of every release after the project’s kirak_version up to the installed one, oldest first, so a project can skip releases.
# What upgrading changes; writes nothingkirak upgrade check
# The changes as diffs (dry run)kirak upgrade
# Write them and set kirak_version to the installed Kirakkirak upgrade --applyUpgrading a project:
pip install -U kirakkirak upgrade checkkirak upgrade --applykirak validatekirak db makemigrations # when Kirak's own tables changed- What a step changes: JSON only:
kirak.json,kirak.local.json, the model files,agents/*.jsonandmcp/*.json. A changed file is written inkirak fmtformat. Python files (hooks, custom routes) are never rewritten: a step reports what to change in them as anupgrade_needs_humanwarning with the file. kirak upgrade checkreports:kirak_versionagainst the installed Kirak (status:current,behind,aheadorunknown), the steps that would run, each file change as a unified diff, thekirak validateproblems left once the changes are made, Kirak’s own tables thatmigrations/models_snapshot.jsondoes not have yet or has in another shape (builtin_tables:added,changed;nullwithout a snapshot), and schemas in.kirak/exported from another version (schemas_stale).kirak upgrade --json:datahasproject_kirak_version,installed_kirak_version,status,steps(id,version,summary),changes(file,diff) andwritten(the files written; empty on a dry run).- Refusals: a project written for a newer Kirak than the installed one exits
1withkirak_version_ahead; an invalidkirak_versionwithkirak_version_invalid; a project JSON file that is not valid JSON withupgrade_file_unreadable. Nothing is written in any of these cases. - No
kirak_version: a warning (kirak_version_missing); every step up to the installed Kirak is checked, and--applyadds the key. - Reads the project’s files only: no database access, no project code imported. The dev MCP server has the same check as
kirak_upgrade_check.
kirak migration-table & kirak migration-plan
Section titled “kirak migration-table & kirak migration-plan”The migration planner that hosted deploys use, as JSON. A deploy target plans a tenant’s migration with the toolchain’s Kirak, so the plan matches the Kirak the tenant runs. Neither command reads or writes a database.
# CREATE TABLE of kirak_migrations for a dialect (mysql, postgresql, sqlite)kirak migration-table --dialect postgresql --json
# Plan from a JSON request on stdinecho '{"dialect": "sqlite", "previous_models": {}, "models": {...}, "modules": [], "confirm_drops": false}' \ | kirak migration-plan --jsonmode:"plan"(default) returnsstatements,models,models_json,checksum,dropsandnotes."pending"returnsadded,droppedandrefused, what a deploy would change.- Refusals: a dropped table or column without
confirm_dropsexits1with problemdrops_need_confirmationand the list indata.drops. A change the deploy cannot apply exits1with problemmigration_refusedanddata.problems. - SQLite (D1): a changed column is applied, not refused. SQLite cannot alter one in place, so the table is rebuilt instead: the new table is created, the rows are copied, the old table is dropped and the new one renamed, all in the deploy’s one atomic migration, and
notesnames each rebuilt table. Only the columns both model sets have are copied, so a dropped column is left behind by the rebuild and still needsconfirm_drops. A rebuild that breaks a new constraint, such asrequiredadded while a row holdsNULL, fails and changes nothing. The models carry no rename, so a renamed field reads as a drop and an add: the column’s data does not move with the name.
Database Migration Commands (kirak db)
Section titled “Database Migration Commands (kirak db)”All kirak db commands execute from the project root and manage the database schema declaratively.
sequenceDiagram autonumber actor Dev as Developer / Agent participant CLI as kirak db participant Snap as models_snapshot.json participant Mig as migrations/ participant DB as Target Database
Dev->>CLI: kirak db makemigrations "add_rating" CLI->>Snap: Compare models/*.json vs. Snapshot CLI->>CLI: Generate non-destructive SQL DDL CLI->>Mig: Write 0002_add_rating.sql CLI->>Dev: Migration created
Dev->>CLI: kirak db migrate CLI->>DB: Query applied migration log table CLI->>DB: Execute pending SQL statements inside transaction CLI->>Snap: Update models_snapshot.json CLI->>Dev: All migrations applied successfullykirak db init
Section titled “kirak db init”Generates and applies the initial database migration based on the project’s models and Kirak’s internal system tables (e.g. auth, rate limits).
kirak db initkirak db init --name initial_schemakirak db makemigrations
Section titled “kirak db makemigrations”Compares the current models/ definitions against migrations/models_snapshot.json and generates a new SQL migration file.
# Generate migration filekirak db makemigrations add_user_avatar
# Dry run: view generated SQL without writing migration fileskirak db makemigrations --dry-runkirak db makemigrations --dry-run --json[!WARNING] Destructive Changes Protection: If a model change would result in data loss (dropping columns, changing incompatible data types, dropping tables),
kirak db makemigrationsrefuses to generate the migration unless explicit confirmation is provided.
kirak db migrate
Section titled “kirak db migrate”Applies all pending migrations to the configured database.
kirak db migrate- Acquires a migration lock to prevent concurrent deployment conflicts.
- Executes migrations sequentially. On PostgreSQL and SQLite each file and its
kirak_migrationsrow run in one transaction, so a file that fails leaves nothing applied. MySQL commits each DDL statement on its own: a failed file keeps the statements before the failure and is not recorded, so fix the file and the database by hand before running again. - Records applied migrations in the internal
kirak_migrationstable.
kirak db status
Section titled “kirak db status”Shows the execution status of all migrations (applied, pending, or modified).
kirak db statuskirak db status --jsonkirak db status --deployedkirak db status --deployed --target staging --jsonWithout --deployed it reads the local database named in kirak.json. With --deployed it asks the deployment service what the deployed database is at instead: a deployed database is migrated from the models on each deploy, not from migrations/, so it is described by its live version and the model set of its schema. The output lists the deployed tables and compares them with the local models, by the rules a deploy applies:
added: tables and columns the next deploy would create.dropped: tables and columns it would delete, which needs--allow-data-loss.refused: changes a deploy cannot apply (on MySQL and PostgreSQL a field’s type, for example). On SQLite (the free tier’s D1) this is empty for a changed column: the deploy rebuilds the table instead. A new field that isrequiredwith no default is still refused everywhere, because the rows already in the table have no value for it.
It needs a deploy to the target first, and kirak login (or the claim token an unclaimed deploy saved). Available for apps on the Kirak free tier; a target that cannot report its database answers db_status_unsupported.
kirak db diff
Section titled “kirak db diff”Compares current models against another project directory to identify schema divergence:
kirak db diff --against ../staging-projectkirak db diff --against ../staging-project --jsonkirak db reset
Section titled “kirak db reset”Drops all tables and resets the database schema. Strictly limited to development environments.
kirak db reset --forceAI Agent & Developer MCP Commands
Section titled “AI Agent & Developer MCP Commands”kirak dev mcp
Section titled “kirak dev mcp”Starts an internal Model Context Protocol (MCP) server over stdio. Designed for AI coding tools (Claude Code, Cursor, Codex, Gemini/Antigravity).
kirak dev mcp- Operates purely over standard input/output (
stdio). - Does not bind to network ports.
- Exposes tools to validate files, inspect schemas, check migrations, and read catalog facts.
kirak mcp inspect
Section titled “kirak mcp inspect”Inspects an MCP server definition (mcp/*.json) and estimates context token costs for LLMs:
kirak mcp inspect assistantOutput includes:
- Exposed tool names and schemas.
- Estimated prompt token consumption.
- Ready-to-copy client configuration blocks for Claude Code, Cursor, and VS Code.
Cloud Deployment Commands
Section titled “Cloud Deployment Commands”kirak deploy
Section titled “kirak deploy”Deploys the application directly to the Kirak deployment service and prints its public URL.
# Deploy to production target (default)kirak deploy
# Deploy to a specific targetkirak deploy --target staging
# Choose where a first deploy runs (logged in): Workers, Cloud Run or a dedicated serverkirak deploy --host workerskirak deploy --host cloud_runkirak deploy --host cloud_run --size scalingkirak deploy --host vps --size cx23
# An instance in your own AWS, Google Cloud or Azure account (Agency plan)kirak deploy --host byoc --cloud aws --region eu-west-1 --size t3.small
# See where this account can deploy and what each costs, then stopkirak deploy --options
# Accept schema changes that drop tables or columns, without interactive promptkirak deploy --allow-data-loss
# Non-interactive CI mode: accept schema drops reported by the deployment servicekirak deploy --force
# JSON output envelopekirak deploy --json| Option | Flag | Description |
|---|---|---|
--target |
-t |
Deployment target name (default: production). Each target maintains its own isolated database state and public URL. |
--host |
- |
Where a first deploy runs: workers, cloud_run, vps (a dedicated server, with --size) or byoc (an instance in your own cloud, with --cloud). Needs kirak login. Without it a terminal asks and a script stops; see Where a First Deploy Runs. |
--size |
- |
The size of a dedicated server (--host vps, for example cx23), the Cloud Run instance type (--host cloud_run: fixed or scaling), or the instance type in your cloud (--host byoc, for example t3.small), as --options lists them. |
--cloud |
- |
Your cloud for --host byoc: aws, gcp or azure. |
--region |
- |
A region (a zone on Google Cloud) of your cloud for --host byoc; the cloud’s default when left out. |
--options |
- |
Show where this account can deploy a new project and what each costs, then stop. Needs kirak login; needs no project. |
--allow-data-loss |
- |
Accept a schema migration that drops tables or columns without interactive confirmation. |
--force |
- |
Non-interactive CI flag: automatically accepts data-loss schema drops reported by the deployment service. Has no effect if the deploy drops nothing. |
--discard-studio-changes |
- |
Replace remote changes made in Studio outside this git repository with the local project state. |
--dir |
-d |
Path to the project root directory. |
--json |
- |
Output structured facts envelope. |
Files Sent
Section titled “Files Sent”The bundle holds the project’s code, config and text files at any depth: files ending in .py, .json,
.txt, .md, .toml, .yaml, .yml, .ini, .cfg, .sql, .html, .htm, .jinja, .jinja2, .j2,
.css, .js, .csv or .xml, plus .gitignore, .gitattributes, .dockerignore, .editorconfig,
.python-version, Dockerfile, Procfile, Makefile, LICENSE and everything under .kirak/. Never
sent: .env and every .env.*, kirak.local.json, .kirak/deploy.json, temporary .kirak/*.tmp files left by an interrupted write, compiled Python (.pyc, .pyo),
other file types (images, archives, databases), and the folders .venv/, venv/, __pycache__/, .git/,
node_modules/, logs/, .pytest_cache/, .mypy_cache/, .ruff_cache/ and .tox/. A symbolic link or junction whose target lies outside the project is never sent. The deployment
service limits the bundle’s size; see kirak.io/deploy.
Where a First Deploy Runs
Section titled “Where a First Deploy Runs”The first deploy of a project by a logged-in account runs where --host says:
--host |
Runs on | Cost |
|---|---|---|
workers |
Kirak’s Workers hosting | Free, and only for the Free plan: a subscription has no free Worker, and --host workers is refused with INSTANCE_LIMIT. |
cloud_run |
A Cloud Run instance, on a paid plan | Included while the plan has an instance left, else an extra instance at its monthly price. --size picks its type: fixed (paused at its monthly allowance) or scaling (usage past the allowance billed, never paused). An included instance is the plan’s type; picking the other type buys it as an extra, also while included instances are left. |
vps |
A dedicated server on Kirak Cloud, of the --size you name |
The size’s monthly price, on any plan. It never uses an included instance. |
byoc |
An instance Kirak creates in your own AWS, Google Cloud or Azure account | Billed by your cloud account, never by Kirak: no wallet reserve and no included instance. Agency plan only. |
So a Free account chooses between its free Worker and a dedicated server, a subscription between Cloud Run (included, then extra) and a dedicated server, and an Agency account can also use its own cloud.
Your own cloud (--host byoc)
Section titled “Your own cloud (--host byoc)”Kirak creates the server in your account, deploys to it the way it does to a dedicated server (your app’s image,
Postgres on the server, migrations, a smoke test and a rollback) and deletes it when you delete the instance. It
needs your cloud’s credentials, which kirak deploy reads from the environment or the project’s .env and sends
with the upload; Studio keeps them encrypted for the project, so a later deploy needs none here:
--cloud |
Variables |
|---|---|
aws |
KIRAK_HOSTING_AWS_ACCESS_KEY, KIRAK_HOSTING_AWS_SECRET_KEY |
gcp |
KIRAK_HOSTING_GCP_SERVICE_ACCOUNT_JSON: the service account’s JSON, or the path of its file |
azure |
KIRAK_HOSTING_AZURE_TENANT_ID, KIRAK_HOSTING_AZURE_CLIENT_ID, KIRAK_HOSTING_AZURE_CLIENT_SECRET, KIRAK_HOSTING_AZURE_SUBSCRIPTION_ID |
Give the account only the rights to create, read and delete instances and their network rules. The values are
never printed, logged or kept with the deploy job; every output of kirak deploy masks them. kirak deploy --options lists each cloud with its regions, instance types and variables. In a terminal the menu asks the
cloud, the region and the instance type, then confirms that your cloud account pays. A deploy to your own cloud
without --host byoc never happens by default, and a project that already deployed stays where it runs.
kirak deploy --options lists what this account can choose, each with its cost, and the dedicated server sizes
for sale with their specs and monthly price; with --json the same as data.targets and data.dedicated.
- No
--hostin a terminal: the CLI shows the same list as a menu, then the sizes if you pick a dedicated server, or the instance types if you pick Cloud Run and the deployment service lists them. An extra instance or a dedicated server asks to confirm its price first: the rest of the month is reserved from your wallet now, then the full price each month. Answering no deploys nothing. - No
--hostin a script (--json, or no terminal): a Free account’s goes to its free Worker, which costs nothing. A subscription’s deploys nothing: the options are printed (indatawith--json), the problem isHOST_REQUIREDand the exit code is 1. Pass--host(and--sizeforvps). Passing it is the consent to the price. A Free account whose Worker is in use stops the same way, with the reason in the options. - A project that already deployed stays where it runs: the CLI does not ask again, and
--hostdoes not move it. - Without a login,
kirak deploymakes the unclaimed preview described below, which has no choice.--hostthen fails withNOT_LOGGED_IN. - A bad combination (a
--hostthat is not one of the four,--host vpswithout--size,--sizewith--host workers) isBAD_HOST, found before anything is validated or uploaded. A plan or wallet that cannot take the choice is refused by the deployment service with its own message (INSTANCE_LIMIT,WALLET_SHORT).--host byocwithout--cloud, and--cloudor--regionwithout--host byoc, areBAD_HOSTtoo; a size or region the cloud does not offer, a Cloud Run type that is notfixedorscaling, and credentials Studio does not have for the project, are refused by Studio with the list to choose from or the variables to set. A credential file that cannot be read isBAD_CREDENTIALS. - MCP tool:
kirak_deploytakeshost,size,cloudandregion. A subscription’s first deploy withouthostdeploys nothing and returns the options with their prices; a Free account’s goes to its free Worker.
Unclaimed Deploys and Claiming
Section titled “Unclaimed Deploys and Claiming”Without kirak login (or KIRAK_API_KEY), kirak deploy still deploys: it creates an unclaimed instance on
Kirak’s hosting, with no account or email. The output then has, besides the public URL:
Claim URL:the page where you claim the instance. Sign in there and enter the claim code to make it yours; an unclaimed instance is temporary.Expires:when the unclaimed instance stops, and a note when an unclaimed instance does not run part of the project yet.
With --json, these are data.claim_url, data.expires_at and data.restricted. Redeploying from the same
folder updates the same instance until it is claimed. The CLI keeps the claim token and code in
.kirak/deploy.json (gitignored; never commit it) and the project’s id in .kirak/project.json (commit it).
After the claim, deploy with kirak login. The lifetime of an unclaimed instance and the free tier’s terms are
at kirak.io/deploy.
kirak deploy claim-code
Section titled “kirak deploy claim-code”Shows the 8-character claim code of the target’s unclaimed deploy. After five wrong codes the claim locks;
--new makes a new code, which unlocks it.
kirak deploy claim-codekirak deploy claim-code --new| Option | Flag | Description |
|---|---|---|
--new |
- |
Make a new claim code (the old one stops working) and reset the five-try lockout. |
--target |
-t |
Deployment target (default: production). |
--dir |
- |
Path to the project root directory. |
--json |
- |
Output structured facts envelope. |
Exits with code 1 when the target has no unclaimed deploy (no_unclaimed_deploy: already claimed, or never
deployed) or, with --new, no claim token (no_claim_token) or an instance that has expired (instance_expired: deploy again for a new one).
Data-Loss Protection Workflow
Section titled “Data-Loss Protection Workflow”A deployment that would drop database tables or columns is stopped before anything changes on the server:
- Interactive Terminal: The CLI displays each table and column at risk and prompts:
This will permanently delete data. Proceed? (y/N). Replyingyescontinues the deploy with the drops accepted. - Non-Interactive / CI /
--jsonRuns: The CLI refuses the deployment and lists the dropped tables/columns, unless--forceor--allow-data-losswas provided. - MCP Tool: The
kirak_deployMCP tool never auto-accepts data loss; runkirak deployin a terminal to confirm destructive changes.
Warnings From the Deployment Service
Section titled “Warnings From the Deployment Service”A deploy that goes live can still come back with warnings: kirak validate warnings the service found, and the service’s own, such as a feature the target cannot run (on the Kirak free tier: a local storage instance, a transaction() call, a host setting its network does not allow) or a .env key it did not keep. They are listed after the result (in problems with --json) and do not change the exit code.
kirak deploy claim-code
Section titled “kirak deploy claim-code”Inspects or rotates the 8-character claim code (XXXX-XXXX) for deployments created without a prior login:
# Print active claim codekirak deploy claim-code
# Rotate and generate a fresh claim codekirak deploy claim-code --new
# JSON envelope: {"claim_code", "rotated"}kirak deploy claim-code --jsonkirak logs
Section titled “kirak logs”Fetches a deployment’s result from Studio (the newest by default), or the running app’s recent log lines with --app.
# The newest deployment's result for production (default)kirak logs
# One deployment: the job_id that `kirak deploy` printedkirak logs --deploy 1234
# Wait for a deployment to finish, printing each stepkirak logs --follow
# The running app's last 200 log lines (paid plan)kirak logs --app --lines 200
# Output as structured JSON envelopekirak logs --json| Option | Flag | Description |
|---|---|---|
--target |
-t |
Deployment target name (default: production). |
--deploy |
Deploy job ID (the job_id from kirak deploy). Default: the newest deployment. |
|
--follow |
-f |
Poll every 2 seconds until the deployment stops (validated, rejected or failed), printing each state and step to stderr, then show the result. Gives up with follow_timeout after 30 minutes. |
--app |
Show the running app’s recent log lines instead of a deployment’s result. Paid plan only. Cannot be combined with --deploy or --follow. |
|
--lines |
-n |
With --app: how many lines, 1-500 (default 100). |
--dir |
-d |
Path to the project root directory. |
--json |
- |
Output structured facts envelope (see below). |
- Displayed Information: Reports the deployment’s current
State(queued,validating,validated,rejectedorfailed), activeStep, deployedVersion, liveURL, timestamps (Started,Finished), and any reportedProblems,Warnings, orErrors. - A failed app: When a paid deployment’s new revision does not start (
START_FAILED) or fails its smoke test (SMOKE_FAILED), the error carries the app’s last log lines (up to 100) inerror.details.logs, each{timestamp, level, message}, andkirak logsprints them under “App output”. The failedkirak deployprints them too, and with--jsonreturns them asdata.logs(datais otherwisenullon a failed deploy). - JSON records:
--jsonaddsrecords, one list of{timestamp, stage, level, message}: the validation problems (stagevalidate), the warnings (deploy), the error (the step it stopped at), and the failed app’s lines (runtime). With--app,data.linesholds the lines as Studio sent them (timestamp,level,logger,message,request_id) andrecordsthe same lines withstageruntime. - Authentication: Requires an active session (
kirak loginorKIRAK_API_KEY) or an active deployment claim token stored in.kirak/. - No Deployment Found: Reports
no_projectifkirak deployhas not been run for the project,no_logsif no deployment records exist (or none with the--deployID), andbad_deploy_idfor an ID that is not a number. With--app:not_deployedwhen the app is not running, andlogs_errorwith Studio’s message on the free plan (APP_LOGS_UNSUPPORTED) or when the logs cannot be read right now.
kirak login & kirak logout
Section titled “kirak login & kirak logout”Authenticates the CLI with Kirak Cloud:
# Interactive browser sign-inkirak login
# Non-interactive JSON output (URL and code printed to stderr)kirak login --json
# Clear active sessionkirak logoutThe stored login belongs to the Studio URL it was issued for, and the CLI sends it only to that URL: after changing KIRAK_STUDIO_URL, run kirak login again. Studio URLs must use https://; http:// is accepted only for localhost and 127.0.0.1. KIRAK_API_KEY is not tied to a URL: it is sent to whatever KIRAK_STUDIO_URL names, so the same https rule applies. The credentials file is created owner-only (mode 0600) on POSIX systems; on Windows it gets the ACL of the user profile. If the OS keyring is unavailable and the owner-only file cannot be created, kirak login fails rather than storing the token with looser permissions.
When the deploy service refuses the stored login token (expired or revoked), kirak deploy reports SESSION_EXPIRED and kirak env push, kirak logs and kirak db status --deployed report session_expired, with “Session expired. Run ‘kirak login’ to re-authenticate.” When the refused token came from KIRAK_API_KEY, the message says the key was refused instead: set a valid key, or unset it and run kirak login.