CLI Reference
Complete reference for every codelore command. Commands work in both local and cloud mode unless noted. Auto-detection: if a .codelore/ folder exists in the current directory or any parent, local mode is used; otherwise cloud mode.
Global flags
| Flag | Description |
|---|---|
-h, --help | Print help for any command |
--version | Print CLI version |
init
codelore init
codelore init [name]
Initializes a new knowledge base. Behavior depends on whether you're logged in:
- Logged in: creates a cloud workspace named
name(defaults to current directory name) and sets it as active. - Not logged in: creates
.codelore/codelore.dbin the current directory for local mode.
codelore init # local mode (no login) or cloud with directory name codelore init my-project # cloud workspace named "my-project"
Lesson commands
codelore add
codelore add <path> [-c content] [-m message]
| Flag | Description |
|---|---|
-c, --content | Lesson content as a string. Skips the editor. |
-m, --message | Version note (like a commit message). Optional. |
codelore add auth/jwt # opens editor codelore add auth/jwt -m "explain token lifetime" # opens editor, saves note codelore add auth/jwt -c "JWT secret in env." -m "quick note"
codelore show
codelore show <path>
codelore show auth/jwt codelore show db/migrations
codelore edit
codelore edit <path> [-m message]
| Flag | Description |
|---|---|
-m, --message | Version note for the new version. |
codelore edit auth/jwt codelore edit auth/jwt -m "update token expiry"
codelore ls
codelore ls
codelore ls
codelore log
codelore log <path>
codelore log auth/jwt codelore log db/migrations
codelore context
codelore context <query>
codelore context "authentication" codelore context "database" codelore context "rate limiting" > context.md # save to file
Authentication
codelore signup
codelore signup
codelore signup
codelore login
codelore login
codelore login
codelore logout
codelore logout
codelore logout
Workspace commands
codelore workspace create
codelore workspace create <name>
codelore workspace create my-team codelore workspace create backend-docs
codelore workspace list
codelore workspace list
codelore workspace ls.codelore workspace list codelore workspace ls
codelore workspace use
codelore workspace use <name>
codelore workspace use my-team codelore workspace use backend-docs
codelore workspace invite
codelore workspace invite <email>
codelore workspace invite teammate@example.com
codelore workspace delete
codelore workspace delete <name>
codelore workspace delete my-team
Sync commands
.codelore/ database and an active cloud workspace. Run them from a directory that contains or is inside a .codelore/folder.codelore push
codelore push
Uploads lessons from the local database to the cloud workspace. For each lesson:
- If only local: upload it.
- If same hash: skip (already in sync).
- If both sides changed: show a diff and prompt to resolve.
Reports a summary: X pushed, Y skipped, Z unresolved.
codelore push
codelore pull
codelore pull
Downloads lessons from the cloud workspace to the local database. Mirror of push:
- If only cloud: download it.
- If same hash: skip.
- If both sides changed: show a diff and prompt to resolve.
codelore pull
Conflict resolution prompt
When a conflict is detected during push or pull, CodeLore displays a unified diff and waits for your input:
Conflict: auth/jwt --- local +++ cloud @@ -1 +1 @@ -JWTs expire after 30 days. +JWTs expire after 7 days (tightened in v2.4). [k] keep local [c] cloud wins [e] edit manually [s] skip
| Key | Action |
|---|---|
k | Keep the local version — uploads local content to cloud |
c | Cloud wins — writes cloud content to local database |
e | Edit manually — opens your editor with both versions for manual merge |
s | Skip — leave both sides unchanged, come back later |
AI integration
codelore mcp
codelore mcp
Starts a Model Context Protocol (MCP) server over stdio so AI tools like Claude Desktop and Cursor can read and write your knowledge base directly. The server targets whichever backend is active (local .codelore/ or your selected cloud workspace) and exposes five tools: get_workspace_info, list_lessons, search_lessons, get_lesson, and add_lesson.
You normally don't run this by hand — your AI tool launches it for you via its MCP config. See the AI Integration guide for setup.
codelore mcp # usually invoked by your AI client, not run directly
Configuration
Global config is stored in ~/.codelore/config.json. You can inspect it directly, let the CLI manage it via the login/workspace commands, or use the codelore config command.
| Field | Default | Description |
|---|---|---|
api_url | http://localhost:8080 | Base URL for the CodeLore server |
token | (empty) | JWT auth token saved after login |
workspace | (empty) | Active cloud workspace name |
codelore config
codelore config
codelore config
codelore config set-url
codelore config set-url <url>
codelore config set-url https://app.getcodelore.com codelore config set-url http://localhost:8080
CODELORE_API_URL environment variable overrides the stored server URL for a single invocation — handy for scripts or pointing a distributed binary at production without touching config.json.