This guide explains how to develop and contribute to the Claude Code Zed integration project locally.
claude-code-zed/
├── claude-code-extension/ # Zed extension (Rust → WASM)
│ ├── src/
│ │ └── lib.rs # Extension implementation
│ ├── Cargo.toml # Extension dependencies
│ └── extension.toml # Zed extension configuration
├── claude-code-server/ # Companion server (Native Rust)
│ ├── src/
│ │ ├── main.rs # Server entry point
│ │ ├── lsp.rs # LSP implementation
│ │ ├── mcp.rs # MCP protocol handling
│ │ └── websocket.rs # WebSocket server
│ └── Cargo.toml # Server dependencies
├── README.md # User documentation
├── DEVELOPMENT.md # This file
└── Cargo.toml # Workspace configuration
-
Rust Toolchain: Install the latest stable Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source ~/.cargo/env
-
WebAssembly Target: Required for building the Zed extension
rustup target add wasm32-wasip1
-
Zed Editor: Download from zed.dev
-
Claude Code CLI: Install from claude.ai/code
# Clone the repository
git clone https://github.com/jiahaoxiang2000/claude-code-zed.git
cd claude-code-zed
# Build the entire workspace
cargo buildThe Zed extension is written in Rust and compiled to WebAssembly.
# Build the extension
cd claude-code-extension
cargo build
# The built extension will be in target/wasm32-wasip1/debug/Zed has built-in support for installing development extensions directly from source code, which automatically handles the build process:
-
Install the extension using Zed's dev extension feature:
- Open Zed
- Press
Cmd+Shift+P(macOS) orCtrl+Shift+P(Linux) - Type "zed: install dev extension" and select it
- Navigate to and select the
claude-code-extensionfolder - Zed will automatically build and install the extension
-
View extension logs:
- Open Zed's log panel:
View → Debug→Open Log - Extension logs will appear with
[EXTENSION]prefix
- Open Zed's log panel:
- Auto-building: Zed's dev extension installer automatically builds the WASM extension
- Hot Reloading: After making code changes, reinstall the extension using the same process
- No manual build needed: You don't need to run
cargo buildmanually - Zed handles it - Logging: Use
eprintln!()for debugging - logs appear in Zed's debug panel - WASM Limitations: The extension runs in a sandboxed WASM environment with limited system access
The companion server is a native Rust application that handles WebSocket communication.
# Build the server
cd claude-code-server
cargo build
# For release build
cargo build --release# Run in debug mode
cd claude-code-server
cargo run -- --debug --worktree /path/to/your/project hybrid
# Or run the built binary
./target/debug/claude-code-server --debug --worktree /path/to/your/project hybrid- Debugging: Use
RUST_LOG=debugfor verbose logging - WebSocket Testing: Use tools like
wscatto test WebSocket connections - Lock Files: Check
~/.claude/ide/for server discovery files
-
Install extension in Zed using the dev extension feature:
- Open Zed
- Press
Cmd+Shift+P(macOS) orCtrl+Shift+P(Linux) - Type "zed: install dev extension" and select it
- Navigate to and select the
claude-code-extensionfolder - Zed will automatically build and install the extension
-
Test with Claude Code CLI:
# Open a supported file in Zed zed test.rs # In another terminal, run Claude Code CLI claude-code
-
Verify connection:
- Check Zed logs for extension startup messages
- Check
~/.claude/ide/for lock files - Verify WebSocket connection in server logs
- The server binary will be automatically downloaded when needed
The Zed extension (claude-code-extension) is responsible for:
- LSP Server Management: Starts and manages the companion server
- Binary Download: Downloads platform-specific server binaries from GitHub releases
- Configuration: Passes workspace and configuration data to the server
Key files:
src/lib.rs: Main extension implementationextension.toml: Zed extension configuration
The companion server (claude-code-server) handles:
- WebSocket Server: Creates WebSocket server on localhost
- Discovery Protocol: Writes lock files for Claude Code CLI discovery
- Authentication: Generates and validates UUID tokens
- Protocol Bridge: Translates between LSP and Claude Code protocols
Key files:
src/main.rs: Server entry point and argument parsingsrc/lsp.rs: LSP server implementationsrc/websocket.rs: WebSocket server and protocol handlingsrc/mcp.rs: MCP (Model Context Protocol) implementation
1. Zed Extension starts → 2. Launches companion server → 3. Server creates WebSocket
↓
6. Claude Code CLI ← 5. Discovers via lock file ← 4. Writes discovery lock file
-
Update extension configuration:
# claude-code-extension/extension.toml [language_servers.claude-code-server] languages = ["Rust", "JavaScript", "TypeScript", "Python", "Markdown", "NewLanguage"] [language_servers.claude-code-server.language_ids] "NewLanguage" = "newlanguage"
-
Rebuild and reinstall the extension
- Check extension logs in Zed's debug panel
- Verify server startup with manual server launch
- Check lock files in
~/.claude/ide/ - Test WebSocket connection with
wscat
- Define message types in
claude-code-server/src/mcp.rs - Implement handlers in the WebSocket server
- Update LSP bridge to forward messages
- Test with Claude Code CLI
-
Extension won't install:
- Check WASM target is installed:
rustup target add wasm32-wasip1 - Verify Cargo.toml has correct crate-type:
["cdylib"]
- Check WASM target is installed:
-
Server download fails:
- Check internet connection
- Verify GitHub release assets exist
- Check platform detection logic
-
WebSocket connection fails:
- Check if port is available
- Verify lock file permissions
- Check firewall settings
- Follow Rust standard formatting:
cargo fmt - Run clippy for linting:
cargo clippy - Write tests for new functionality
- Document public APIs