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 — watcher reaction scripts, referenced via defineWatcher({ 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/data (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.


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-runProcess without persisting history
--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) \
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