# NocoBase CLI ## Description NocoBase CLI (`nb`) is the command-line entry point for NocoBase, used to initialize, connect to, and manage NocoBase applications in a local workspace. It supports two common initialization paths: * Connect to an existing NocoBase application and save it as a CLI env * Install a new NocoBase application via Docker, npm, or Git, then save it as a CLI env When creating a new local application, [`nb init`](/api/cli/init.md) can also install or update NocoBase AI coding skills. To skip this step, use `--skip-skills`. ## Usage ```bash nb [command] ``` The root command itself is mainly used to display help and dispatch invocations to command groups or standalone commands. ## Command groups (Topics) The following command groups are shown in `nb --help`: | Command group | Description | | ------------------------------------ | --------------------------------------------------------------------------------------------- | | [`nb api`](/api/cli/api/index.md) | Call NocoBase APIs through the CLI. | | [`nb app`](/api/cli/app/index.md) | Manage the application runtime: start, stop, restart, logs, and upgrade. | | [`nb backup`](/api/cli/backup/index.md) | Create backups and download them locally, or restore a local backup file to the target env. | | [`nb config`](/api/cli/config/index.md) | Manage CLI default configuration. | | [`nb db`](/api/cli/db/index.md) | Manage the built-in database of the selected env. | | [`nb env`](/api/cli/env/index.md) | Manage NocoBase project environments, the current env, status, details, and runtime commands. | | [`nb license`](/api/cli/license/index.md) | Manage commercial licenses and licensed plugins. | | [`nb plugin`](/api/cli/plugin/index.md) | Manage plugins in the selected NocoBase env. | | [`nb portal`](/api/cli/portal/index.md) | Manage a Portal's local source directory: configure, create, develop, sync source, deploy, and destroy. | | [`nb scaffold`](/api/cli/scaffold/index.md) | Generate scaffolding for NocoBase plugin development. | | [`nb self`](/api/cli/self/index.md) | Check or update NocoBase CLI itself. | | [`nb session`](/api/cli/session/index.md) | Configure `NB_SESSION_ID` so the current env is isolated by shell or agent runtime. | | [`nb skills`](/api/cli/skills/index.md) | Check or sync NocoBase AI coding skills in the current workspace. | | [`nb source`](/api/cli/source/index.md) | Manage local source projects: download, develop, build, and test. | ## Commands Standalone commands currently exposed directly by the root command: | Command | Description | | ---------------------- | ---------------------------------------------------------- | | [`nb init`](/api/cli/init.md) | Initialize NocoBase so coding agents can connect and work. | ## Viewing help View help for the root command: ```bash nb --help ``` View help for a command or command group: ```bash nb init --help nb app --help nb backup --help nb config --help nb api resource --help nb license --help nb portal --help nb portal config --help ``` ## Examples Interactive initialization: ```bash nb init ``` Initialize using a browser form: ```bash nb init --ui ``` Create a Docker application non-interactively: ```bash nb init --env app1 --yes --source docker --version alpha ``` Connect to an existing application: ```bash nb env add app1 --api-base-url http://localhost:13000/api nb env current nb env status ``` Resync env status after starting the application: ```bash nb app start -e app1 nb env update app1 ``` Call an API: ```bash nb api resource list --resource users -e app1 ``` View CLI default configuration: ```bash nb config list nb config get docker.network ``` View commercial license status: ```bash nb license status -e app1 nb license plugins list -e app1 ``` Create and develop a portal: ```bash nb portal create customer -e app1 --yes nb portal config customer -e app1 --yes --source-storage git --git-repo git@github.com:nocobase/customer-portal.git nb portal dev customer -e app1 --yes nb portal deploy customer -e app1 --yes ``` Create and download a backup: ```bash nb backup create -e app1 --output ./backups ``` Restore a local backup: ```bash nb backup restore -e app1 --file ./backups/backup_20260520_190408_8397.nbdata --yes --force ``` ## Environment variables The following environment variables affect CLI behavior: | Variable | Description | | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | | `NB_CLI_ROOT` | Root directory where the CLI stores `.nocobase` configuration and local application files. Defaults to the current user's home directory. | | `NB_LOCALE` | CLI prompt language and local initialization UI language. Supports `en-US` and `zh-CN`. | | `NB_SESSION_ID` | Session ID for the current shell or agent runtime. When set, `nb env use` and `nb env current` are isolated by session. | Example: ```bash export NB_CLI_ROOT=/your/workspace export NB_LOCALE=zh-CN ``` ## Configuration files Default configuration file: ```text ~/.nocobase/config.json ``` After setting `NB_CLI_ROOT=/your/workspace`, the configuration file path becomes: ```text /your/workspace/.nocobase/config.json ``` The CLI is also compatible with reading legacy project configuration in the current working directory. The session-level cache for the current env is stored in: ```text .nocobase/sessions/.json ``` The globally last-used env is stored in the `lastEnv` field of `config.json`. When `NB_SESSION_ID` is not set, the CLI falls back to this global value. The runtime command cache is stored in: ```text .nocobase/versions//commands.json ``` This file is generated or refreshed by [`nb env update`](/api/cli/env/update.md) and is used to cache runtime commands synchronized from the target application. ## Related links * [Quick Start](/ai/quick-start.md) * [Global Environment Variables](/api/app/env.md) * [AI Builder](/ai-builder/index.md) * [Plugin Development](/plugin-development/index.md)