Skip to content

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.

Terminal window
kirak --help
kirak --version # prints e.g. "kirak 0.1.1"

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 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.

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.


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"]
end

Scaffolds a new Kirak application directory with pre-configured schemas, models, hooks, and agent instructions.

Terminal window
# Standard scaffolding (defaults to MySQL)
kirak new my-api
# PostgreSQL project
kirak 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 --here
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.
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 Kirak

src/ 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.


Inspects and reports project facts by reading local files without importing project code or connecting to a database.

Terminal window
kirak info
kirak info --json
kirak info --dir ../other-project
  • kirak_version: Installed version of Kirak runtime.
  • project_root: Absolute path to project root.
  • manifest: Current kirak.json configuration merged with kirak.local.json.
  • modules: List of enabled modules.
  • models: Model layout (directory vs file), 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.

Performs multi-layered static verification across models, manifest settings, agents, MCP tools, and Python code.

Terminal window
# Validate entire project
kirak validate
# Validate specific subsystem
kirak validate models
kirak validate manifest
kirak validate agents
kirak validate mcp
# Test a draft file before writing it to disk
kirak validate models --file ./draft_model.json
# Test a single file replacement
kirak 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 errors
kirak validate --strict --json
  1. Schema Compliance: Validates every JSON file against .kirak/*.schema.json. A project with no models is valid: a models/ folder that is missing or empty starts with only the built-in tables.
  2. Referential Integrity: Verifies foreign keys, relation references, and hook names.
  3. Secret Leak Detection: Rejects credentials, private keys, or passwords written inside kirak.json or model files.
  4. Python Code Inspection (--code): Uses AST parsing to check that hooks subscribe to valid events without executing arbitrary code.

Explores the Kirak catalog of modules and pluggable backends.

Terminal window
# List all built-in modules
kirak modules
# Inspect a specific module in detail
kirak modules payments
kirak modules payments --json
# List providers for a module
kirak providers storage
# Inspect a specific provider's configuration schema
kirak providers storage aws_s3
kirak providers storage aws_s3 --json

Dumps the complete Kirak runtime catalog as a single comprehensive document. Includes all modules, providers, parameter specifications, hook events, and social backends.

Terminal window
kirak catalog --json > catalog.json

Scans kirak.json and reports every environment variable required by enabled modules and configured providers.

Terminal window
kirak env
kirak env --json

Output 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_KEY

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.

Terminal window
# Push secrets from .env in project root to production target
kirak env push
# Push to a specific deployment target (default: production)
kirak env push --target staging
# Push from a custom env file
kirak env push --file prod.env
# Dry run: view what variables would be pushed (values masked as ***)
kirak env push --dry-run
kirak 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 from kirak.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 login or KIRAK_API_KEY) or an active deployment claim token. Without them, reports not_authenticated or no_project (exit code 2).

Exports JSON Schemas corresponding to the currently installed Kirak version into .kirak/.

Terminal window
# Export all schemas to .kirak/
kirak schema
# Print a specific schema to stdout
kirak schema --print model
kirak schema --print manifest

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).

Terminal window
# Local development: http://127.0.0.1:8000, restarting when a project file changes
kirak run
# Another app module, host or port
kirak 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.


Canonically formats kirak.json, models/*.json (or models.json), agents/*.json, and mcp/*.json with standard 2-space indentation and consistent key ordering.

Terminal window
# Format all project JSON declarations in place
kirak fmt
# Check formatting without modifying files (exits 1 if unformatted files exist)
kirak fmt --check
# Format a specific project directory
kirak 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, --check prints paths of unformatted files to stderr and exits with code 1 (or exit code 0 if all files conform).
  • JSON Syntax Errors: If any target file contains invalid JSON syntax, prints the parse error and exits with code 1.

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.

Terminal window
# What upgrading changes; writes nothing
kirak upgrade check
# The changes as diffs (dry run)
kirak upgrade
# Write them and set kirak_version to the installed Kirak
kirak upgrade --apply

Upgrading a project:

Terminal window
pip install -U kirak
kirak upgrade check
kirak upgrade --apply
kirak validate
kirak db makemigrations # when Kirak's own tables changed
  • What a step changes: JSON only: kirak.json, kirak.local.json, the model files, agents/*.json and mcp/*.json. A changed file is written in kirak fmt format. Python files (hooks, custom routes) are never rewritten: a step reports what to change in them as an upgrade_needs_human warning with the file.
  • kirak upgrade check reports: kirak_version against the installed Kirak (status: current, behind, ahead or unknown), the steps that would run, each file change as a unified diff, the kirak validate problems left once the changes are made, Kirak’s own tables that migrations/models_snapshot.json does not have yet or has in another shape (builtin_tables: added, changed; null without a snapshot), and schemas in .kirak/ exported from another version (schemas_stale).
  • kirak upgrade --json: data has project_kirak_version, installed_kirak_version, status, steps (id, version, summary), changes (file, diff) and written (the files written; empty on a dry run).
  • Refusals: a project written for a newer Kirak than the installed one exits 1 with kirak_version_ahead; an invalid kirak_version with kirak_version_invalid; a project JSON file that is not valid JSON with upgrade_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 --apply adds 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.

Terminal window
# CREATE TABLE of kirak_migrations for a dialect (mysql, postgresql, sqlite)
kirak migration-table --dialect postgresql --json
# Plan from a JSON request on stdin
echo '{"dialect": "sqlite", "previous_models": {}, "models": {...}, "modules": [], "confirm_drops": false}' \
| kirak migration-plan --json
  • mode: "plan" (default) returns statements, models, models_json, checksum, drops and notes. "pending" returns added, dropped and refused, what a deploy would change.
  • Refusals: a dropped table or column without confirm_drops exits 1 with problem drops_need_confirmation and the list in data.drops. A change the deploy cannot apply exits 1 with problem migration_refused and data.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 notes names each rebuilt table. Only the columns both model sets have are copied, so a dropped column is left behind by the rebuild and still needs confirm_drops. A rebuild that breaks a new constraint, such as required added while a row holds NULL, 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.

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 successfully

Generates and applies the initial database migration based on the project’s models and Kirak’s internal system tables (e.g. auth, rate limits).

Terminal window
kirak db init
kirak db init --name initial_schema

Compares the current models/ definitions against migrations/models_snapshot.json and generates a new SQL migration file.

Terminal window
# Generate migration file
kirak db makemigrations add_user_avatar
# Dry run: view generated SQL without writing migration files
kirak db makemigrations --dry-run
kirak 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 makemigrations refuses to generate the migration unless explicit confirmation is provided.


Applies all pending migrations to the configured database.

Terminal window
kirak db migrate
  • Acquires a migration lock to prevent concurrent deployment conflicts.
  • Executes migrations sequentially. On PostgreSQL and SQLite each file and its kirak_migrations row 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_migrations table.

Shows the execution status of all migrations (applied, pending, or modified).

Terminal window
kirak db status
kirak db status --json
kirak db status --deployed
kirak db status --deployed --target staging --json

Without --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 is required with 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.


Compares current models against another project directory to identify schema divergence:

Terminal window
kirak db diff --against ../staging-project
kirak db diff --against ../staging-project --json

Drops all tables and resets the database schema. Strictly limited to development environments.

Terminal window
kirak db reset --force

Starts an internal Model Context Protocol (MCP) server over stdio. Designed for AI coding tools (Claude Code, Cursor, Codex, Gemini/Antigravity).

Terminal window
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.

Inspects an MCP server definition (mcp/*.json) and estimates context token costs for LLMs:

Terminal window
kirak mcp inspect assistant

Output includes:

  • Exposed tool names and schemas.
  • Estimated prompt token consumption.
  • Ready-to-copy client configuration blocks for Claude Code, Cursor, and VS Code.

Deploys the application directly to the Kirak deployment service and prints its public URL.

Terminal window
# Deploy to production target (default)
kirak deploy
# Deploy to a specific target
kirak deploy --target staging
# Choose where a first deploy runs (logged in): Workers, Cloud Run or a dedicated server
kirak deploy --host workers
kirak deploy --host cloud_run
kirak deploy --host cloud_run --size scaling
kirak 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 stop
kirak deploy --options
# Accept schema changes that drop tables or columns, without interactive prompt
kirak deploy --allow-data-loss
# Non-interactive CI mode: accept schema drops reported by the deployment service
kirak deploy --force
# JSON output envelope
kirak 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.

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.

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.

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 --host in 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 --host in 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 (in data with --json), the problem is HOST_REQUIRED and the exit code is 1. Pass --host (and --size for vps). 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 --host does not move it.
  • Without a login, kirak deploy makes the unclaimed preview described below, which has no choice. --host then fails with NOT_LOGGED_IN.
  • A bad combination (a --host that is not one of the four, --host vps without --size, --size with --host workers) is BAD_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 byoc without --cloud, and --cloud or --region without --host byoc, are BAD_HOST too; a size or region the cloud does not offer, a Cloud Run type that is not fixed or scaling, 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 is BAD_CREDENTIALS.
  • MCP tool: kirak_deploy takes host, size, cloud and region. A subscription’s first deploy without host deploys nothing and returns the options with their prices; a Free account’s goes to its free Worker.

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.

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.

Terminal window
kirak deploy claim-code
kirak 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).

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). Replying yes continues the deploy with the drops accepted.
  • Non-Interactive / CI / --json Runs: The CLI refuses the deployment and lists the dropped tables/columns, unless --force or --allow-data-loss was provided.
  • MCP Tool: The kirak_deploy MCP tool never auto-accepts data loss; run kirak deploy in a terminal to confirm destructive changes.

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.

Inspects or rotates the 8-character claim code (XXXX-XXXX) for deployments created without a prior login:

Terminal window
# Print active claim code
kirak deploy claim-code
# Rotate and generate a fresh claim code
kirak deploy claim-code --new
# JSON envelope: {"claim_code", "rotated"}
kirak deploy claim-code --json

Fetches a deployment’s result from Studio (the newest by default), or the running app’s recent log lines with --app.

Terminal window
# The newest deployment's result for production (default)
kirak logs
# One deployment: the job_id that `kirak deploy` printed
kirak logs --deploy 1234
# Wait for a deployment to finish, printing each step
kirak logs --follow
# The running app's last 200 log lines (paid plan)
kirak logs --app --lines 200
# Output as structured JSON envelope
kirak 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, rejected or failed), active Step, deployed Version, live URL, timestamps (Started, Finished), and any reported Problems, Warnings, or Errors.
  • 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) in error.details.logs, each {timestamp, level, message}, and kirak logs prints them under “App output”. The failed kirak deploy prints them too, and with --json returns them as data.logs (data is otherwise null on a failed deploy).
  • JSON records: --json adds records, one list of {timestamp, stage, level, message}: the validation problems (stage validate), the warnings (deploy), the error (the step it stopped at), and the failed app’s lines (runtime). With --app, data.lines holds the lines as Studio sent them (timestamp, level, logger, message, request_id) and records the same lines with stage runtime.
  • Authentication: Requires an active session (kirak login or KIRAK_API_KEY) or an active deployment claim token stored in .kirak/.
  • No Deployment Found: Reports no_project if kirak deploy has not been run for the project, no_logs if no deployment records exist (or none with the --deploy ID), and bad_deploy_id for an ID that is not a number. With --app: not_deployed when the app is not running, and logs_error with Studio’s message on the free plan (APP_LOGS_UNSUPPORTED) or when the logs cannot be read right now.

Authenticates the CLI with Kirak Cloud:

Terminal window
# Interactive browser sign-in
kirak login
# Non-interactive JSON output (URL and code printed to stderr)
kirak login --json
# Clear active session
kirak logout

The 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.