Skip to content
API Blog

CLI Reference

The Lobu CLI (@lobu/cli) scaffolds local project files, runs the embedded server, and manages org/agent configuration through the same REST API used by the web app.

Terminal window
# Run directly (no install)
npx @lobu/cli@latest <command>
# Or install globally
npm install -g @lobu/cli
lobu <command>

Scaffold a local agent project with lobu.config.ts, .env, and an agent directory.

Terminal window
npx @lobu/cli@latest init my-agent

Generates:

  • lobu.config.ts: the TypeScript project entrypoint (defineConfig from @lobu/cli/config)
  • package.json + tsconfig.json: declare @lobu/cli / @lobu/connector-sdk and give the editor type resolution
  • .env — local environment variables (API keys, optional external DATABASE_URL)
  • agents/{name}/IDENTITY.md, SOUL.md, USER.md, skill files, and evals
  • *.connector.ts — custom connectors, referenced from lobu.config.ts via connectorFromFile
  • *.reaction.ts — behavior reaction scripts, referenced via defineBehavior({ reaction })
  • AGENTS.md, TESTING.md, README.md, .gitignore

Interactive prompts guide you through provider, platform, network access policy, gateway port, public URL, and memory configuration. Local runs use an embedded Postgres (PG18 + pgvector) by default; set DATABASE_URL when you want to use an external Postgres.


Run the embedded Lobu stack. lobu.config.ts is not required. With no DATABASE_URL, the command starts an embedded Postgres (PG18 + pgvector) and stores data under ~/.lobu/pgdata (override with LOBU_DATA_DIR). If DATABASE_URL is set in the environment or .env, Lobu uses that external Postgres instead.

Terminal window
npx @lobu/cli@latest run
npx @lobu/cli@latest run --port 9000
npx @lobu/cli@latest dev --verbose # `dev` and `start` are aliases for `run`
FlagDescription
--port <port>Gateway port (overrides GATEWAY_PORT in .env)
--quietSuppress the startup banner; raise log level to warn
--verboseLower log level to debug
--log-level <level>Forwarded as LOG_LEVEL to the bundled server

The command spawns the bundled Node server and forwards stdio. Ctrl+C cleanly stops the server and worker subprocesses.


Authenticate with Lobu via the OAuth 2.0 device-code flow. Prints a verification URL and opens it in the browser; you approve there and the CLI receives the token.

Terminal window
npx @lobu/cli@latest login
npx @lobu/cli@latest login --token <api-token> # CI/CD
npx @lobu/cli@latest login -c staging # login to a named context
npx @lobu/cli@latest login --force # re-authenticate
FlagDescription
--token <token>Use an API token directly
-c, --context <name>Authenticate against a named context
-f, --forceRe-authenticate, revoking the existing OAuth session first

Manage named API contexts.

Terminal window
npx @lobu/cli@latest context list
npx @lobu/cli@latest context current
npx @lobu/cli@latest context add staging --url https://staging.example.com/api/v1
npx @lobu/cli@latest context use staging

Environment overrides: set LOBU_CONTEXT to select a context by name, or LOBU_API_URL to override the URL directly.


Manage the active organization for org-scoped API commands.

Terminal window
npx @lobu/cli@latest org list
npx @lobu/cli@latest org current
npx @lobu/cli@latest org set my-org

LOBU_ORG overrides the active org for one process.


Manage agents via the same org-scoped REST endpoints as the web app.

Terminal window
npx @lobu/cli@latest agent list
npx @lobu/cli@latest agent get my-agent
npx @lobu/cli@latest agent create my-agent --name "My Agent"
npx @lobu/cli@latest agent update my-agent --description "Handles support"
npx @lobu/cli@latest agent delete my-agent --yes

