This repository has been archived and is no longer actively maintained.
We now focus on VSCode integration for Claude Code CLI. If you're looking for Claude Code editor integration, we recommend using VSCode instead of Zed.
Thank you to everyone who starred this repository and supported our work! 🙏
If you want to continue development of Zed integration, feel free to fork this repository and build upon this codebase.
A two-part system that integrates Claude Code CLI with Zed editor for AI-assisted coding.
- Text Selection Sharing: Zed can send selected text context to Claude Code CLI
- File Reference Handling: Selected code snippets and file paths are transmitted
- WebSocket Communication: Stable connection between Zed and Claude Code CLI
- LSP Diagnostics: Currently NOT implemented - Zed extension works as LSP client but doesn't expose IDE diagnostic information (errors, warnings, type hints) to Claude Code CLI
- One-way Communication: Primary flow is Zed → Claude Code; limited Claude Code → Zed capabilities
- Zed editor
- Claude Code CLI
-
Clone the repository:
git clone https://github.com/jiahaoxiang2000/claude-code-zed.git
-
Install the Zed extension (Development Mode):
- Open Zed editor
- Press
Cmd+Shift+P
(macOS) orCtrl+Shift+P
(Linux/Windows) to open the command palette - Type "zed: install dev extension" and select it
- Navigate to and select the
claude-code-extension
folder in your cloned repository - The extension will be installed and activated automatically
-
The claude-code-server is automatically downloaded:
- The extension will automatically download the appropriate
claude-code-server
binary from GitHub releases - No manual build or installation of the server is required
- The server binary is cached in the extension's working directory
- The extension will automatically download the appropriate
- macOS: Intel (x86_64) and Apple Silicon (aarch64)
- Linux: x86_64
- Windows: Not currently supported
The Claude Code extension runs as a Language Server Protocol (LSP) server and automatically activates when you open files with the following extensions:
- Rust (
.rs
) - JavaScript (
.js
) - TypeScript (
.ts
,.tsx
) - Python (
.py
) - Markdown (
.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:
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:
- Select some text in your Zed editor
- In Claude Code CLI, ask: "What did I select?"
- If connected properly, Claude should be able to see your selected text
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
- Rust toolchain with
wasm32-wasi
target:curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh rustup target add wasm32-wasi
- Zed editor for testing
- Claude Code CLI for integration testing
- Make (usually pre-installed on macOS/Linux)
The 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:
make dev-build
-
Restart Zed to use the updated binary
-
Test your changes (optional guided testing):
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:
- Edit
claude-code-extension/src/lib.rs
- Change
FORCE_DEVELOPMENT_MODE
totrue
- Restart Zed (the extension will recompile automatically)
- 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:
- Purpose: Zed editor integration and LSP communication
- Technology: Rust compiled to WebAssembly
- Responsibilities:
- Editor selection tracking
- File reference handling
- LSP server lifecycle management
- Communication with the companion server
- Purpose: WebSocket server for Claude Code CLI communication
- Technology: Native Rust application
- Responsibilities:
- WebSocket server on localhost
- Lock file management (
~/.claude/ide/[port].lock
) - Authentication token handling
- JSON-RPC protocol implementation
- Bridging between Zed extension and Claude Code CLI
The system implements the Claude Code protocol as documented in claudecode.nvim PROTOCOL.md:
-
Zed Extension Startup:
- Extension loads in Zed's WASM environment
- Establishes LSP connection to companion server
- Begins tracking editor selections and file changes
-
Companion Server Launch:
claude-code-server
starts as native process- Creates WebSocket server on random port (10000-65535)
- Writes discovery lock file to
~/.claude/ide/[port].lock
- Sets environment variables (
CLAUDE_CODE_SSE_PORT
,ENABLE_IDE_INTEGRATION
)
-
Claude Code Discovery:
- Claude Code CLI discovers server via lock file
- Authenticates using UUID token from lock file
- Establishes WebSocket connection
-
Bidirectional Communication:
- Zed → Claude: Selection changes, file references via LSP → Server → WebSocket
- Claude → Zed: MCP tool calls via WebSocket → Server → LSP → Extension
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 changes
A: 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:
- Open Zed editor
- Press
Cmd+Shift+P
(macOS) orCtrl+Shift+P
(Linux/Windows) to open the command palette - Type "zed: install dev extension" and select it
- Navigate to and select the
claude-code-extension
folder in your cloned repository - The extension will be installed and activated automatically
If 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:
- Close Zed completely
- Remove the extension cache (location varies by OS):
- macOS:
~/Library/Application Support/Zed/extensions
- Linux:
~/.local/share/zed/extensions
- macOS:
- Restart Zed and try installing again
A: Check the following:
- Verify the extension is active: Look for "Claude Code Server" in Zed's language server status
- Check supported file types: The extension only activates for
.rs
,.js
,.ts
,.tsx
,.py
, and.md
files - Restart Zed: Sometimes a restart is needed after installation
- Check logs: Open Zed's developer console to see any error messages
A: To view detailed debug logs from the Claude Code extension:
-
Start Zed with the
--foreground
flag:zed --foreground .
-
Start Claude Code CLI in another terminal:
claude-code
-
Enable IDE integration:
/ide
-
Select
claude-code-server
from the menu
When running Zed with --foreground
, you'll see real-time debug output from the extension in your terminal, including:
- Extension initialization messages
- LSP server startup logs
- Connection status messages
- Selection change events
- Communication between Zed and Claude Code CLI
- Any errors or warnings
This is particularly useful for troubleshooting connection issues or understanding the extension's behavior.
A: When properly connected, you should see:
- A lock file created at
~/.claude/ide/[port].lock
- The Claude Code CLI will show IDE integration status
- Text selections in Zed will be visible to Claude Code CLI
If you continue experiencing issues, please open an issue with your error details and system information.