A two-part system that integrates Claude Code CLI with Zed editor for AI-assisted coding.

getWorkspaceFoldersThe following tools are exposed to Claude Code CLI:
- getCurrentSelection - Get the current text selection in the active editor
- getLatestSelection - Get the most recent text selection
- getWorkspaceFolders - Get the workspace folders open in the IDE
- getDiagnostics - Get diagnostics (errors, warnings) for files in the workspace
openFile, openDiff, saveDocument are not available in Zed integrationClone the repository:
bash
git clone https://github.com/celve/claude-code-zed.git
Install the Zed extension (Development Mode):
Cmd+Shift+P (macOS) or Ctrl+Shift+P (Linux/Windows) to open the command paletteclaude-code-extension folder in your cloned repositoryThe extension will be installed and activated automatically
The claude-code-server is automatically downloaded:
claude-code-server binary from GitHub releasesThe Claude Code extension runs as a Language Server Protocol (LSP) server and automatically activates when you open files with the following extensions:
.rs).js).ts, .tsx).py).md)To enable Claude Code integration for additional file types, edit the claude-code-extension/extension.toml file:
[language_servers.claude-code-server]
name = "Claude Code Server"
languages = ["Rust", "JavaScript", "TypeScript", "Python", "Markdown", "Go", "Java"]
[language_servers.claude-code-server.language_ids]
"Rust" = "rust"
"JavaScript" = "javascript"
"TypeScript" = "typescript"
"Python" = "python"
"Markdown" = "markdown"
"Go" = "go"
"Java" = "java"
After modifying the configuration, reinstall extention and restart Zed for the changes to take effect.
Once the extension is installed, follow these steps to connect Claude Code CLI with Zed:
Open a supported file in Zed: Create or open a file with one of the supported extensions (.rs, .js, .ts, .tsx, .py, .md)
Start Claude Code CLI: Open your terminal and run:
bash
claude-code
Enable IDE integration: In Claude Code CLI, run:
/ide
Select the integration: Choose claude-code-server from the menu that appears
Test the connection:
Once connected, you'll have: - Text selection sharing: Selected text in Zed is automatically available to Claude Code CLI - File context: Claude can see which file you're working in - Real-time updates: Changes in your selection are immediately reflected in Claude
To confirm everything is working:
- Check for a lock file at ~/.claude/ide/[port].lock
- The Claude Code CLI will display IDE integration status
- Text selections in Zed should be visible to Claude Code CLI
wasm32-wasi target:
bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup target add wasm32-wasiThe easiest way to develop and test changes:
Make your changes to the server code in claude-code-server/src/
Build and deploy in one command:
bash
make dev-build
Restart Zed to use the updated binary
Test your changes (optional guided testing):
bash
make dev-test
| Command | Description |
|---|---|
make dev-build |
Build release version and deploy to Zed |
make dev-debug |
Build debug version and deploy to Zed |
make dev-clean |
Remove development deployment |
make dev-test |
Build, deploy, and show testing instructions |
make status |
Show current deployment status |
make help |
Show all available commands |
The Makefile automatically: - Detects your platform (macOS Intel/ARM, Linux) - Builds the server with the correct target - Creates the Zed extension directory if needed - Copies the binary with the platform-specific name - Provides clear feedback and next steps
By default, the extension uses production behavior (downloads from GitHub releases). For developers who want to test local changes, you can enable development mode via the FORCE_DEVELOPMENT_MODE flag in claude-code-extension/src/lib.rs:
// Set this to true to always use local development binaries instead of GitHub releases
// DEFAULT: false (production behavior - downloads from GitHub)
const FORCE_DEVELOPMENT_MODE: bool = false;
When FORCE_DEVELOPMENT_MODE = false (DEFAULT):
- ✅ Standard production behavior
- ✅ Downloads official binaries from GitHub releases
- ✅ Only uses development binaries in claude-code-zed project directories
- ✅ Safe for end users and most development work
When FORCE_DEVELOPMENT_MODE = true (DEVELOPMENT):
- Extension always looks for manually copied binaries first
- Works in any directory (not just claude-code-zed projects)
- Allows using local fixes immediately without waiting for releases
To enable development mode:
1. Edit claude-code-extension/src/lib.rs
2. Change FORCE_DEVELOPMENT_MODE to true
3. Restart Zed (the extension will recompile automatically)
4. Use make dev-build to deploy your local binary
# Check current status
make status
# Make changes to claude-code-server/src/lsp.rs
# Build and deploy
make dev-build
# Restart Zed and test
make dev-test
If you prefer manual control:
# Build the server
cd claude-code-server
cargo build --release
# Copy to Zed extension directory (macOS ARM example)
cp target/release/claude-code-server \
"$HOME/Library/Application Support/Zed/extensions/work/claude-code-zed/claude-code-server-macos-aarch64"
"Binary not found" after make dev-build:
- Ensure Zed was completely restarted
- Check make status to verify deployment
- Try make dev-clean && make dev-build
Extension compilation errors:
- Verify Rust toolchain: rustup target list --installed | grep wasm32-wasi
- Update Rust: rustup update
- Clear Zed cache and reinstall extension
Connection issues:
- Check file type is supported (.rs, .js, .ts, .py, .md)
- Look for "Claude Code Server" in Zed's language server status
- Restart both Zed and Claude Code CLI
This project consists of two components:
claude-code-zed)claude-code-server)lsp/ - LSP server implementation (handlers, notifications, watchdog)mcp/ - MCP protocol implementation (handlers, tools, types)websocket.rs - WebSocket server and client management~/.claude/ide/[port].lock)The system implements the Claude Code protocol as documented in claudecode.nvim PROTOCOL.md:
Begins tracking editor selections and file changes
Companion Server Launch:
claude-code-server starts as native process~/.claude/ide/[port].lockSets environment variables (CLAUDE_CODE_SSE_PORT, ENABLE_IDE_INTEGRATION)
Claude Code Discovery:
Establishes WebSocket connection
Bidirectional Communication:
Zed Editor (WASM) ←→ LSP ←→ Native Server ←→ WebSocket ←→ Claude Code CLI
│ │
└── Selection tracking └── Protocol implementation
└── File references └── Lock file management
└── WASM-safe operations └── Full system access
selection_changed: Notifies Claude when text selection changesA: This error typically occurs when Zed cannot compile the Rust extension to WebAssembly. Here are the solutions:
Make sure you have Rust installed with the wasm32-wasi target:
# Install Rust if you haven't already
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Add the WebAssembly target
rustup target add wasm32-wasi
Instead of installing from source, try installing the published extension:
Cmd+Shift+P (macOS) or Ctrl+Shift+P (Linux/Windows) to open the command paletteclaude-code-extension folder in your cloned repositoryIf you need to install from source, verify the extension compiles correctly:
cd claude-code-extension
cargo check --target wasm32-wasi
If this fails, check that your Rust toolchain is up to date:
rustup update
For macOS users who encounter issues with the standard Rust installation, use Homebrew:
# Install rustup through Homebrew
brew install rustup-init
# Run rustup-init to complete the installation
rustup-init
# Add Cargo bin directory to your PATH
echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.zshrc
# Reload your shell configuration
source ~/.zshrc
# Add the WebAssembly target
rustup target add wasm32-wasi
After installation, restart your terminal and try installing the Zed extension again.
Sometimes clearing the extension cache helps:
~/Library/Application Support/Zed/extensions~/.local/share/zed/extensionsA: Check the following:
.rs, .js, .ts, .tsx, .py, and .md filesA: To view detailed debug logs from the Claude Code extension:
--foreground flag:
```bash
ze$ claude mcp add claude-code-zed \
-- python -m otcore.mcp_server <graph>