claudecode.nvim
CLAUDE.md3.1k starsChanged 6 months agoMITView on GitHub
This file provides context for Claude Code when working with this codebase. claudecode.nvim - A Neovim plugin that implements the same WebSocket-based MCP protocol as Anthropic's official IDE extensions. Built with pure Lua and zero dependencies. Best Practice: Always use mise run all at the end of editing sessions for complete validation. The dev toolchain is provisioned by mise (see mise.toml), which replaced the former Nix flake devShell. The fixtures/ directory contains test Neovim configurations for verifying plugin integrations: Available…
Trending
Quiet since September.about the whole repository
Who's talking about coder/claudecode.nvim
- anomalyco/opencode“Editor integrations”GitHub · Jun 19, 2025 · 68 reactions
- microsoft/vscode“Support CLI agents”GitHub · Aug 21, 2025 · 10 reactions
- LazyVim/LazyVim“feat(extras): ai: add `claudecode.nvim`”GitHub · Jul 5, 2025 · 8 reactions
- folke/sidekick.nvim“feature: Native IDE Integration via ACP/MCP Protocol”GitHub · Dec 18, 2025 · 6 reactions
- A Hacker News story“Show HN: Claudecode.nvim – Bringing Claude to Neovim (+how their protocol works)”Hacker News · Jun 2, 2025 · 4 points
The biggest 5 of 39 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 39
Talked about on GitHub, Hacker News and Bluesky (39 times).
On GitHub · 35
- Jun 19, 2025Editor integrations — anomalyco/opencode68 reactions · 33 comments
- Aug 21, 2025Support CLI agents — microsoft/vscode10 reactions · 2 comments
- Jul 5, 2025feat(extras): ai: add `claudecode.nvim` — LazyVim/LazyVim8 reactions · 2 comments
- Dec 18, 2025feature: Native IDE Integration via ACP/MCP Protocol — folke/sidekick.nvim6 reactions · 3 comments
- Mar 20, 2026feature: Integrate with /ide in various AI tools — folke/sidekick.nvim3 reactions · 6 comments
30 more on GitHub
- Jun 23, 2025[PLUGIN REQUEST] coder/claudecode.nvim — nix-community/nixvim2 reactions · 2 comments
- Sep 27, 2025Propuesta de cambio de plugin de Claude Code — Gentleman-Programming/Gentleman.Dots1 reaction · 2 comments
- Jul 9, 2025fix(vectorcode): wrap logging in vim.schedule to prevent fast event context errors — ravitemer/codecompanion-history.nvim1 reaction · 1 comment
- Sep 7, 2026[Resource]: claudecode.nvim — hesreallyhim/awesome-claude-code0 reactions · 1 comment
- Sep 7, 2026Add `coder/claudecode.nvim` — rockerBOO/awesome-neovim0 reactions
- Sep 4, 2026Claude-Code Plugins to add — rockerBOO/awesome-neovim0 reactions · 2 comments
- Aug 28, 2026claude_code_ide: Make Zed a recognised Claude Code IDE — zed-industries/zed0 reactions · 1 comment
- Jun 30, 2026[plugins] Add claudecode.nvim plugin configuration — tntzxzttt/nvim0 reactions
- Jun 26, 2026Install claude-code integration plugin — nox456/neovim-config0 reactions
- Jun 26, 2026Bump claudecode-nvim from `288c9bf` to `2390c6e` in /plugins — josh/lazy-nvim-nix0 reactions
- Jun 25, 2026feat: 遷移 CCC nvim 整合到 coder/claudecode.nvim + claude-tmux.nvim — Shiou-Ju/nvim0 reactions · 2 comments
- Jun 23, 2026Bump claudecode-nvim from `bcb3fe2` to `288c9bf` in /plugins — josh/lazy-nvim-nix0 reactions
- Jun 18, 2026Bump claudecode-nvim from `e6c9dd4` to `bcb3fe2` in /plugins — josh/lazy-nvim-nix0 reactions
- Jun 16, 2026Bump claudecode-nvim from `7c7d47e` to `e6c9dd4` in /plugins — josh/lazy-nvim-nix0 reactions
- Jun 12, 2026Bump claudecode-nvim from `7b8b709` to `7c7d47e` in /plugins — josh/lazy-nvim-nix0 reactions
- Jun 9, 2026Bump claudecode-nvim from `b9b99f9` to `7b8b709` in /plugins — josh/lazy-nvim-nix0 reactions
- Jun 8, 2026Bump claudecode-nvim from `8ec3212` to `b9b99f9` in /plugins — josh/lazy-nvim-nix0 reactions
- Jun 4, 2026Bump claudecode-nvim from `781f3ab` to `8ec3212` in /plugins — josh/lazy-nvim-nix0 reactions
- Jun 2, 2026Bump claudecode-nvim from `102d835` to `781f3ab` in /plugins — josh/lazy-nvim-nix0 reactions
- Apr 28, 2026feat(nvim): adopt official Claude Code extra, retire avante/gp/claude-code.nvim, fix obsidian fork + sops event — olafkfreund/nixos_config0 reactions
- Apr 28, 2026Bump claudecode-nvim from `432121f` to `102d835` in /plugins — josh/lazy-nvim-nix0 reactions
- Apr 27, 2026Weekly radar update — 2026-04-27 — breckenedge/claude-code-radar0 reactions
- Feb 26, 2026[Sprint 16] WebSocket server + lock file (ide_server.rs) — magiash/magia-legacy0 reactions
- Feb 26, 2026[Sprint 16] #579 Claude Code IDE Integration Protocol — magiash/magia-legacy0 reactions
- Feb 8, 2026feat(neovim): claude-code window 위치를 하단으로 변경 — iai6203/dotfiles0 reactions
- Jan 20, 2026feat: 🎸 refactor: migrate Neovim config from packer.nvim to lazy.nvim — kohbis/dotfiles0 reactions
- Oct 1, 2025at_mentioned support for sending context (region) to Claude Code — stevemolitor/monet0 reactions
- Sep 16, 2025vimPlugins.claude-fzf{-history}-nvim: init at 2025-09-06 — NixOS/nixpkgs0 reactions · 1 comment
- Jul 17, 2025coder/claudecode.nvim 用の ddt.vim ターミナルプロバイダを作る — gamoutatsumi/nix-config0 reactions · 12 comments
- Jun 30, 2025Support LSP Features — stevemolitor/claude-code.el0 reactions · 3 comments
On Hacker News · 3
- Jun 2, 2025Show HN: Claudecode.nvim – Bringing Claude to Neovim (+how their protocol works)4 points
- Jun 26, 2025Looking for AI tools in neovim3 points · 1 comment
- Aug 7, 2025Claudecode.nvim2 points · 1 comment
On Bluesky · 1
- Apr 4, 2026思いつきでNeovimの環境構築を半ばまで済ませ、 github.com/coder/claude... でClaude Codeを使えるようにしてみた — @ymatz.net3 likes and reposts · 1 reply
In this repositoryOne other file it gives its agents.
- AGENTS.mdAGENTS.md
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
43 rules. About 0 are common, 21 are distinctive, and 22 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈21
Distinctive · estimate
This author's own choices. Worth a look.
22
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 32
Best Practice: Always use mise run all at the end of editing sessions for complete validation.
- Distinctive: line 92
Complete VS Code Extension Compatibility: All tools now implement identical behavior and output formats as the official VS Code extension.
- Very specific: line 111
Format Compliance: All tools return MCP-compliant format: {content: [{type: "text", text: "JSON-stringified-data"}]}
- Distinctive: line 162
Identical Tool Set: All 10 VS Code tools implemented
- Very specific: line 169
Run mise run test to verify MCP compliance:
- Distinctive: line 171
Tool Format Validation: All tools return proper MCP structure
- Very specific: line 183
Test files follow the pattern *_spec.lua or *_test.lua and use the busted framework.
- Distinctive: line 194
Test Pattern: Run specific test files during development:
- Distinctive: line 214
Mocking: Use comprehensive mocking for vim APIs and external dependencies
- Distinctive: line 217
Clarity: Test names should clearly describe what behavior is being verified
- Very specific: line 263
Start the plugin: :ClaudeCodeStart
- Very specific: line 264
Check lock file contains authToken: cat ~/.claude/ide/*.lock | jq .authToken
- Very specific: line 265
Test WebSocket connection with auth: Use test scripts in scripts/ directory
- Very specific: line 266
Verify authentication in logs: Set log_level = "debug" in config
- Very specific: line 312
Example use case: If you frequently use <CR> or arrow keys in the Claude Code terminal to accept/reject diffs, enable this option to …
- Distinctive: line 339
Connection Events: Use DEBUG level for routine connection establishment/teardown
- Distinctive: line 340
Authentication Flow: Use DEBUG for successful auth, WARN for failures
- Distinctive: line 341
User-Facing Events: Use INFO sparingly for events users need to know about
- Distinctive: line 342
System Errors: Use ERROR for failures that require user attention
- Distinctive: line 357
All authentication events are logged for security auditing
- Distinctive: line 375
When updating the version number for a new release, you must update ALL of these files:
- Very specific: line 396
CHANGELOG.md: - Add new release section with: - Distinctive: line 426
Start Development: Use existing tests and documentation to understand the system
- Distinctive: line 427
Make Changes: Follow existing patterns and conventions in the codebase
- Very specific: line 428
Validate Work: Run mise run all to ensure formatting, linting, and tests pass
- Distinctive: line 429
Document Changes: Update relevant documentation (this file, PROTOCOL.md, etc.)
- Very specific: line 430
Commit: Only commit after successful mise run all execution
- Very specific: line 436
Implement Integration: Add support in relevant modules (e.g., lua/claudecode/tools/)
- Very specific: line 438
Test Integration: Use fixture to verify functionality with vv [integration-name]
- Distinctive: line 439
Update Documentation: Add integration to fixtures list and relevant tool documentation
- Very specific: line 440
Run Full Test Suite: Ensure mise run all passes with new integration
- Very specific: line 446
Test all relevant claudecode.nvim features with the integration
- Distinctive: line 447
Document any integration-specific behaviors or limitations
- Distinctive: line 457
Update Documentation: Add to this file's MCP tools list
- Distinctive: line 485
Zero Warnings: All code must pass luacheck with 0 warnings/errors
- Distinctive: line 486
MCP Compliance: All tools must return proper MCP format with JSON-stringified content
- Very specific: line 488
Consistent Formatting: Use mise run format (treefmt) for consistent code style
- Distinctive: line 489
Documentation: Update CLAUDE.md for architectural changes, PROTOCOL.md for protocol changes
- Very specific: line 494
mise run test: - All tests passing (320/320 success rate required) - Very specific: line 509
Ensure all tools return: {content: [{type: "text", text: "JSON-string"}]}
- Very specific: line 510
Use vim.json.encode() for proper JSON stringification
- Very specific: line 511
Test JSON parsing with custom test decoder in tests/busted_setup.lua
- Very specific: line 517
Check lua/claudecode/tools/init.lua for registration patterns
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides context for Claude Code when working with this codebase.
Project Overview
claudecode.nvim - A Neovim plugin that implements the same WebSocket-based MCP protocol as Anthropic's official IDE extensions. Built with pure Lua and zero dependencies.
Common Development Commands
Testing
mise run test- Run all tests using busted with coveragebusted tests/unit/specific_spec.lua- Run specific test filebusted --coverage -v- Run tests with coverage
Code Quality
mise run check- Check Lua syntax and run luacheckmise run format- Format code with treefmtluacheck lua/ tests/ --no-unused-args --no-max-line-length- Direct linting
Build Commands
mise run all- RECOMMENDED: Run formatting, linting, and testing (complete validation)mise run test- Run all tests using busted with coveragemise run check- Check Lua syntax and run luacheckmise run format- Format code with treefmtmise run clean- Remove generated test filesmise tasks- List available tasks
Best Practice: Always use mise run all at the end of editing sessions for complete validation.
Development with mise
The dev toolchain is provisioned by mise (see mise.toml), which replaced the former Nix flake devShell.
mise install- Install all tools (Neovim, LuaJIT, formatters, etc.)mise run setup- Build the Lua test rocks (busted/luacheck/luacov) into./.luarocksmise run all- Format, lint, and testmise run format- Format all files with treefmt- Activate mise in your shell so its tools (and
fixtures/bin) are on PATH — addeval "$(mise activate bash)"(orzsh/fish) to your shell rc. (mise run <task>works without activation.)
Integration Testing with Fixtures
The fixtures/ directory contains test Neovim configurations for verifying plugin integrations:
vv <config>- Start Neovim with a specific fixture configurationvve <config>- Start Neovim with a fixture config in edit modelist-configs- Show available fixture configurations- Source
fixtures/nvim-aliases.shto enable these commands
Available Fixtures:
netrw- Tests with Neovim's built-in file explorernvim-tree- Tests with nvim-tree.lua file exploreroil- Tests with oil.nvim file explorermini-files- Tests with mini.files file explorer
Usage: source fixtures/nvim-aliases.sh && vv oil starts Neovim with oil.nvim configuration
Architecture Overview
Core Components
- WebSocket Server (
lua/claudecode/server/) - Pure Neovim implementation using vim.loop, RFC 6455 compliant - MCP Tool System (
lua/claudecode/tools/) - Implements tools that Claude can execute (openFile, getCurrentSelection, etc.) - Lock File System (
lua/claudecode/lockfile.lua) - Creates discovery files for Claude CLI at~/.claude/ide/ - Selection Tracking (
lua/claudecode/selection.lua) - Monitors text selections and sends updates to Claude - Diff Integration (
lua/claudecode/diff.lua) - Native Neovim diff support for Claude's file comparisons - Terminal Integration (
lua/claudecode/terminal.lua) - Manages Claude CLI terminal sessions with support for internal Neovim terminals and external terminal applications
WebSocket Server Implementation
- TCP Server:
server/tcp.luahandles port binding and connections - Handshake:
server/handshake.luaprocesses HTTP upgrade requests with authentication - Frame Processing:
server/frame.luaimplements RFC 6455 WebSocket frames - Client Management:
server/client.luamanages individual connections - Utils:
server/utils.luaprovides base64, SHA-1, XOR operations in pure Lua
Authentication System
The WebSocket server implements secure authentication using:
- 128-bit Tokens: 32-char lowercase hex from the OS CSPRNG, generated per session
- Header-based Auth: Uses
x-claude-code-ide-authorizationheader - Lock File Discovery: Tokens stored in
~/.claude/ide/[port].lockfor Claude CLI - MCP Compliance: Follows official Claude Code IDE authentication protocol
MCP Tools Architecture (✅ FULLY COMPLIANT)
Complete VS Code Extension Compatibility: All tools now implement identical behavior and output formats as the official VS Code extension.
MCP-Exposed Tools (with JSON schemas):
openFile- Opens files with optional line/text selection (startLine/endLine), preview mode, text pattern matching, and makeFrontmost flaggetCurrentSelection- Gets current text selection from active editorgetLatestSelection- Gets most recent text selection (even from inactive editors)getOpenEditors- Lists currently open files with VS Code-compatibletabsstructureopenDiff- Opens native Neovim diff viewscheckDocumentDirty- Checks if document has unsaved changessaveDocument- Saves document with detailed success/failure reportinggetWorkspaceFolders- Gets workspace folder informationcloseAllDiffTabs- Closes the diffs claudecode itself opened (its tracked diff registry only). It never touches diffs created by other tools such as diffview.nvim, fugitive, or native:diffsplit, andopenFile/openDiffnever reuse a window that is currently in diff mode (issue #277).getDiagnostics- Gets language diagnostics (errors, warnings) from the editor
Internal Tools (not exposed via MCP):
close_tab- Internal-only tool for tab management (hardcoded in Claude Code)
Format Compliance: All tools return MCP-compliant format: {content: [{type: "text", text: "JSON-stringified-data"}]}
Terminal Integration Options
Internal Terminals (within Neovim):
- Snacks.nvim:
terminal/snacks.lua- Advanced terminal with floating windows - Native:
terminal/native.lua- Built-in Neovim terminal as fallback
External Terminals (separate applications):
- External Provider:
terminal/external.lua- Launches Claude in external terminal apps
Configuration Example:
opts = {
terminal = {
provider = "external", -- "auto", "snacks", "native", or "external"
external_terminal_cmd = "alacritty -e %s" -- Required for external provider
}
}Key File Locations
lua/claudecode/init.lua- Main entry point and setuplua/claudecode/config.lua- Configuration managementplugin/claudecode.lua- Plugin loader with version checkstests/- Comprehensive test suite with unit, component, and integration tests
Autocmd Events
The plugin emits User autocmds (not config fields) that integrations can hook:
ClaudeCodeSendComplete- Fired inM.send_at_mention(init.lua) once per file, synchronously, when a send is accepted on the connected branch (acceptance-time, not delivery; not fired on the queued/disconnected path).data = { file_path, start_line, end_line, context }—file_pathis the formatted path Claude received, lines are 0-indexed and may be nil. Primary use: focus an external Claude session (provider = "none"/"external") wherefocus_after_sendis inert. Emitted via the guarded, pcall-wrappedfire_send_completehelper (no-op whenvim.api.nvim_exec_autocmdsis absent, e.g. minimal test stubs). Seelua/claudecode/types.luaClaudeCodeSendCompleteDataand README "Events".
MCP Protocol Compliance
Protocol Implementation Status
- ✅ WebSocket Server: RFC 6455 compliant with MCP message format
- ✅ Tool Registration: JSON Schema-based tool definitions
- ✅ Authentication: 128-bit token-based secure handshake (32-char lowercase hex from the OS CSPRNG)
- ✅ Message Format: JSON-RPC 2.0 with MCP content structure
- ✅ Error Handling: Comprehensive JSON-RPC error responses
VS Code Extension Compatibility
claudecode.nvim implements 100% feature parity with Anthropic's official VS Code extension:
- Identical Tool Set: All 10 VS Code tools implemented
- Compatible Formats: Output structures match VS Code extension exactly
- Behavioral Consistency: Same parameter handling and response patterns
- Error Compatibility: Matching error codes and messages
Protocol Validation
Run mise run test to verify MCP compliance:
- Tool Format Validation: All tools return proper MCP structure
- Schema Compliance: JSON schemas validated against VS Code specs
- Integration Testing: End-to-end MCP message flow verification
Testing Architecture
Tests are organized in three layers:
- Unit tests (
tests/unit/) - Test individual functions in isolation - Component tests (
tests/component/) - Test subsystems with controlled environment - Integration tests (
tests/integration/) - End-to-end functionality with mock Claude client
Test files follow the pattern *_spec.lua or *_test.lua and use the busted framework.
Test Infrastructure
JSON Handling: Custom JSON encoder/decoder with support for:
- Nested objects and arrays
- Special Lua keywords as object keys (
["end"]) - MCP message format validation
- VS Code extension output compatibility
Test Pattern: Run specific test files during development:
# Run a specific test file (mise sets LUA_PATH automatically)
busted tests/unit/tools/specific_tool_spec.lua --verbose
# Or run the whole suite
mise run test # Recommended for complete validationCoverage Metrics:
- 320+ tests covering all MCP tools and core functionality
- Unit Tests: Individual tool behavior and error cases
- Integration Tests: End-to-end MCP protocol flow
- Format Tests: MCP compliance and VS Code compatibility
Test Organization Principles
- Isolation: Each test should be independent and not rely on external state
- Mocking: Use comprehensive mocking for vim APIs and external dependencies
- Coverage: Aim for both positive and negative test cases, edge cases included
- Performance: Tests should run quickly to encourage frequent execution
- Clarity: Test names should clearly describe what behavior is being verified
Authentication Testing
The plugin implements authentication using 128-bit tokens (32-char lowercase hex) from the OS CSPRNG that are generated for each server session and stored in lock files. This ensures secure connections between Claude CLI and the Neovim WebSocket server.
Testing Authentication Features
Lock File Authentication Tests (tests/lockfile_test.lua):
- Auth token generation and uniqueness validation
- Lock file creation with authentication tokens
- Reading auth tokens from existing lock files
- Error handling for missing or invalid tokens
WebSocket Handshake Authentication Tests (tests/unit/server/handshake_spec.lua):
- Valid authentication token acceptance
- Invalid/missing token rejection
- Edge cases (empty tokens, malformed headers, length limits)
- Case-insensitive header handling
Server Integration Tests (tests/unit/server_spec.lua):
- Server startup with authentication tokens
- Auth token state management during server lifecycle
- Token validation throughout server operations
End-to-End Authentication Tests (tests/integration/mcp_tools_spec.lua):
- Complete authentication flow from server start to tool execution
- Authentication state persistence across operations
- Concurrent operations with authentication enabled
Manual Authentication Testing
Test Script Authentication Support:
# Test scripts automatically detect and use authentication tokens
cd scripts/
./claude_interactive.sh # Automatically reads auth token from lock fileAuthentication Flow Testing:
- Start the plugin:
:ClaudeCodeStart - Check lock file contains
authToken:cat ~/.claude/ide/*.lock | jq .authToken - Test WebSocket connection with auth: Use test scripts in
scripts/directory - Verify authentication in logs: Set
log_level = "debug"in config
Testing Authentication Failures:
# Test invalid auth token (should fail)
websocat ws://localhost:PORT --header "x-claude-code-ide-authorization: invalid-token"
# Test missing auth header (should fail)
websocat ws://localhost:PORT
# Test valid auth token (should succeed)
websocat ws://localhost:PORT --header "x-claude-code-ide-authorization: $(cat ~/.claude/ide/*.lock | jq -r .authToken)"Authentication Logging
Enable detailed authentication logging by setting:
require("claudecode").setup({
log_level = "debug", -- Shows auth token generation, validation, and failures
diff_opts = {
keep_terminal_focus = true, -- If true, moves focus back to terminal after diff opens
},
})Configuration Options
Diff Options
The diff_opts configuration allows you to customize diff behavior:
layout("vertical"|"horizontal", default:"vertical") - Whether the diff panes open in a vertical or horizontal split.keep_terminal_focus(boolean, default:false) - When enabled, keeps focus in the Claude Code terminal when a diff opens instead of moving focus to the diff buffer. This allows you to continue using terminal keybindings like<CR>for accepting/rejecting diffs without accidentally triggering other mappings.open_in_new_tab(boolean, default:false) - Open diffs in a new tab instead of the current tab.hide_terminal_in_new_tab(boolean, default:false) - When opening diffs in a new tab, do not show the Claude terminal split in that new tab. The terminal remains in the original tab, giving maximum screen estate for reviewing the diff.on_new_file_reject("keep_empty"|"close_window", default:"keep_empty") - Behavior when rejecting a diff for a new file (where the old file did not exist).auto_resize_terminal(boolean, default:true) - Whether the plugin resizes the Claude terminal across the diff lifecycle. Set tofalseto keep the plugin's hands off the terminal width and manage it yourself via theClaudeCodeDiffOpened/ClaudeCodeDiffClosedUser autocmds.- Legacy aliases (still supported):
vertical_split(maps tolayout) andopen_in_current_tab(inverse ofopen_in_new_tab).
Related terminal option: terminal.diff_split_width_percentage (number, default: nil) shrinks/widens the terminal split while a diff is open, falling back to terminal.split_width_percentage when unset. It only applies when auto_resize_terminal is true.
The plugin also emits User autocmds ClaudeCodeDiffOpened (data: tab_name, file_path, new_file_path, is_new_file, diff_window, target_window, terminal_window, tab_number) and ClaudeCodeDiffClosed (data: tab_name, file_path, reason). These fire regardless of auto_resize_terminal, letting user configs react to the diff lifecycle. reason is a best-effort human-readable label, not a stable enum; tab_number is set only for new-tab diffs and terminal_window may be nil when no Claude terminal is visible.
Example use case: If you frequently use <CR> or arrow keys in the Claude Code terminal to accept/reject diffs, enable this option to prevent focus from moving to the diff buffer where <CR> might trigger unintended actions.
require("claudecode").setup({
diff_opts = {
layout = "vertical", -- "vertical" or "horizontal"
keep_terminal_focus = true, -- If true, moves focus back to terminal after diff opens
open_in_new_tab = true, -- Open diff in a separate tab
hide_terminal_in_new_tab = true, -- In the new tab, do not show Claude terminal
on_new_file_reject = "keep_empty", -- "keep_empty" or "close_window"
auto_resize_terminal = true, -- false = own terminal width via ClaudeCodeDiffOpened/Closed User autocmds
-- Legacy aliases (still supported):
-- vertical_split = true,
-- open_in_current_tab = true,
},
})Log levels for authentication events:
- DEBUG: Server startup authentication state, client connections, handshake processing, auth token details
- WARN: Authentication failures during handshake
- ERROR: Auth token generation failures, handshake response errors
Logging Best Practices
- Connection Events: Use DEBUG level for routine connection establishment/teardown
- Authentication Flow: Use DEBUG for successful auth, WARN for failures
- User-Facing Events: Use INFO sparingly for events users need to know about
- System Errors: Use ERROR for failures that require user attention
Development Notes
Technical Requirements
- Plugin requires Neovim >= 0.8.0
- Uses only Neovim built-ins for WebSocket implementation (vim.loop, vim.json, vim.schedule)
- Zero external dependencies for core functionality
Security Considerations
- WebSocket server only accepts local connections (127.0.0.1) for security
- Authentication tokens are 128-bit tokens (32-char lowercase hex) from the OS CSPRNG
- Lock files created at
~/.claude/ide/[port].lockfor Claude CLI discovery - All authentication events are logged for security auditing
Performance Optimizations
- Selection tracking is debounced to reduce overhead
- WebSocket frame processing optimized for JSON-RPC payload sizes
- Connection pooling and cleanup to prevent resource leaks
Integration Support
- Terminal integration supports both snacks.nvim and native Neovim terminal
- Compatible with popular file explorers (nvim-tree, oil.nvim, neo-tree, mini.files)
- Visual selection tracking across different selection modes
Release Process
Version Updates
When updating the version number for a new release, you must update ALL of these files:
lua/claudecode/init.lua- Main version table:M.version = { major = 0, minor = 2, -- Update this patch = 0, -- Update this prerelease = nil, -- Remove for stable releases }scripts/claude_interactive.sh- Multiple client version references:- Line ~52:
"version": "0.2.0"(handshake) - Line ~223:
"version": "0.2.0"(initialize) - Line ~309:
"version": "0.2.0"(reconnect)
- Line ~52:
scripts/lib_claude.sh- ClaudeCodeNvim version:- Line ~120:
"version": "0.2.0"(init message)
- Line ~120:
CHANGELOG.md- Add new release section with:- Release date
- Features with PR references
- Bug fixes with PR references
- Development improvements
Release Commands
# Get merged PRs since last version
gh pr list --state merged --base main --json number,title,mergedAt,url --jq 'sort_by(.mergedAt) | reverse'
# Get commit history
git log --oneline v0.1.0..HEAD
# Always run before committing
mise run all
# Verify no old version references remain
rg "0\.1\.0" . # Should only show CHANGELOG.md historical entriesDevelopment Workflow
Pre-commit Requirements
ALWAYS run mise run all before committing any changes. This runs code quality checks and formatting that must pass for CI to succeed. Never skip this step - many PRs fail CI because contributors don't run the build commands before committing.
Recommended Development Flow
- Start Development: Use existing tests and documentation to understand the system
- Make Changes: Follow existing patterns and conventions in the codebase
- Validate Work: Run
mise run allto ensure formatting, linting, and tests pass - Document Changes: Update relevant documentation (this file, PROTOCOL.md, etc.)
- Commit: Only commit after successful
mise run allexecution
Integration Development Guidelines
Adding New Integrations (file explorers, terminals, etc.):
- Implement Integration: Add support in relevant modules (e.g.,
lua/claudecode/tools/) - Create Fixture Configuration: REQUIRED - Add a complete Neovim config in
fixtures/[integration-name]/ - Test Integration: Use fixture to verify functionality with
vv [integration-name] - Update Documentation: Add integration to fixtures list and relevant tool documentation
- Run Full Test Suite: Ensure
mise run allpasses with new integration
Fixture Requirements:
- Complete Neovim configuration with plugin dependencies
- Include
dev-claudecode.luawith development keybindings - Test all relevant claudecode.nvim features with the integration
- Document any integration-specific behaviors or limitations
MCP Tool Development Guidelines
Adding New Tools:
- Study Existing Patterns: Review
lua/claudecode/tools/for consistent structure - Implement Handler: Return MCP format:
{content: [{type: "text", text: JSON}]} - Add JSON Schema: Define parameters and expose via MCP (if needed)
- Create Tests: Both unit tests and integration tests required
- Update Documentation: Add to this file's MCP tools list
Tool Testing Pattern:
-- All tools should return MCP-compliant format
local result = tool_handler(params)
expect(result).to_be_table()
expect(result.content).to_be_table()
expect(result.content[1].type).to_be("text")
local parsed = json_decode(result.content[1].text)
-- Validate parsed structure matches VS Code extensionError Handling Standard:
-- Use consistent JSON-RPC error format
error({
code = -32602, -- Invalid params
message = "Description of the issue",
data = "Additional context"
})Code Quality Standards
- Test Coverage: Maintain comprehensive test coverage (currently 320+ tests, 100% success rate)
- Zero Warnings: All code must pass luacheck with 0 warnings/errors
- MCP Compliance: All tools must return proper MCP format with JSON-stringified content
- VS Code Compatibility: New tools must match VS Code extension behavior exactly
- Consistent Formatting: Use
mise run format(treefmt) for consistent code style - Documentation: Update CLAUDE.md for architectural changes, PROTOCOL.md for protocol changes
Development Quality Gates
mise run check- Syntax and linting (0 warnings required)mise run test- All tests passing (320/320 success rate required)mise run format- Consistent code formatting- MCP Validation - Tools return proper format structure
- Integration Test - End-to-end protocol flow verification
Development Troubleshooting
Common Issues
Test Failures with LUA_PATH:
mise sets LUA_PATH/LUA_CPATH automatically (see mise.toml [env]), so prefer mise run test or run busted through the activated mise environment (mise exec -- busted ...). If a module still can't be found, you're likely running busted outside the mise environment.
JSON Format Issues:
- Ensure all tools return:
{content: [{type: "text", text: "JSON-string"}]} - Use
vim.json.encode()for proper JSON stringification - Test JSON parsing with custom test decoder in
tests/busted_setup.lua
MCP Tool Registration:
- Tools with
schema = nilare internal-only - Tools with schema are exposed via MCP
- Check
lua/claudecode/tools/init.luafor registration patterns
Authentication Testing:
# Verify auth token generation
cat ~/.claude/ide/*.lock | jq .authToken
# Test WebSocket connection
websocat ws://localhost:PORT --header "x-claude-code-ide-authorization: $(cat ~/.claude/ide/*.lock | jq -r .authToken)"Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

