CLI Reference
The CodeLayers CLI is the command-line tool that runs on your development machine. It parses your code, builds the dependency graph, encrypts everything, and syncs to the backend where your devices receive updates in real-time.
Installation
curl -fsSL https://codelayers.ai/install.sh | bash
Or with Homebrew:
brew install codelayers-ai/tap/codelayers
Verify installation:
codelayers --version
Global Options
These options work with any command:
| Option | Description |
|---|---|
| -d, --debug | Enable debug logging |
| -h, --help | Show help |
| -V, --version | Show version |
Commands
login
Authenticate by entering your 12-word mnemonic phrase.
codelayers login
What happens:
- You'll be prompted to enter your 12-word mnemonic (generated in the app)
- Your mnemonic is used to derive an encryption key (never sent to servers)
- A "sync ID" is derived and sent to the backend to link your devices
| Option | Description |
|---|---|
| -f, --force | Force re-authentication (clear existing credentials) |
Example:
# Enter your mnemonic from the app
codelayers login
# Force new login (e.g., to switch accounts)
codelayers login --force
logout
Sign out and clear stored credentials.
codelayers logout
What happens:
- Clears stored mnemonic and authentication tokens
- Stops any running watch processes
- Does NOT delete your synced data from the backend (it's encrypted and useless without your mnemonic)
status
Show current authentication and sync status.
codelayers status
Example output:
Authentication:
✓ Logged in as user_abc123
✓ Mnemonic configured (sync ID: a1b2c3...)
Synced Repositories:
~/projects/my-app (last sync: 2 minutes ago)
~/projects/api-server (watching)
Backend Connection:
✓ WebSocket connected
2 devices subscribed
explore
Explore any public GitHub Pull Request in 3D — no clone, no checkout, no account required. Opens directly in your browser.
codelayers explore <PR_URL>
| Argument | Description |
|---|---|
| PR_URL | GitHub Pull Request URL (e.g., https://github.com/owner/repo/pull/123) |
What happens:
- Fetches the PR metadata and diff from GitHub
- Builds a dependency graph of the repository
- Calculates blast radius from the PR's changed files
- Opens an interactive 3D visualization in your browser
Free tier: 10 explores every 30 days. No account required.
Example:
# Explore a PR
codelayers explore https://github.com/openclaw/openclaw/pull/17092
# Works with any public GitHub PR
codelayers explore https://github.com/facebook/react/pull/31763
sync
One-time sync of a repository to the backend.
codelayers sync [PATH]
| Argument | Description |
|---|---|
| PATH | Path to repository (defaults to current directory) |
| Option | Description |
|---|---|
| --clean | Force clean sync - delete existing graph and re-upload everything |
What happens:
- Parses all supported files using tree-sitter
- Builds a dependency graph (functions, classes, imports, calls)
- Calculates metrics (PageRank, centrality, topological depth)
- Encrypts the graph with your mnemonic-derived key
- Uploads encrypted chunks to the backend
Example:
# Sync current directory
codelayers sync
# Sync specific path
codelayers sync ~/projects/my-app
# Force complete re-sync (useful if graph seems corrupted)
codelayers sync --clean
watch
Watch a repository for changes and sync updates to your devices in real-time via the backend.
codelayers watch [PATH] [OPTIONS]
| Option | Description |
|---|---|
| --agent <AGENT> | Enable AI agent integration (claude, gemini, or codex) |
| --mcp | Run as MCP server for Claude (advanced) |
What happens:
- Does an initial sync (like
codelayers sync) - Establishes WebSocket connection to backend
- Watches for file changes and syncs updates in real-time
- Backend relays updates to connected devices
- If
--agentis specified, launches the AI coding agent
Example:
# Basic watch mode
codelayers watch
# Watch with Claude Code integration
codelayers watch --agent claude
# Watch specific directory with Gemini
codelayers watch ~/projects/api --agent gemini
See AI Agents guide for tips on using the --agent option effectively.
share
Create a shareable link to an interactive 3D code visualization. The link is zero-knowledge encrypted — the server never sees your code.
codelayers share [PATH] [OPTIONS]
| Option | Default | Description |
|---|---|---|
| PATH | . | Path to repository |
| --base <REF> | — | PR mode: base branch/commit (e.g., main, origin/main, SHA) |
| --head <REF> | HEAD | PR mode: head branch/commit |
| --expires <DAYS> | 7 | Days until share expires (max 90 for Pro) |
| --max-views <N> | unlimited | Maximum number of views |
| --format <FMT> | human | Output format: human or json |
| --github-repo <OWNER/REPO> | — | Link share to GitHub repository |
| --github-pr <NUMBER> | — | Link share to GitHub PR number |
| --github-pr-title <TITLE> | — | PR title for display in viewer |
Example:
# Share current directory (uncommitted changes as blast radius)
codelayers share
# PR mode: compare base to head
codelayers share . --base origin/main --head HEAD
# Customize expiry
codelayers share --expires 30
# Machine-readable output (for CI/CD)
codelayers share --format json
# Link to a GitHub PR (adds PR title + link in viewer)
codelayers share . --base origin/main --head HEAD \
--github-repo owner/repo \
--github-pr 42 \
--github-pr-title "Add auth flow"
JSON output (when --format json):
{
"share_url": "https://app.codelayers.ai/s/{uuid}#k={base64_key}",
"share_id": "uuid",
"node_count": 1247,
"file_count": 582,
"edge_count": 3891,
"changed_file_count": 12,
"total_loc": 45230,
"blast_radius_count": 47,
"languages": { "rust": 312, "typescript": 156, "swift": 89 }
}
See Web Sharing for details on how encryption works and viewer features.
shares
Manage your shared visualization links.
codelayers shares <SUBCOMMAND>
| Subcommand | Description |
|---|---|
| list [PATH] | List all shares (optionally filter by repo path) |
| copy <SHARE_ID> | Copy share URL to clipboard (macOS) |
| info <SHARE_ID> | Show share details |
| remove <SHARE_ID> | Delete a share (removes from backend + local history) |
| cleanup | Remove all expired shares from local history |
Example:
# List all shares
codelayers shares list
# List shares for a specific repo
codelayers shares list ~/projects/my-app
# Copy a share URL to clipboard
codelayers shares copy abc-123-def
# Delete a share
codelayers shares remove abc-123-def
# Clean up expired shares
codelayers shares cleanup
api-keys
Create and manage API keys for headless/CI authentication. API keys let you use the CLI in environments where interactive login isn't possible, like GitHub Actions or CI/CD pipelines.
codelayers api-keys <SUBCOMMAND>
| Subcommand | Description |
|---|---|
| create <NAME> [OPTIONS] | Create a new API key |
| list | List all API keys (shows name, ID, scopes, status) |
| revoke <KEY_ID> | Revoke an API key |
Create options:
| Option | Default | Description |
|---|---|---|
| --scopes <SCOPES> | all | Comma-separated scopes (share:create, share:read, share:delete, sync:write, sync:read) |
| --expires <DAYS> | never | Days until key expires |
Example:
# Create a key with default scopes
codelayers api-keys create "GitHub CI"
# Create with specific scopes
codelayers api-keys create "Read Only" --scopes share:read,sync:read
# Create with expiry
codelayers api-keys create "Temp Key" --expires 30
# List all keys
codelayers api-keys list
# Revoke a key
codelayers api-keys revoke key_abc123
Using an API key:
Set the CODELAYERS_API_KEY environment variable:
export CODELAYERS_API_KEY=cl_key_xxxxxxxxxxxx
codelayers share .
When an API key is set, the CLI skips interactive login and uses the key for all API calls.
Requirements: To create API keys, you need the CLI installed, an active Pro subscription, and to be logged in.
pair
Pair with a device using a 6-digit code to share your mnemonic.
codelayers pair
What happens:
- Generates a 6-digit pairing code
- Discovers your device via mDNS on local network
- Waits for the device to enter the code
- Securely transfers mnemonic to the device
When to use:
- Initial device setup when mnemonic is on CLI
- Sharing mnemonic with a new device
- When you want to pair without manually typing 12 words
Note: After pairing, all data sync happens through the backend WebSocket—P2P is only used for this initial pairing process.
list
List all synced repositories.
codelayers list
Example output:
Synced Repositories:
~/projects/my-app
Last sync: 2024-01-15 10:30:45
Files: 847
Graph: 1,523 nodes, 4,291 edges
~/projects/api-server
Last sync: 2024-01-15 10:28:12
Files: 234
Graph: 512 nodes, 1,203 edges
Currently watching
info
Show detailed sync status for a repository.
codelayers info [PATH]
Example output:
Repository: ~/projects/my-app
Sync Status:
Last sync: 2024-01-15 10:30:45
Graph version: 47
Files parsed: 847
Nodes: 1,523
Edges: 4,291
Languages Detected:
TypeScript: 612 files
Python: 198 files
JSON: 37 files
Cache:
Location: ~/.codelayers/
Size: 12.4 MB
AI Agents
CodeLayers integrates with AI coding assistants to provide spatial context for code conversations.
Supported Agents
| Agent | Command | Requirements |
|---|---|---|
| Claude Code | --agent claude | Claude Code CLI installed |
| Gemini | --agent gemini | Gemini CLI installed |
| Codex | --agent codex | Codex CLI installed |
How It Works
Interactive Mode (default):
- Run
codelayers watch --agent claude - CLI spawns Claude Code as a subprocess
- You type prompts in the terminal
- Your device observes the conversation and highlights relevant files
Remote Mode:
- Your device sends prompts to CLI via WebSocket
- CLI forwards prompts to the AI agent
- Responses stream back to your device
Example Session
$ codelayers watch --agent claude
✓ Synced 847 files
✓ Backend WebSocket connected
✓ Claude Code connected
You: How does authentication work in this project?
Claude: Looking at the codebase, authentication is handled in
`src/auth/`. The main entry point is `auth.ts` which uses JWT
tokens stored in cookies...
[CodeLayers highlights: src/auth/auth.ts, src/auth/jwt.ts, src/middleware/auth.ts]
MCP Tools
When using --agent claude, an MCP server provides tools for visualization control:
| Tool | Description |
|---|---|
| highlight_file | Highlight a specific file in the 3D view |
| focus_node | Zoom and center on a specific node |
| show_dependencies | Show edges to/from a node |
| switch_mode | Change visualization mode |
Supported Languages
CodeLayers uses tree-sitter for parsing. Currently supported:
| Language | Extensions |
|---|---|
| Rust | .rs |
| TypeScript | .ts, .tsx |
| JavaScript | .js, .jsx, .mjs |
| Python | .py |
| Java | .java |
| Go | .go |
| C++ | .cpp, .cc, .cxx, .h, .hpp |
| C# | .cs |
| Ruby | .rb |
| PHP | .php |
| Swift | .swift |
Files with other extensions are tracked but not parsed for dependencies.