Skip to content

CLI Overview ​

The Nanokit CLI, invoked via the nkapp command, is the central tool for managing your application's lifecycle. It handles everything from local development bootstrapping to remote cloud orchestration.

Installation ​

Nanokit is distributed as a global npm package (@nkapp/cli) or can be run via npx.

bash
npm install -g @nkapp/cli
nkapp --version

Global Flags ​

Most commands support these flags to ensure consistency across different environments and automation flows:

FlagDescription
-e, --env <env>Specifies the target environment (e.g., local, stage, production). Defaults to local for most commands (stage for deploy).
-y, --yesSkips interactive confirmation prompts. Essential for CI/CD pipelines.
-V, --versionPrints the CLI version.
--helpShows help for any command or subcommand.

There is no global --verbose flag. Use nkapp doctor for diagnostics and nkapp logs for service output.

up vs deploy ​

These two commands were split, and the division of labour is the single most important thing to know about the CLI:

nkapp upnkapp deploy
Ownsservice reconcileprovisioning · host bootstrap · code sync · service reconcile
Infrastructure plan/applyskipped by default (--infra opts in)yes
Remote code syncskipped by default (--sync opts in)yes
Typical useinner loop, local and remoteshipping a change to a target

--legacy (or NANOKIT_UP_LEGACY=1) restores the pre-split up pipeline.

Execution Workflow ​

When you run nkapp up, Nanokit follows a deterministic multi-stage workflow:

  1. Config Validation: The nanokit.yml file is parsed and validated against the Zod schema.
  2. Environment Merging: Environment-specific overrides are applied to the global configuration.
  3. Secret Resolution: All vault:// or env:// references are resolved into actual values.
  4. Infrastructure Planning (opt-in on up; always on deploy): Nanokit compares the desired state with the current state of the provider.
  5. Action: The plan is applied, creating or updating resources as needed.

Command Reference ​

Lifecycle Commands ​

The primary commands you'll use daily to manage your stack:

CommandDescription
nkapp upReconcile services (change-proportional); infra + sync are opt-in
nkapp runDeprecated alias of up — use nkapp up
nkapp startStart stopped services without recreating containers
nkapp stopStop running services without removing them
nkapp restartRestart running services
nkapp destroyStop and remove services (keeps volumes by default)
nkapp cleanFull project reset: wipe remote infra and local state
nkapp teardownState-free, tag-based remote teardown for CI/CD
nkapp planStrictly read-only preview of upcoming changes

Deployment ​

CommandDescription
nkapp deployProvision, sync and deploy to a VPS via SSH (or a cloud provider)
nkapp migrateMove an environment to a different deploy target
nkapp ci initScaffold a GitHub Actions / GitLab CI workflow that runs nkapp deploy
nkapp export k8sTranslate nanokit.yml into Kubernetes manifests (offline)
nkapp export helmGenerate a parameterized Helm chart from nanokit.yml (offline)
nkapp import k8sScaffold a nanokit.yml from existing Kubernetes manifests (offline)

Observability ​

CommandDescription
nkapp hubOpen the Nanokit Hub (Bridge) — aliases: bridge, dashboard
nkapp logsStream logs from project services
nkapp shellOpen an interactive terminal in a service or database
nkapp doctorRead-only environment health check
nkapp certsRead-only TLS certificate inventory (gateway storage + live probe)

Host Hygiene ​

Three prune commands with the same shape: a mandatory side-effect-free preview, explicit guards, and an --ssh host override. None of them is wired into up/deploy — detection is automatic in doctor, removal stays explicit.

CommandDescription
nkapp volumes pruneRemove orphaned Nanokit-managed volumes
nkapp containers pruneRemove stale (exited/created, aged-out, unclaimed) containers
nkapp images pruneReclaim Docker image space (dangling by default)

Database Management ​

CommandDescription
nkapp dbManage database lifecycle, branching, resets and password rotation
nkapp backupTake manual backups and manage the backup catalog
nkapp restoreRestore a database from a backup

Configuration Management ​

CommandDescription
nkapp configUnified command to manage all project settings
nkapp serviceAdd, remove, or modify services in nanokit.yml
nkapp hostManage project hostnames, SSL trust, and remote bootstrapping
nkapp secretsManage secrets and Vault integration
nkapp envList and sync environment variables
nkapp infraManage cloud infrastructure settings
nkapp infra destroyForcefully wipe all remote infrastructure

Account, Providers & Teams ​

CommandDescription
nkapp authConnect the CLI to your Nanokit account
nkapp provider authManage cloud provider credentials
nkapp teamManage teams, invites, and role-based access

Agents ​

CommandDescription
nkapp mcpStart the MCP server for an AI agent host; approve, deny and audit agent requests

Bootstrapping & Maintenance ​

CommandDescription
nkapp configureInteractive wizard for a new project (refuses if nanokit.yml exists)
nkapp initInitialize a new Nanokit project
nkapp updateUpdate the CLI to the latest published version