agent scaffold <agentId> adds a new local agent (agents/<id>/* plus a defineAgent entry in lobu.config.ts) without touching existing agents, the local-files counterpart of agent create:

Terminal window
npx @lobu/cli@latest agent scaffold support-bot --name "Support Bot" --description "Handles tickets"

Config helpers use the web app’s /config API:

Terminal window
npx @lobu/cli@latest agent config get my-agent --output config.json
npx @lobu/cli@latest agent config patch my-agent --file config.patch.json

Most agent commands accept --org <slug>, -c/--context <name>, and --json where useful.


Manage the org’s model (inference) providers over the same REST surface the web console and lobu apply (defineConfig({ providers })) edit — one store, many editors. Exists so a project with no lobu.config.ts can still add a provider. Secret-bearing flags take a literal value or a $ENV_VAR reference (quote it).

Terminal window
npx @lobu/cli@latest providers list
npx @lobu/cli@latest providers catalog
npx @lobu/cli@latest providers create my-openai --kind openai --key '$OPENAI_API_KEY' --model gpt-5 --default
npx @lobu/cli@latest providers update my-openai --name "My OpenAI"
npx @lobu/cli@latest providers set-key my-openai --key '$OPENAI_API_KEY'
npx @lobu/cli@latest providers set-capability my-openai text --model gpt-5
npx @lobu/cli@latest providers set-default my-openai
npx @lobu/cli@latest providers delete my-openai --yes
SubcommandDescription
listList the org’s model providers
catalogList provider kinds available to add
create <slug>Add a provider. Required: --kind <kind>, --key <value|$ENV_VAR>. Optional: --name <name>, --model <id>, --capabilities <json> (per-modality overrides, e.g. {"text":{"model":"gpt-4o"}}), --default
update <slug>Rename a provider. Required: --name <name>
set-key <slug>Rotate a provider’s API key. Required: --key <value|$ENV_VAR>
set-capability <slug> <modality>Set one modality’s model/endpoint (text, image, stt, tts). Optional: --model <id>, --base-url <url>, --models-endpoint <path>
set-default <slug>Make a provider the org default
delete <slug>Delete a provider. Optional: --yes to confirm

Subcommands accept --org <slug>; read-facing ones (list, catalog, create, update) also accept --json.


Manage sandbox environments — the runtime providers agents use to execute code.

Terminal window
npx @lobu/cli@latest environment list
npx @lobu/cli@latest environment create my-sandbox --provider vercel --credential 'token=$VERCEL_TOKEN'
npx @lobu/cli@latest environment set-credential my-sandbox --credential 'token=$VERCEL_TOKEN'
npx @lobu/cli@latest environment delete my-sandbox --yes
SubcommandDescription
listList environments
create <name>Create an environment. Required: --provider <kind>. Optional: --credential <key=value|key=$ENV_VAR> (repeatable, quote it)
set-credential <id>Set or rotate an environment’s credential. Required: --credential <key=value|key=$ENV_VAR> (repeatable)
delete <id>Delete an environment. Optional: --yes to confirm

Subcommands accept --org <slug>; list and create also accept --json.


List and revoke connected clients — MCP apps and messaging integrations bound to the org.

Terminal window
npx @lobu/cli@latest clients list
npx @lobu/cli@latest clients list --agent my-agent
npx @lobu/cli@latest clients revoke <clientId> --yes
SubcommandDescription
listList connected clients. Optional: --agent <agentId> to filter to one agent
revoke <clientId>Revoke an MCP client’s tokens and sessions. Optional: --yes to confirm

Subcommands accept --org <slug>; list also accepts --json.


Invoke an admin REST tool by name (POST /api/<org>/<tool>). One entry point over the same UI-callable tool surface, instead of a bespoke command per action. Run with --list or no arguments to discover available tools. (lobu memory run is the MCP JSON-RPC counterpart; call routes through the REST proxy.)

Terminal window
npx @lobu/cli@latest call # list tools (default when called bare)
npx @lobu/cli@latest call --list --all # include internal/admin-only tools
npx @lobu/cli@latest call sync_connection --arg connection_id:=42
npx @lobu/cli@latest call some_tool --input-file args.json --raw
FlagDescription
--listList tools available to the current token (default when called bare)
--allInclude internal/admin-only tools in --list output
--input-file <path>Read the JSON args body from a file (top-level object)
--arg <entry>Add a top-level arg as key=string or key:=<json> (repeatable)
--rawEmit compact JSON (default is pretty-printed)
--url <url>Server URL override
--org <slug>Org slug override
--jsonPrint the full JSON response

Send a prompt to an agent and stream the response to the terminal.

Terminal window
npx @lobu/cli@latest chat "What is the weather?"
npx @lobu/cli@latest chat "Hello" --agent my-agent --thread conv-123
npx @lobu/cli@latest chat "Check my PRs" --user telegram:12345
npx @lobu/cli@latest chat "Where did we leave off?" --continue
npx @lobu/cli@latest chat "Status update" -c staging

-u/--user impersonates a platform user ID (telegram:<numeric-id>, slack:<member-id>), which routes the message through that platform instead of replying directly in the terminal.

FlagDescription
-a, --agent <id>Agent ID (defaults to first agent in local lobu.config.ts when present)
-u, --user <id>User ID to impersonate, e.g. telegram:12345. With this flag the message routes through the user’s platform (Telegram/Slack)
-t, --thread <id>Thread/conversation ID for multi-turn conversations
-g, --gateway <url>Gateway URL (default: http://localhost:8787 or from .env)
--dry-runSkip side-effecting tool calls (sandbox writes, sdk_run mutations). The turn still runs and history is still persisted.
--newForce a new session (ignore an existing one)
-C, --continueResume the last thread for this (context, agent)
--auto-approveAuto-approve every tool call — use only in trusted environments
--jsonEmit raw SSE events as JSON lines instead of rendered text
-c, --context <name>Use a named context for gateway URL and credentials

Lobu does not ship its own eval runner. Use promptfoo with @lobu/promptfoo-provider; see the Evaluations guide for the full pattern.

Terminal window
bun add -D promptfoo @lobu/promptfoo-provider
LOBU_TOKEN=$(npx @lobu/cli@latest token --raw) \
bunx promptfoo eval -c agents/<agent-id>/evals/promptfooconfig.yaml

Validate that local lobu.config.ts loads and conforms to the schema, plus skill IDs and provider configuration.

Terminal window
npx @lobu/cli@latest validate

Returns exit code 1 if validation fails.


Sync local lobu.config.ts and agent directories to a Lobu Cloud org. Idempotent, prompt-confirmed, one-way (files are the source of truth).

Terminal window
npx @lobu/cli@latest apply # plan + prompt + apply
npx @lobu/cli@latest apply --dry-run # plan only, no mutations
npx @lobu/cli@latest apply --yes --org my-org # CI mode, no prompt
npx @lobu/cli@latest deploy --only agents # `deploy` is an alias
FlagDescription
--dry-runShow the plan and exit without mutating
--yesSkip the confirmation prompt (CI mode)
--only <kind>Restrict to one resource family: agents or memory
--org <slug>Org slug override (defaults to the active session)
--url <url>Server URL override
--forceBypass the project-link guard if context/org don’t match .lobu/project.json

See lobu apply for the full flow — plan output, apply order, stable platform IDs, drift, and required-secret checks.


Show a summary of agents in the active org.

Terminal window
npx @lobu/cli@latest status
npx @lobu/cli@latest status --org my-org

link binds the current directory to a (context, org) pair, written to .lobu/project.json. Subsequent commands in this directory default to that context and org, and lobu apply refuses to run against a different pair unless you pass --force. unlink removes the file.

Terminal window
npx @lobu/cli@latest link --org my-org
npx @lobu/cli@latest link -c staging --org my-org
npx @lobu/cli@latest unlink
FlagDescription
-c, --context <name>Use a named context
--org <slug>Org slug to link (defaults to the active org)

Run local health checks: dependencies, DATABASE_URL reachability, pgvector, ports, and provider keys.

Terminal window
npx @lobu/cli@latest doctor
npx @lobu/cli@latest doctor --memory-only # only check memory MCP connectivity + auth
FlagDescription
--memory-onlyOnly check memory MCP connectivity and authentication

Show or toggle anonymous error reporting (Sentry). With no subcommand, prints the current status.

Terminal window
npx @lobu/cli@latest telemetry # same as `telemetry status`
npx @lobu/cli@latest telemetry status
npx @lobu/cli@latest telemetry on # writes SENTRY_DSN to .env
npx @lobu/cli@latest telemetry on --dsn https://[email protected]/1
npx @lobu/cli@latest telemetry off # removes SENTRY_DSN from .env
SubcommandDescription
statusShow whether telemetry is on or off (default)
onEnable telemetry — accepts --dsn <dsn> to override Lobu’s default DSN
offDisable telemetry

Terminal window
npx @lobu/cli@latest whoami
npx @lobu/cli@latest token --raw
npx @lobu/cli@latest logout

token (no subcommand) prints the stored session token. token create mints an org-scoped personal access token suitable for servers and CI — it survives a lobu logout and is not tied to the device-code session:

Terminal window
npx @lobu/cli@latest token create --org my-org --name ci-token --scope "mcp:read mcp:write" --expires-in-days 90
npx @lobu/cli@latest token create --org my-org --raw # token only, for scripting
npx @lobu/cli@latest token create --org my-org --json
FlagDescription
--org <slug>Org slug override
--name <name>Token name (default: lobu-cli-YYYY-MM-DD)
--description <text>Token description
--scope <scope>Space-separated scopes (default: mcp:read mcp:write)
--expires-in-days <days>Expire the token after N days (positive integer)
--rawPrint the token only, no labels
--jsonPrint the full JSON response
-c, --context <name>Use a named context
Terminal window
# 1. Authenticate and select org
npx @lobu/cli@latest login
npx @lobu/cli@latest org set my-org
# 2. Manage remote/UI-backed agents
npx @lobu/cli@latest agent list
npx @lobu/cli@latest agent create my-agent --name "My Agent"
# 3. Optional local artifact workflow
npx @lobu/cli@latest init my-agent
cd my-agent
npx @lobu/cli@latest validate
npx @lobu/cli@latest apply --org my-org
# 4. Run locally (embedded Postgres by default; external Postgres if DATABASE_URL is set)
npx @lobu/cli@latest run