
Cli
- 11 installs
- 81.3k repo stars
- Updated August 5, 2026
- lobehub/lobe-chat
Helps with ai & agent building tasks during AI-assisted development.
About
cli is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted coding.
- cli
- AI & Agent Building
- AI-coding skill
Cli by the numbers
- 11 all-time installs (skills.sh)
- +1 installs in the week ending Aug 2, 2026 (Skillselion tracking)
- Ranked #11,769 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/lobehub/lobe-chat --skill cliAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 11 |
|---|---|
| repo stars | ★ 81.3k |
| Last updated | August 5, 2026 |
| Repository | lobehub/lobe-chat ↗ |
What it does
Helps with ai & agent building tasks during AI-assisted development.
Files
LobeHub CLI Development Guide
Overview
LobeHub CLI (@lobehub/cli) is a command-line tool for managing and interacting with LobeHub services. Built with Commander.js + TypeScript.
- Package:
apps/cli/ - Entry:
apps/cli/src/index.ts - Binaries:
lh,lobe,lobehub(all aliases for the same CLI) - Build: tsup
- Runtime: Node.js / Bun
Architecture
apps/cli/src/
├── index.ts # Entry point, registers all commands
├── api/
│ ├── client.ts # tRPC client (type-safe backend API)
│ └── http.ts # Raw HTTP utilities
├── auth/
│ ├── credentials.ts # Encrypted credential storage (AES-256-GCM)
│ ├── refresh.ts # Token auto-refresh
│ └── resolveToken.ts # Token resolution (flag > stored)
├── commands/ # All CLI commands (one file per command group)
│ ├── agent.ts # Agent CRUD + run
│ ├── config.ts # whoami, usage
│ ├── connect.ts # Device gateway connection + daemon
│ ├── doc.ts # Document management
│ ├── file.ts # File management
│ ├── generate/ # Content generation (text/image/video/tts/asr)
│ ├── kb.ts # Knowledge base management
│ ├── login.ts # OIDC Device Code Flow auth
│ ├── logout.ts # Clear credentials
│ ├── memory.ts # User memory management
│ ├── message.ts # Message management
│ ├── model.ts # AI model management
│ ├── plugin.ts # Plugin management
│ ├── provider.ts # AI provider management
│ ├── search.ts # Global search
│ ├── skill.ts # Agent skill management
│ ├── status.ts # Gateway connectivity check
│ └── topic.ts # Conversation topic management
├── daemon/
│ └── manager.ts # Background daemon process management
├── tools/
│ ├── shell.ts # Shell command execution (for gateway)
│ └── file.ts # File operations (for gateway)
├── settings/
│ └── index.ts # Persistent settings (~/.lobehub/)
├── utils/
│ ├── logger.ts # Logging (verbose mode)
│ ├── format.ts # Table output, JSON, timeAgo, truncate
│ └── agentStream.ts # SSE streaming for agent runs
└── constants/
└── urls.ts # Official server & gateway URLsCommand Groups
| Command | Alias | Description |
|---|---|---|
lh login | - | Authenticate via OIDC Device Code Flow |
lh logout | - | Clear stored credentials |
lh connect | - | Device gateway connection & daemon management |
lh status | - | Quick gateway connectivity check |
lh agent | - | Agent CRUD, run, status |
lh generate | gen | Content generation (text, image, video, tts, asr, download) |
lh doc | - | Document CRUD, batch-create, parse, topic linking |
lh file | - | File list, view, delete, recent |
lh kb | - | Knowledge base CRUD, folders, docs, upload, tree view |
lh memory | - | User memory CRUD + extraction |
lh message | - | Message list, search, delete, count, heatmap |
lh topic | - | Topic CRUD + search + recent |
lh skill | - | Skill CRUD + import (GitHub/URL/market) |
lh model | - | Model CRUD, toggle, batch-toggle, clear |
lh provider | - | Provider CRUD, config, test, toggle |
lh plugin | - | Plugin install, uninstall, update |
lh search | - | Global search across all types |
lh whoami | - | Current user info |
lh usage | - | Monthly/daily usage statistics |
Adding a New Command
1. Create Command File
Create apps/cli/src/commands/<name>.ts:
import type { Command } from 'commander';
import { getTrpcClient } from '../api/client';
import { outputJson, printTable, truncate } from '../utils/format';
export function register<Name>Command(program: Command) {
const cmd = program.command('<name>').description('...');
// Subcommands
cmd
.command('list')
.description('List items')
.option('-L, --limit <n>', 'Maximum number of items', '30')
.option('--json [fields]', 'Output JSON, optionally specify fields')
.action(async (options) => {
const client = await getTrpcClient();
const result = await client.<router>.<procedure>.query({ ... });
// Handle output
});
}2. Register in Entry Point
In apps/cli/src/index.ts:
import { registerNewCommand } from './commands/new';
// ...
registerNewCommand(program);3. Add Tests
Create apps/cli/src/commands/<name>.test.ts alongside the command file.
Conventions
Output Patterns
All list/view commands follow consistent patterns:
--json [fields]- JSON output with optional field filtering--yes- Skip confirmation for destructive ops-L, --limit <n>- Pagination limit (default: 30)-v, --verbose- Verbose logging
Table Output
const rows = items.map((item) => [item.id, truncate(item.title, 40), timeAgo(item.updatedAt)]);
printTable(rows, ['ID', 'TITLE', 'UPDATED']);JSON Output
if (options.json !== undefined) {
const fields = typeof options.json === 'string' ? options.json : undefined;
outputJson(items, fields);
return;
}Authentication
Commands that need auth use getTrpcClient() which auto-resolves tokens:
const client = await getTrpcClient();
// client.router.procedure.query/mutate(...)Confirmation Prompts
import { confirm } from '../utils/format';
if (!options.yes) {
const ok = await confirm('Are you sure?');
if (!ok) return;
}Storage Locations
| File | Path | Purpose |
|---|---|---|
| Credentials | ~/.lobehub/credentials.json | Encrypted tokens (AES-256-GCM) |
| Settings | ~/.lobehub/settings.json | Custom server/gateway URLs |
| Daemon PID | ~/.lobehub/daemon.pid | Background process PID |
| Daemon Status | ~/.lobehub/daemon.status | Connection status JSON |
| Daemon Log | ~/.lobehub/daemon.log | Daemon output log |
The base directory (~/.lobehub/) can be overridden with the LOBEHUB_CLI_HOME env var (e.g. LOBEHUB_CLI_HOME=.lobehub-dev for dev mode isolation).
Key Dependencies
commander- CLI framework@trpc/client+superjson- Type-safe API client@lobechat/device-gateway-client- WebSocket gateway connection@lobechat/local-file-shell- Local shell/file tool executionpicocolors- Terminal colorsws- WebSocketdiff- Text diffingfast-glob- File pattern matching
Development
Running in Dev Mode
Dev mode uses LOBEHUB_CLI_HOME=.lobehub-dev to isolate credentials from the global ~/.lobehub/ directory, so dev and production configs never conflict.
# Run a command in dev mode (from apps/cli/)
cd apps/cli && bun run dev -- <command>
# This is equivalent to:
LOBEHUB_CLI_HOME=.lobehub-dev bun src/index.ts <command>Connecting to Local Dev Server
To test CLI against a local dev server (e.g. localhost:3011):
Step 1: Start the local server
# From cloud repo root
bun run dev
# Server starts on http://localhost:3011 (or configured port)Step 2: Login to local server via Device Code Flow
cd apps/cli && bun run dev -- login --server http://localhost:3011This will:
1. Call POST http://localhost:3011/oidc/device/auth to get a device code 2. Print a URL like http://localhost:3011/oidc/device?user_code=XXXX-YYYY 3. Open the URL in your browser — log in and authorize 4. Save credentials to apps/cli/.lobehub-dev/credentials.json 5. Save server URL to apps/cli/.lobehub-dev/settings.json
After login, all subsequent bun run dev -- <command> calls will use the local server.
Step 3: Run commands against local server
cd apps/cli && bun run dev -- task list
cd apps/cli && bun run dev -- task create -i "Test task" -n "My Task"
cd apps/cli && bun run dev -- agent listTroubleshooting:
- If login returns
invalid_grant, make sure the local OIDC provider is properly configured (checkOIDC_*env vars in.env) - If you get
UNAUTHORIZEDon API calls, your token may have expired — runbun run dev -- login --server http://localhost:3011again - Dev credentials are stored in
apps/cli/.lobehub-dev/(gitignored), not in~/.lobehub/
Switching Between Local and Production
# Dev mode (local server) — uses .lobehub-dev/
cd apps/cli && bun run dev -- <command>
# Production (app.lobehub.com) — uses ~/.lobehub/
lh <command>The two environments are completely isolated by different credential directories.
Build & Test
# Build CLI
cd apps/cli && bun run build
# Unit tests
cd apps/cli && bun run test
# E2E tests (requires authenticated CLI)
cd apps/cli && bunx vitest run e2e/kb.e2e.test.ts
# Link globally for testing (installs lh/lobe/lobehub commands)
cd apps/cli && bun run cli:linkDetailed Command References
See references/ for each command group:
- Agent:
references/agent.md(CRUD, run, status) - Content Generation:
references/generate.md(text, image, video, tts, asr, download) - Knowledge & Files:
references/knowledge.md(kb, file, doc) - Conversation:
references/conversation.md(topic, message) - Memory:
references/memory.md(memory management, extraction) - Skills & Plugins:
references/skills-plugins.md(skill, plugin) - Models & Providers:
references/models-providers.md(model, provider) - Search & Config:
references/search-config.md(search, whoami, usage)
Agent Commands
Manage AI agents: create, edit, delete, list, run, and check status.
Source: apps/cli/src/commands/agent.ts
lh agent list
List all agents.
lh agent list [-L [-k [--json [fields]] < n > ] < keyword > ]| Option | Description | Default |
|---|---|---|
-L, --limit <n> | Maximum items | 30 |
-k, --keyword <keyword> | Filter by keyword | - |
--json [fields] | JSON output with optional field filter | - |
Table columns: ID, TITLE, DESCRIPTION, MODEL
---
lh agent view <agentId>
View agent configuration details.
lh agent view [fields]] < agentId > [--jsonDisplays: Title, description, model, provider, system role, plugins, tools.
---
lh agent create
Create a new agent.
lh agent create [options]| Option | Description | Required |
|---|---|---|
-t, --title <title> | Agent title | No |
-d, --description <desc> | Description | No |
-m, --model <model> | Model ID | No |
-p, --provider <provider> | Provider ID | No |
-s, --system-role <role> | System prompt | No |
--group <groupId> | Agent group ID | No |
Output: Created agent ID and session ID.
---
lh agent edit <agentId>
Update an existing agent. Same options as create, all optional. Only specified fields are updated.
lh agent edit [-m [-s ... < agentId > [-t < title > ] < model > ] < role > ]---
lh agent delete <agentId>
Delete an agent.
lh agent delete < agentId > [--yes]Requires confirmation unless --yes is provided.
---
lh agent duplicate <agentId>
Duplicate an existing agent.
lh agent duplicate < agentId > [-t < title > ]| Option | Description |
|---|---|
-t, --title <title> | Optional new title for the duplicate |
Output: New agent ID.
---
lh agent run
Start an agent execution (streaming SSE).
lh agent run [options]| Option | Description |
|---|---|
-a, --agent-id <id> | Agent ID to run |
-s, --slug <slug> | Agent slug (alternative to ID) |
-p, --prompt <text> | User prompt |
-t, --topic-id <id> | Reuse existing topic |
--no-auto-start | Don't auto-start the agent |
--json | Output full JSON event stream |
-v, --verbose | Show detailed tool call info |
--replay <file> | Replay events from saved JSON file (offline) |
Streaming Behavior
Uses utils/agentStream.ts to handle Server-Sent Events:
1. Sends agent run request to backend 2. Streams SSE events in real-time 3. Displays: text chunks, tool call status, operation progress 4. Shows final token usage and cost summary
Replay Mode
--replay <file> reads a saved JSON event stream for offline debugging without server connection.
---
lh agent status <operationId>
Check agent operation status.
lh agent status [fields]] [--history] [--history-limit < operationId > [--json < n > ]| Option | Description | Default |
|---|---|---|
--json [fields] | JSON output | - |
--history | Include step history | false |
--history-limit <n> | Max history entries | 10 |
Displays: Status (running/completed/failed), steps count, tokens used, cost, error info, timestamps.
Conversation Commands (Topic & Message)
Topic Management (lh topic)
Manage conversation topics (threads).
Source: apps/cli/src/commands/topic.ts
lh topic list
lh topic list [--agent-id [-L [--page [--json [fields]] < id > ] < n > ] < n > ]| Option | Description | Default |
|---|---|---|
--agent-id <id> | Filter by agent | - |
-L, --limit <n> | Page size | 30 |
--page <n> | Page number | 1 |
Table columns: ID, TITLE, FAV, UPDATED
lh topic search <keywords>
lh topic search [--json [fields]] < keywords > [--agent-id < id > ]lh topic create
lh topic create -t [--favorite] < title > [--agent-id < id > ]| Option | Description | Required |
|---|---|---|
-t, --title <title> | Topic title | Yes |
--agent-id <id> | Associate with agent | No |
--favorite | Mark as favorite | No |
lh topic edit <id>
lh topic edit [--favorite] [--no-favorite] < id > [-t < title > ]lh topic delete <ids...>
lh topic delete [--yes] < id1 > [id2...]lh topic recent
lh topic recent [-L [--json [fields]] < n > ]| Option | Description | Default |
|---|---|---|
-L, --limit <n> | Number of items | 10 |
---
Message Management (lh message)
Manage chat messages within topics.
Source: apps/cli/src/commands/message.ts
lh message list
lh message list [options] [--json [fields]]| Option | Description | Default |
|---|---|---|
--topic-id <id> | Filter by topic | - |
--agent-id <id> | Filter by agent | - |
-L, --limit <n> | Page size | 30 |
--page <n> | Page number | 1 |
--user | Only show user messages | - |
Table columns: ID, ROLE, CONTENT, CREATED
Note: When --topic-id or --agent-id is provided, uses message.getMessages; otherwise uses message.listAll.
lh message search <keywords>
lh message search [fields]] < keywords > [--jsonFull-text search across all messages.
lh message delete <ids...>
lh message delete [--yes] < id1 > [id2...]lh message count
lh message count [--start [--end [--json] < date > ] < date > ]| Option | Description |
|---|---|
--start <date> | Start date (ISO format, e.g. 2024-01-01) |
--end <date> | End date (ISO format) |
Output: Total message count for the specified period.
lh message heatmap
lh message heatmap [--json]Output: Activity heatmap data showing message frequency over time.
Content Generation Commands
Generate text, images, videos, speech, and transcriptions.
Source: apps/cli/src/commands/generate/
Command Structure
lh generate (alias: gen)
├── text <prompt> # Text generation
├── image <prompt> # Image generation
├── video <prompt> # Video generation
├── tts <text> # Text-to-speech
├── asr <audioFile> # Audio-to-text (speech recognition)
├── download <generationId> <asyncTaskId> # Wait & download generation result
├── status <generationId> <asyncTaskId> # Check async task status
└── list # List generation topics⚠️ Important:statusanddownloadrequire anasyncTaskId(UUID format, e.g.
7ad0eb13-e9a5-4403-8070-1f7fe95b2f95), not the generation ID (gen_xxx).
The asyncTaskId is printed after "→ Task" in thevideo/imagecommand output.
---
lh generate text <prompt> / lh gen text <prompt>
Generate text completion.
Source: apps/cli/src/commands/generate/text.ts
lh gen text "Explain quantum computing" [options]
echo "context" | lh gen text "summarize" --pipe| Option | Description | Default |
|---|---|---|
-m, --model <model> | Model ID | openai/gpt-4o-mini |
-p, --provider <provider> | Provider name | - |
-s, --system <prompt> | System prompt | - |
--temperature <n> | Temperature (0-2) | - |
--max-tokens <n> | Maximum output tokens | - |
--stream | Enable streaming output | false |
--json | Output full JSON response | false |
--pipe | Read additional context from stdin | false |
Pipe Mode
When --pipe is used, reads stdin and prepends it to the prompt. Useful for piping file contents:
cat README.md | lh gen text "summarize this" --pipe---
lh generate image <prompt> / lh gen image <prompt>
Generate images from text prompt. This is an async operation — the command submits the task and returns a generation ID + async task ID for tracking.
Source: apps/cli/src/commands/generate/image.ts
lh gen image "A sunset over mountains" [options]
lh gen image "A cute cat" --model dall-e-3 --provider openai --json| Option | Description | Default |
|---|---|---|
-m, --model <model> | Model ID | dall-e-3 |
-p, --provider <provider> | Provider name | openai |
-n, --num <n> | Number of images | 1 |
--width <px> | Width in pixels | - |
--height <px> | Height in pixels | - |
--steps <n> | Number of steps | - |
--seed <n> | Random seed | - |
--json | Output raw JSON | false |
Output (non-JSON):
✓ Image generation started
Batch ID: gb_xxx
1 image(s) queued
Generation gen_xxx → Task 7ad0eb13-xxxx-xxxx-xxxx-xxxxxxxxxxxx
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is the asyncTaskId — use this for status/download
Use "lh generate status <generationId> <asyncTaskId>" to check progress.Typical workflow:
# 1. Submit generation — note down BOTH IDs from the output
lh gen image "A cute cat"
# Generation gen_abc123 → Task 7ad0eb13-e9a5-4403-8070-1f7fe95b2f95
# 2. Wait & download using generationId + asyncTaskId (the UUID)
lh gen download gen_abc123 7ad0eb13-e9a5-4403-8070-1f7fe95b2f95 -o cat.png---
lh generate video <prompt> / lh gen video <prompt>
Generate video from text prompt. This is an async operation.
Source: apps/cli/src/commands/generate/video.ts
lh gen video "A cat playing piano" -m < model > -p < provider > [options]| Option | Description | Required |
|---|---|---|
-m, --model <model> | Model ID | Yes |
-p, --provider <provider> | Provider name | Yes |
--aspect-ratio <ratio> | Aspect ratio (e.g. 16:9) | No |
--duration <sec> | Duration in seconds | No |
--resolution <res> | Resolution (e.g. 720p) | No |
--seed <n> | Random seed | No |
--json | Output raw JSON | No |
Note: Unlike image, video requires -m and -p (no defaults). Use lh model list <provider> --type video to find available video models.
Output (non-JSON):
✓ Video generation started
Batch ID: gb_xxx
Generation gen_xxx → Task 7ad0eb13-xxxx-xxxx-xxxx-xxxxxxxxxxxx
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is the asyncTaskId — use this for status/download
Use "lh generate status <generationId> <asyncTaskId>" to check progress.Typical workflow:
# 1. Find available video models for a provider
lh model list volcengine --json | grep -i seedance
# 2. Submit generation — note down BOTH IDs from the output
lh gen video "A cat on a runway" -m doubao-seedance-2-0-260128 -p volcengine \
--aspect-ratio 9:16 --duration 5 --resolution 1080p
# Generation gen_abc123 → Task 7ad0eb13-e9a5-4403-8070-1f7fe95b2f95
# 3. Wait & download using generationId + asyncTaskId (the UUID)
lh gen download gen_abc123 7ad0eb13-e9a5-4403-8070-1f7fe95b2f95 -o result.mp4 --timeout 600---
lh generate tts <text> / lh gen tts <text>
Text-to-speech generation.
Source: apps/cli/src/commands/generate/tts.ts
lh gen tts "Hello, world!" [options]---
lh generate asr <audioFile> / lh gen asr <audioFile>
Audio-to-text transcription (Automatic Speech Recognition).
Source: apps/cli/src/commands/generate/asr.ts
lh gen asr recording.wav [options]---
lh generate download <generationId> <asyncTaskId>
Wait for an async generation task to complete and download the result file.
Source: apps/cli/src/commands/generate/index.ts
⚠️ <asyncTaskId> is the UUID printed after "→ Task" in the video/image output.Do not pass the generation ID (gen_xxx) here — that will cause a server error.lh gen download <generationId> <asyncTaskId> [-o output.png]
lh gen download gen_xxx 7ad0eb13-xxxx-xxxx-xxxx-xxxxxxxxxxxx -o ~/Desktop/result.mp4 --timeout 600| Option | Description | Default |
|---|---|---|
-o, --output <path> | Output file path (auto-detect extension) | <generationId>.<ext> |
--interval <sec> | Polling interval in seconds | 5 |
--timeout <sec> | Timeout in seconds (0 = no timeout) | 300 |
Behavior:
1. Polls generation.getGenerationStatus at the specified interval 2. Shows live progress: ⋯ Status: processing... (42s) 3. On success: downloads asset URL to local file 4. On error / wrong ID: displays a clear message pointing to the correct ID format 5. On timeout: suggests using lh gen status to check later
---
lh generate status <generationId> <asyncTaskId>
Check the status of an async generation task.
⚠️ <asyncTaskId> is the UUID printed after "→ Task" in the video/image output.Do not pass the generation ID (gen_xxx) here — that will cause a server error.lh gen status <generationId> <asyncTaskId> [--json]
lh gen status gen_xxx 7ad0eb13-xxxx-xxxx-xxxx-xxxxxxxxxxxx| Option | Description |
|---|---|
--json | Output raw JSON response |
Displays:
- Status (color-coded):
success(green),error(red),processing(yellow),pending(cyan) - Error message (if failed)
- Asset URL and thumbnail URL (if completed)
---
lh generate list
List all generation topics.
lh gen list [--json [fields]]Table columns: ID, TITLE, TYPE, UPDATED
---
Backend Architecture
Image and video generation use an async task pattern:
1. Create topic → generationTopic.createTopic 2. Submit generation → image.createImage / video.createVideo
- Creates batch + generation + asyncTask records in a DB transaction
- Triggers async background task (image via
createAsyncCaller, video viainitModelRuntimeFromDB) - Returns
{ data: { batch, generations }, success }withasyncTaskIdin each generation
3. Poll status → generation.getGenerationStatus
- Input:
{ generationId, asyncTaskId }— both are required, andasyncTaskIdmust be the
UUID from the async_tasks table, not gen_xxx
- Returns
{ status, error, generation }(generation includes asset URLs on success) - Before querying, calls
checkTimeoutTaskswhich marks tasks aserrorif they have been
pending or processing for more than \~5 minutes (ASYNC_TASK_TIMEOUT = 298s)
Server routes:
apps/server/src/routers/lambda/image/index.ts— image creation (usesauthedProcedure+serverDatabase)apps/server/src/routers/lambda/video/index.ts— video creation (usesauthedProcedure+serverDatabase)apps/server/src/routers/lambda/generation.ts— status checkingpackages/database/src/models/asyncTask.ts—AsyncTaskModelincludingcheckTimeoutTasks
Note: Image/video routes do NOT use the keyVaults middleware — they read API keys from the database via initModelRuntimeFromDB or createAsyncCaller.
Knowledge Base, File & Document Commands
Knowledge Base (lh kb)
Manage knowledge bases for RAG (Retrieval-Augmented Generation). Supports directory tree structure with folders, documents, and file uploads.
Source: apps/cli/src/commands/kb.ts
lh kb list
lh kb list [--json [fields]]Table columns: ID, NAME, DESCRIPTION, UPDATED
lh kb view <id>
lh kb view [fields]] < id > [--jsonDisplays: Name, description, full directory tree with all files and documents (recursively fetched). Shows indented tree structure with item type (File/Doc), file type, and size.
API: Uses file.getKnowledgeItems to recursively fetch items. Folders (custom/folder fileType) are traversed in parallel via Promise.all for performance.
lh kb create
lh kb create -n [--avatar < name > [-d < desc > ] < url > ]| Option | Description | Required |
|---|---|---|
-n, --name <name> | Knowledge base name | Yes |
-d, --description <desc> | Description | No |
--avatar <url> | Avatar URL | No |
Output: Created KB ID. Note: backend returns ID as a string directly (not an object).
lh kb edit <id>
lh kb edit [-d [--avatar < id > [-n < name > ] < desc > ] < url > ]Requires at least one change flag. Errors if none specified.
lh kb delete <id>
lh kb delete [--yes] < id > [--remove-files]| Option | Description |
|---|---|
--remove-files | Also delete associated files |
--yes | Skip confirmation |
lh kb add-files <knowledgeBaseId>
lh kb add-files <kbId> --ids <fileId1> <fileId2> ...Link existing files to a knowledge base.
lh kb remove-files <knowledgeBaseId>
lh kb remove-files <kbId> --ids <fileId1> <fileId2> ... [--yes]Unlink files from a knowledge base.
lh kb mkdir <knowledgeBaseId>
lh kb mkdir < kbId > -n < name > [--parent < folderId > ]Create a folder in a knowledge base. Uses document.createDocument with fileType: 'custom/folder'.
| Option | Description | Required |
|---|---|---|
-n, --name <name> | Folder name | Yes |
--parent <parentId> | Parent folder ID | No |
lh kb create-doc <knowledgeBaseId>
lh kb create-doc [--parent < kbId > -t < title > [-c < content > ] < folderId > ]Create a document in a knowledge base. Uses document.createDocument with fileType: 'custom/document'.
| Option | Description | Required |
|---|---|---|
-t, --title <title> | Document title | Yes |
-c, --content <text> | Document content | No |
--parent <parentId> | Parent folder ID | No |
lh kb move <id>
lh kb move < id > --type < file | doc > [--parent < folderId > ]Move a file or document to a different folder (or to root if --parent is omitted).
| Option | Description | Default |
|---|---|---|
--type <type> | Item type: file or doc | file |
--parent <parentId> | Target folder ID (omit for root) | - |
Uses document.updateDocument for docs, file.updateFile for files.
lh kb upload <knowledgeBaseId> <filePath>
lh kb upload <kbId> <filePath> [--parent <folderId>]Upload a local file to a knowledge base via S3 presigned URL.
| Option | Description |
|---|---|
--parent <parentId> | Parent folder ID |
Flow: Compute SHA-256 hash → get presigned URL via upload.createS3PreSignedUrl → PUT to S3 → create file record via file.createFile.
---
File Management (lh file)
Manage uploaded files.
Source: apps/cli/src/commands/file.ts
lh file list
lh file list [--kb-id [-L [--json [fields]] < id > ] < n > ]| Option | Description | Default |
|---|---|---|
--kb-id <id> | Filter by knowledge base | - |
-L, --limit <n> | Maximum items | 30 |
Table columns: ID, NAME, TYPE, SIZE, UPDATED
lh file view <id>
lh file view [fields]] < id > [--jsonDisplays: Name, type, size, chunking status, embedding status.
lh file delete <ids...>
lh file delete [--yes] < id1 > [id2...]Supports deleting multiple files at once.
lh file recent
lh file recent [-L [--json [fields]] < n > ]| Option | Description | Default |
|---|---|---|
-L, --limit <n> | Number of items | 10 |
---
Document Management (lh doc)
Manage text documents (notes, wiki pages).
Source: apps/cli/src/commands/doc.ts
lh doc list
lh doc list [-L [--file-type [--source-type [--json [fields]] < n > ] < type > ] < type > ]| Option | Description | Default |
|---|---|---|
-L, --limit <n> | Maximum items | 30 |
--file-type <type> | Filter by file type | - |
--source-type <type> | Filter by source type (file, web, api, topic) | - |
Table columns: ID, TITLE, TYPE, UPDATED
lh doc view <id>
lh doc view [fields]] < id > [--jsonDisplays: Title, type, KB association, updated time, full content.
lh doc create
lh doc create -t [-F [--parent [--slug [--kb [--file-type < title > [-b < body > ] < path > ] < id > ] < slug > ] < id > ] < type > ]| Option | Description | Required |
|---|---|---|
-t, --title <title> | Document title | Yes |
-b, --body <content> | Document body text | No |
-F, --body-file <path> | Read body from file | No |
--parent <id> | Parent document ID | No |
--slug <slug> | Custom URL slug | No |
--kb <id> | Knowledge base ID to associate with | No |
--file-type <type> | File type (e.g. custom/document, custom/folder) | No |
-b and -F are mutually exclusive; -F reads the file content as the body.
lh doc batch-create <file>
Batch create documents from a JSON file. The file must contain a non-empty array of document objects.
lh doc batch-create documents.jsonEach object in the array can have: title, content, fileType, knowledgeBaseId, parentId, slug.
lh doc edit <id>
lh doc edit [-b [-F [--parent [--file-type < id > [-t < title > ] < body > ] < path > ] < id > ] < type > ]lh doc delete <ids...>
lh doc delete [--yes] < id1 > [id2...]lh doc parse <fileId>
Parse an uploaded file into a document.
lh doc parse [--json [fields]] < fileId > [--with-pages]| Option | Description |
|---|---|
--with-pages | Preserve page structure |
Output: Parsed title and content preview.
lh doc link-topic <docId> <topicId>
Associate a document with a topic. Creates a linked copy via the notebook router.
lh doc link-topic <docId> <topicId>lh doc topic-docs <topicId>
List documents associated with a topic.
lh doc topic-docs [--json [fields]] < topicId > [--type < type > ]| Option | Description |
|---|---|
--type <type> | Filter by type (article, markdown, note, report) |
Memory Commands
Manage user memories - the AI's long-term knowledge about users.
Source: apps/cli/src/commands/memory.ts
Memory Categories
| Category | Description |
|---|---|
identity | User's name, role, relationships |
activity | Recent activities and their status |
context | Ongoing contexts, projects, goals |
experience | Past experiences and key learnings |
preference | User preferences, directives, suggestions |
---
lh memory list [category]
List memory entries, optionally filtered by category.
lh memory list # All categories
lh memory list identity # Only identity memories
lh memory list preference # Only preferences| Option | Description |
|---|---|
--json [fields] | JSON output |
Output: Grouped by category, showing type/status and descriptions.
---
lh memory create
Create a new identity memory entry.
lh memory create [options]| Option | Description |
|---|---|
--type <type> | Memory type |
--role <role> | User's role |
--relationship <rel> | Relationship description |
-d, --description <desc> | Description |
--labels <labels...> | Extracted labels |
---
lh memory edit <category> <id>
Edit a memory entry. Options vary by category:
lh memory edit identity < id > [options]
lh memory edit activity < id > [options]
lh memory edit context < id > [options]
lh memory edit experience < id > [options]
lh memory edit preference < id > [options]Category-specific Options
identity:
--type <type>,--role <role>,--relationship <rel>
activity:
--narrative <text>,--notes <text>,--status <status>
context:
--title <title>,--description <desc>,--status <status>
experience:
--situation <text>,--action <text>,--key-learning <text>
preference:
--directives <text>,--suggestions <text>
---
lh memory delete <category> <id>
lh memory delete identity < id > [--yes]---
lh memory persona
Display the compiled memory persona summary.
lh memory persona [--json [fields]]Output: Summarized user profile built from all memory categories.
---
lh memory extract
Trigger async memory extraction from chat history.
lh memory extract [--from [--to < date > ] < date > ]| Option | Description |
|---|---|
--from <date> | Start date (ISO format) |
--to <date> | End date (ISO format) |
Starts a background task that analyzes chat history and creates new memory entries.
---
lh memory extract-status
Check the status of a memory extraction task.
lh memory extract-status [--task-id [--json [fields]] < id > ]| Option | Description |
|---|---|
--task-id <id> | Check specific task |
Model & Provider Commands
Model Management (lh model)
Manage AI models within providers.
Source: apps/cli/src/commands/model.ts
lh model list <providerId>
List models for a specific provider.
lh model list openai
lh model list openai --type image --enabled
lh model list lobehub --type video --json| Option | Description | Default |
|---|---|---|
-L, --limit <n> | Maximum items | 50 |
--enabled | Only show enabled models | false |
--type <type> | Filter by model type (`chat\ | embedding\ |
--json [fields] | Output JSON, optionally specify fields | - |
Table columns: ID, NAME, ENABLED, TYPE
Backend: aiModel.getAiProviderModelList → AiInfraRepos.getAiProviderModelList (supports type filter at repository level)
lh model view <id>
lh model view [fields]] < modelId > [--jsonDisplays: Name, provider, type, enabled status, capabilities.
lh model create
lh model create --id [--type < id > --provider < providerId > [--display-name < name > ] < type > ]| Option | Description | Default |
|---|---|---|
--id <id> | Model ID | Required |
--provider <providerId> | Provider ID | Required |
--display-name <name> | Display name | - |
--type <type> | Model type | chat |
lh model edit <id>
lh model edit [--type < modelId > --provider < providerId > [--display-name < name > ] < type > ]lh model toggle <id>
Enable or disable a model.
lh model toggle < modelId > --provider < providerId > --enable
lh model toggle < modelId > --provider < providerId > --disable| Option | Description | Required |
|---|---|---|
--provider <providerId> | Provider ID | Yes |
--enable | Enable the model | One required |
--disable | Disable the model | One required |
lh model batch-toggle <ids...>
Enable or disable multiple models at once.
lh model batch-toggle model1 model2 model3 --provider openai --enablelh model delete <id>
lh model delete < modelId > --provider < providerId > [--yes]lh model clear
Clear all models (or only remote/fetched models) for a provider.
lh model clear --provider [--yes] < providerId > [--remote]---
Provider Management (lh provider)
Manage AI service providers.
Source: apps/cli/src/commands/provider.ts
lh provider list
lh provider list [--json [fields]]Table columns: ID, NAME, ENABLED, SOURCE
lh provider view <id>
lh provider view [fields]] < providerId > [--jsonDisplays: Name, enabled status, source, configuration.
lh provider create
lh provider create --id [-d [--logo [--sdk-type < id > -n < name > [-s < source > ] < desc > ] < url > ] < type > ]| Option | Description | Default |
|---|---|---|
--id <id> | Provider ID | Required |
-n, --name <name> | Provider name | Required |
-s, --source <source> | Source type (builtin or custom) | custom |
-d, --description <desc> | Provider description | - |
--logo <logo> | Provider logo URL | - |
--sdk-type <sdkType> | SDK type (openai, anthropic, azure, bedrock, ...) | - |
lh provider edit <id>
lh provider edit [-d [--logo [--sdk-type < providerId > [-n < name > ] < desc > ] < url > ] < type > ]Requires at least one change flag.
lh provider config <id>
Configure provider settings (API key, base URL, etc.).
lh provider config openai --api-key sk-xxx
lh provider config openai --base-url https://custom-endpoint.com
lh provider config openai --show
lh provider config openai --show --json| Option | Description |
|---|---|
--api-key <key> | Set API key |
--base-url <url> | Set base URL |
--check-model <model> | Set connectivity check model |
--enable-response-api | Enable Response API mode (OpenAI) |
--disable-response-api | Disable Response API mode |
--fetch-on-client | Enable fetching models on client |
--no-fetch-on-client | Disable fetching models on client |
--show | Show current config |
--json [fields] | Output JSON (with --show) |
Important: The lobehub provider is platform-managed. Attempting to set --api-key or --base-url on it will be rejected with an error message.
lh provider test <id>
Test provider connectivity.
lh provider test openai
lh provider test openai -m gpt-4o --jsonlh provider toggle <id>
lh provider toggle < providerId > --enable
lh provider toggle < providerId > --disablelh provider delete <id>
lh provider delete < providerId > [--yes]Search & Configuration Commands
Global Search (lh search)
Search across all LobeHub resource types.
Source: apps/cli/src/commands/search.ts
lh search <query>
lh search "meeting notes" [-t [-L [--json [fields]] < type > ] < n > ]| Option | Description | Default |
|---|---|---|
-t, --type <type> | Filter by resource type | All types |
-L, --limit <n> | Results per type | 10 |
Searchable Types
| Type | Description |
|---|---|
agent | AI agents |
topic | Conversation topics |
file | Uploaded files |
folder | File folders |
message | Chat messages |
page | Documents/pages |
memory | User memories |
mcp | MCP servers |
plugin | Installed plugins |
communityAgent | Community marketplace agents |
knowledgeBase | Knowledge bases |
Output: Results grouped by type, showing ID, title/name, description.
---
User Configuration (lh whoami / lh usage)
Source: apps/cli/src/commands/config.ts
lh whoami
Display current authenticated user information.
lh whoami [--json [fields]]Displays: Name, username, email, user ID, subscription plan.
lh usage
Display usage statistics.
lh usage [--month [--daily] [--json [fields]] < YYYY-MM > ]| Option | Description | Default |
|---|---|---|
--month <YYYY-MM> | Month to query | Current month |
--daily | Group by day | false (monthly total) |
Output: Token usage, costs, and model breakdown for the specified period.
---
Global Options
These options are available across most commands:
| Option | Description |
|---|---|
--json [fields] | Output as JSON; optionally filter to specific fields (comma-separated) |
--yes | Skip confirmation prompts for destructive operations |
-L, --limit <n> | Pagination limit for list commands |
-v, --verbose | Enable verbose/debug logging |
--help | Show command help |
--version | Show CLI version |
JSON Field Filtering
The --json option supports field selection:
# Full JSON output
lh agent list --json
# Only specific fields
lh agent list --json "id,title,model"Skill & Plugin Commands
Skill Management (lh skill)
Manage agent skills (custom instructions and capabilities).
Source: apps/cli/src/commands/skill.ts
lh skill list
lh skill list [--source [--json [fields]] < source > ]| Option | Description |
|---|---|
--source <source> | Filter: builtin, market, user |
Table columns: ID, NAME, DESCRIPTION, SOURCE, IDENTIFIER
lh skill view <id>
lh skill view [fields]] < id > [--jsonDisplays: Name, description, source, identifier, content.
lh skill create
lh skill create -n < name > -d < desc > -c < content > [-i < identifier > ]| Option | Description | Required |
|---|---|---|
-n, --name <name> | Skill name | Yes |
-d, --description <desc> | Description | Yes |
-c, --content <content> | Skill content (prompt/instructions) | Yes |
-i, --identifier <id> | Custom identifier | No |
lh skill edit <id>
lh skill edit [-n [-d < id > [-c < content > ] < name > ] < desc > ]lh skill delete <id>
lh skill delete < id > [--yes]lh skill search <query>
lh skill search [fields]] < query > [--jsonlh skill install <source> (alias: lh skill i)
Install a skill. Auto-detects source type from the input:
# GitHub (URL or owner/repo shorthand)
lh skill install lobehub/skill-repo
lh skill install https://github.com/lobehub/skill-repo
lh skill install lobehub/skill-repo --branch dev
# ZIP URL
lh skill install https://example.com/skill.zip
# Marketplace identifier
lh skill install my-cool-skill
lh skill i my-cool-skill| Option | Description | Notes |
|---|---|---|
--branch <branch> | Branch name (GitHub only) | Optional |
Detection rules:
https://github.com/...orowner/repo→ GitHub- Other
https://...URLs → ZIP URL - Everything else → marketplace identifier
Resource Commands
lh skill resources <id>
List files/resources within a skill.
lh skill resources [fields]] < id > [--jsonDisplays: Path, type, size.
lh skill read-resource <id> <path>
Read a specific resource file from a skill.
lh skill read-resource <skillId> <path>Output: File content or JSON metadata.
---
Plugin Management (lh plugin)
Install and manage plugins (external tool integrations).
Source: apps/cli/src/commands/plugin.ts
lh plugin list
lh plugin list [--json [fields]]Table columns: ID, IDENTIFIER, TYPE, TITLE
lh plugin install
lh plugin install -i [--settings < identifier > --manifest < json > [--type < type > ] < json > ]| Option | Description | Required |
|---|---|---|
-i, --identifier <id> | Plugin identifier | Yes |
--manifest <json> | Plugin manifest JSON | Yes |
--type <type> | plugin or customPlugin | No (default: plugin) |
--settings <json> | Plugin settings JSON | No |
lh plugin uninstall <id>
lh plugin uninstall < id > [--yes]lh plugin update <id>
lh plugin update [--settings < id > [--manifest < json > ] < json > ]