CLI Reference¶
All commands use the sylvan entry point. When invoked with no arguments, it starts the MCP server in stdio mode.
serve¶
Start the MCP server.
| Option | Default | Description |
|---|---|---|
--transport, -t |
stdio |
Transport mode: stdio, sse, or http (streamable-http) |
--host |
127.0.0.1 |
Bind address for SSE/HTTP modes |
--port, -p |
8420 |
Port for SSE/HTTP modes |
Running sylvan with no command is equivalent to sylvan serve.
# Default stdio mode (what MCP clients expect)
sylvan serve
# SSE on all interfaces
sylvan serve --transport sse --host 0.0.0.0
# Streamable HTTP on a custom port
sylvan serve --transport http --port 9000
index¶
Index a local folder for code symbol retrieval.
| Option | Default | Description |
|---|---|---|
--name, -n |
directory name | Display name for the repo |
--watch, -w |
off | Watch for file changes and auto-reindex |
# Index a project
sylvan index /path/to/my-project
# Index with a custom name
sylvan index /path/to/my-project --name backend
# Index and watch for changes
sylvan index /path/to/my-project --watch
scaffold¶
Generate a sylvan/ directory and agent instruction files for a project.
| Argument / Option | Default | Description |
|---|---|---|
repo |
required | Name of an already-indexed repository |
--agent, -a |
claude |
Agent format: claude, cursor, copilot, generic |
--root, -r |
auto-detected | Override project root path |
# Generate Claude Code instructions
sylvan scaffold my-project
# Generate for Cursor
sylvan scaffold my-project --agent cursor
# Override the project root
sylvan scaffold my-project --root /home/user/projects/my-project
init¶
Interactive configuration setup. Walks through provider selection for summary generation and embeddings.
No options. The command prompts for:
- Summary provider -- heuristic (default), Ollama, Claude Code, or Codex CLI
- Writes the configuration to
~/.sylvan/config.yaml
sylvan init
# Sylvan -- first time setup
#
# Summary provider (generates richer search metadata):
# [1] Heuristic only (no AI, always works) [default]
# [2] Ollama / local LLM
# [3] Claude Code (detected)
# [4] Codex CLI (not detected)
remove¶
Remove an indexed repository and all its data (symbols, sections, imports, references, quality metrics, files).
| Argument / Option | Default | Description |
|---|---|---|
name |
required | Repository name (as shown in sylvan status) |
--force, -f |
false |
Skip confirmation prompt |
sylvan remove old-project
# Remove 'old-project' and all its indexed data? [y/N]: y
# Removed 'old-project':
# references: 142
# quality: 89
# symbols: 621
# files: 78
# repos: 1
# Skip confirmation
sylvan remove old-project --force
Does not remove the source files on disk — only the indexed data.
status¶
Show all indexed repositories with file and symbol counts.
No options. Prints each repo with its stats:
my-project: 223 files, 1401 symbols (indexed 2026-03-23T10:15:00)
django@4.2 [library]: 850 files, 12340 symbols (indexed 2026-03-20T08:00:00)
doctor¶
Diagnose installation health. Checks Python version, SQLite, sqlite-vec, tree-sitter, embedding model, database status, configuration, and indexed repositories.
No options. Output shows pass/fail for each check:
Sylvan Doctor
[+] Python version -- 3.12.4
[+] SQLite version -- 3.45.1
[+] sqlite-vec extension -- loaded
[+] Database -- ~/.sylvan/sylvan.db (42.3 MB)
[+] Configuration -- summary=heuristic, embedding=sentence-transformers
[+] Embedding model -- sentence-transformers (384d)
[+] Indexed repositories -- 3 repos
my-project: 223 files
backend: 150 files
django@4.2: 850 files
[+] Tree-sitter -- language pack available
7 passed, 0 failed
shell¶
Start an interactive Python REPL with the ORM preloaded. All models, the database connection, and the query builder are imported and ready.
No options. The shell provides:
Symbol,Section,FileRecord,FileImport,Repo,Blob,Reference,Quality,WorkspacemodelsQueryBuilderfor ad-hoc queries
export¶
Export an indexed repository to JSON.
| Option | Default | Description |
|---|---|---|
--output, -o |
- (stdout) |
Output file path |
--format, -f |
json |
Export format (currently only json) |
# Export to stdout
sylvan export my-project
# Export to a file
sylvan export my-project --output backup.json
The output includes all symbols, sections, files, and imports for the repository.
hook¶
Handle Claude Code hook events for auto-indexing worktrees. Reads a JSON payload from stdin.
| Argument | Description |
|---|---|
event |
Event type: worktree-create or worktree-remove |
This command is called automatically by Claude Code hooks, not manually. It expects a JSON payload on stdin with a worktreePath field.
migrate¶
Run all pending database migrations. When invoked with no subcommand, applies pending migrations.
| Option | Default | Description |
|---|---|---|
--dry-run |
off | Show pending migrations without applying them |
# Apply all pending migrations
sylvan migrate
# Preview what would be applied
sylvan migrate --dry-run
# Current version: 3
# Pending: 2 migration(s)
# 004: add_quality_table
# 005: add_workspace_table
#
# --dry-run: no migrations applied.
migrate create¶
Create a new empty migration file.
| Argument | Description |
|---|---|
description |
Human-readable description for the migration |
sylvan migrate create "add analytics table"
# Created: src/sylvan/database/migrations/006_add_analytics_table.py
# Edit up() and down(), then run: sylvan migrate
migrate rollback¶
Roll back the most recent migration.
No options. Runs the down() function of the last applied migration.
library add¶
Add a third-party library by fetching and indexing its source code.
| Argument / Option | Default | Description |
|---|---|---|
spec |
required | Package spec: manager/name[@version] (e.g., pip/django@4.2) |
--timeout, -t |
120 |
Fetch timeout in seconds |
# Index a specific version
sylvan library add pip/django@4.2
# Index latest version
sylvan library add pip/fastapi
# npm package
sylvan library add npm/htmx.org@2.0.8
# With a longer timeout for large packages
sylvan library add pip/tensorflow --timeout 300
library list¶
List all indexed third-party libraries.
No options.
django@4.2: 850 files, 12340 symbols (pip)
fastapi@0.115.0: 120 files, 890 symbols (pip)
htmx.org@2.0.8: 15 files, 230 symbols (npm)
library remove¶
Remove an indexed library and its cached source files.
| Argument | Description |
|---|---|
name |
Library name as shown in library list (e.g., django@4.2) |
library update¶
Update a library to its latest version. Removes the old version and indexes the new one.
| Argument | Description |
|---|---|
name |
Library name to update |
library map¶
Map a package name to a git repository URL. Use this when a package's registry metadata does not include a source repo link, so library add cannot find the source automatically.
| Argument | Description |
|---|---|
spec |
Package spec: manager/name (e.g., pip/tiktoken) |
repo_url |
Git repository URL |
Mappings are saved in ~/.sylvan/registry.toml and reused automatically by library add.
sylvan library map pip/tiktoken https://github.com/openai/tiktoken
# Mapped pip/tiktoken -> https://github.com/openai/tiktoken
# Now run: sylvan library add pip/tiktoken
library unmap¶
Remove a package-to-repo URL mapping.
| Argument | Description |
|---|---|
spec |
Package spec to remove (e.g., pip/tiktoken) |
library mappings¶
List all user-provided package-to-repo URL mappings.
No options.
pip/tiktoken -> https://github.com/openai/tiktoken
pip/tree-sitter -> https://github.com/tree-sitter/py-tree-sitter
workspace create¶
Create a workspace, optionally indexing and adding projects in one step.
| Option | Default | Description |
|---|---|---|
--description, -d |
"" |
Workspace description |
--path, -p |
none | Paths to index and add (can repeat) |
# Empty workspace, add repos later
sylvan workspace create myproject -d "Frontend + backend"
# Create and index in one step
sylvan workspace create myproject -p /path/to/frontend -p /path/to/backend
workspace list¶
List all workspaces with repo and symbol counts.
No options.
workspace add¶
Add an already-indexed repo to a workspace.
| Option | Description |
|---|---|
--repo, -r |
Repository name (as shown in sylvan status) |
workspace show¶
Show workspace details and its repos.
workspace remove¶
Delete a workspace. Does not delete the indexed repos — they remain available individually.