/nocobase-dev:cli-recipesfrom nocobase-dev
Use when the user asks how to install or run NocoBase from the terminal — "install nb CLI", "how do I bootstrap NocoBase", "run nb commands", "start/stop/upgrade NocoBase", "add an environment", "backup NocoBase", "enable a plugin". Provides the install one-liner (`@nocobase/cli`, stable channel), the env, lifecycle, plugin and backup recipes in their `nb` 2.2 canonical forms, and a routing table that hands deeper tasks to the upstream `nocobase-env-manage`, `nocobase-plugin-manage`, and `nocobase-publish-manage` skills.
Ships in nocobase-dev. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
The nb CLI is the canonical way to bootstrap and operate a NocoBase v2 project from a terminal. This skill covers install, the most-used commands in their canonical (2.2) spelling, and where to go for deeper topics. Command forms below were checked against @nocobase/cli 2.2.20; always confirm an exact flag with nb <group> <command> --help before relying on it.
npm install -g @nocobase/cli # stable channel (`latest`)
nb --version
Requirements: Node.js 22 or newer, Yarn 1.x, npm, and Docker if you choose the Docker install source or the built-in database. pnpm is needed only when developing an AI Portal. To connect an agent to an existing NocoBase, the app must be 2.1.0 or newer. If the install errors with EACCES, configure a user-level npm prefix (npm config set prefix "$HOME/.npm-global") rather than running with sudo.
Channels: the stable @nocobase/cli (latest) is the default for everything in this plugin. The @alpha channel is needed only for nb portal (Portal lifecycle), which stable and beta do not contain — see overview. Update the CLI itself with nb self check / nb self update.
mkdir my-nocobase && cd my-nocobase
nb init --ui
nb init --ui opens a browser-based setup wizard. Its first step chooses install a new app, manage a local app, or connect a remote app. The CLI keeps the process running until the user finishes the wizard — set a 30-minute timeout and do not interrupt it. Terminal-only variants: nb init (interactive prompts) and nb init --env <name> -y (defaults, no prompts; add --setup-mode connect-remote --api-base-url <https://host/api> --auth-type oauth to connect an existing app instead of installing).
In a sandboxed environment where the CLI cannot open a browser:
nb init also installs the upstream NocoBase skills (the same set bundled here) — that is intentional and harmless; skip it with --skip-skills, and manage them later with nb skills check|install|update|remove.
→ Detailed rules and edge cases live in nocobase-env-manage.
An env is a named NocoBase endpoint plus its credential, stored by the CLI. Every runtime command takes -e, --env <name> and defaults to the current env.
# Save an endpoint (the URL includes the /api prefix) and sign in
nb env add prod --api-base-url https://app.example.com/api --auth-type oauth
nb env auth prod # re-authenticate: --auth-type basic|token|oauth
nb env list # all envs
nb env use prod # switch the current env
nb env current
nb env info prod # app, database, API and auth details (secrets masked)
nb env status # runtime status; `nb env status --all` for every env
nb env update prod # re-sync the env and refresh generated `nb api` commands
nb env remove prod
--auth-type oauth uses the OAuth device flow when the server supports it (it prints a verification URL and code, so it works on a headless server) and falls back to a browser loopback flow otherwise; it needs the IdP: OAuth plugin. --auth-type token takes an API key (--access-token), --auth-type basic takes --username / --password. When an explicit --env differs from the current env in a non-interactive session, add --yes (or run nb env use <name> first).
# Run / stop / restart the app of the current env (or pass --env <name>)
nb app start
nb app stop
nb app restart
# Pull a new release without losing data
nb app upgrade # --force skips the confirmation; --version <tag> pins one
# Inspect what's running
nb env status # runtime status
nb env info # full details
nb app logs --tail 200 --no-follow # recent logs (pm2 logs for local installs, docker logs for Docker)
The flat forms (start, stop, restart, upgrade, logs) still run as hidden aliases, but write the canonical nb app … forms. There is no flat status command — use nb env status, nb env info or nb app logs.
nb plugin list # all plugins, with enabled/disabled state
nb plugin enable @nocobase/plugin-api-keys # one or more package names
nb plugin disable @nocobase/plugin-api-keys
nb plugin import <archive.tgz | https-url | npm-spec> # unpack a packaged plugin into storage/plugins (does not enable it)
nb plugin takes full package names (@nocobase/plugin-…). nb pm is a hidden alias that only offers list, enable and disable; there is no install-from-registry or remove command — bring a plugin in with nb plugin import, then nb plugin enable. Built-in plugins (API keys, IdP: OAuth, MCP server, …) need no import.
→ For the full grammar and error handling, load nocobase-plugin-manage. That skill enforces "no docker/api/manual fallback chains" — only direct nb plugin commands.
# Create a backup on the env and download it
nb backup create --output ./backups/ --json-output
# Restore a local backup file into an env (overwrites application data — confirm with the user first)
nb backup restore --file ./backups/<file>.nbdump --env <env> --force
# Server-side backups and cross-environment migrations are `nb api` groups
nb api backup list -e staging
nb api migration rules list -e staging
nb api migration create --help # then: get, check, execute, download, logs, list
nb backup {create,restore} is the file-based front door. The server-side surface is nb api backup {create,list,status,download,remove,restore,restore-upload,restore-status} and nb api migration {rules,create,check,execute,download,logs,list,get,remove} — those groups are generated from the app's OpenAPI, so confirm exact flags with -h.
→ The full publish playbook (selective backups, partial restores, version compatibility, dev→prod migration order) lives in nocobase-publish-manage.
nb api surfacenb api … has two parts: the built-in nb api resource list|get|create|update|destroy|query for any collection, and generated groups built from the connected app's OpenAPI schema when you run nb env add / nb env update. The available groups therefore depend on the app version and its enabled plugins — inspect them with nb api --help and nb api <group> --help.
nb api data-modeling collections list -j
nb api data-modeling collections get --filter-by-tk posts --appends fields -j
nb api resource list --resource users --filter '{}' --page-size 20 -j
nb api workflow workflows list -j
nb api flow-surfaces apply-blueprint --body-file blueprint.json -j
nb api acl roles list -e prod -j
Shared conventions: -e/--env, --api-base-url, -t/--token (API key override), --role (sent as X-Role), and -j/--json-output (raw JSON, on by default; --no-json-output for tables). Query parameters become kebab-case flags (--filter-by-tk, --page-size, --appends); write bodies go in --body '<json>' or --body-file <path> (mutually exclusive — prefer the file for anything non-trivial).
Each upstream skill documents the subcommands it owns:
| Sub-command family | Skill |
|---|---|
nb api flow-surfaces … (UI authoring) | nocobase-portal-manage → nocobase-ui-builder |
| `nb api data-modeling collections | fields |
| `nb api workflow workflows | flow-nodes |
| `nb api acl roles | data-sources …`, role-mode toggles |
nb api ai … (LLM providers/services, employees), nb api kb … | nocobase-ai-manager, nocobase-ai-employee, nocobase-ai-knowledge-base-manager |
nb api backup …, nb api migration … | nocobase-publish-manage |
Always reach for the specialist skill first — it has the per-command argument tables, safety rules, and worked examples. A manual workflow run is the one case where the REST call is the documented portable path: POST /api/workflows:execute?filterByTk=<workflowId> (see examples).
If the user explicitly asks for a YAML/DSL "committed-to-git" build flow, hand off to nocobase-dsl-reconciler — it owns cli push, the workspaces/ layout, and reconciliation logic. Do not invoke the DSL path for ad-hoc UI tweaks; use nocobase-portal-manage instead (live API, no commit needed).
| Task | One-liner |
|---|---|
| Install | npm install -g @nocobase/cli |
| Bootstrap (interactive) | nb init --ui |
| Add and sign in to an env | nb env add <name> --api-base-url <url>/api --auth-type oauth |
| Run / stop | nb app start / nb app stop |
| Upgrade in place | nb app upgrade |
| Status / logs | nb env status / nb app logs |
| Enable a plugin | nb plugin enable @nocobase/plugin-<name> |
| Backup | nb backup create --output <dir> |
| Restore | nb backup restore --file <path> --force |
| Migrate environments | nb api migration … (see nocobase-publish-manage) |
| Apply a UI blueprint | nb api flow-surfaces apply-blueprint --body-file <payload>.json -j |
| Run a workflow manually | POST /api/workflows:execute?filterByTk=<id> |
nb env — the CLI keeps its envs locally.For everything else, prefer nb when it is available; it carries fewer auth and CORS pitfalls than raw HTTP.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub agents-store/claude-plugins --plugin nocobase-dev25 skills in this plugin
/api-referenceReference-only skill (loaded on demand) that maps the NocoBase v2 REST API surface — base URL, authentication, action-style endpoint convention, and pointers into the bundled OpenAPI 3.0.3 specification. Loaded by the model when it needs an exact endpoint path or schema; not auto-triggered./authUse when the user wants to authenticate to a NocoBase v2 instance, asks "how do I get a token for NocoBase", "how do I log in via API or CLI", "how do I connect an agent or MCP client", "why is my request returning 401 from NocoBase", or needs working curl/Node samples that send the bearer token. Covers the CLI path (`nb env add` / `nb env auth`), the upstream login flow (NB_USER + NB_PASSWORD → auth:signIn → token), the long-lived API Key path, OAuth through the IdP: OAuth plugin, and the separate Auth: OIDC SSO plugin./