Clangd Setup Skill
Use this skill when clangd-mcp is missing or needs configuration for the
current workspace.
Core Principles
- Proactive Execution: Do all necessary work to set up
clangdonce user approval is obtained. - Workspace Specific: Configuration (
compile_commands.json) must be generated for the specific V8 checkout.
Setup Workflow
Follow these steps to ensure clangd is ready:
1. Check and Install clangd-mcp
- Check if the
clangd-mcpserver is available in the list of registered servers. - If not available:
- Ask the user: "Would you like me to install and configure
clangd-mcpfor this workspace?" - If approved, proceed to installation steps if known, or ask the user for guidance on how to enable it in their specific environment.
- Ask the user: "Would you like me to install and configure
2. Generate compile_commands.json
clangd requires a compilation database to understand the codebase.
- Identify Build Directory: Check for common build directories like
out/x64.debug,out/x64.release. - Check for Existing File: Check if
compile_commands.jsonalready exists in the identified build directory or at the project root. - Generate if Missing: If it doesn't exist, you MUST attempt to generate
it.
- Method: Run
gn gen <build_dir> --export-compile-commands.- Example:
gn gen out/x64.debug --export-compile-commands
- Example:
- Ask the user before running the command to ensure it targets the correct build directory they are working with.
- Method: Run
3. Verify Configuration
- Once
compile_commands.jsonis generated, verify thatclangd-mcptools (likefind_symbol,get_definition) return meaningful results for a known symbol in the codebase.
Troubleshooting
- If
clangdcannot find headers, ensurecompile_commands.jsonis at the root or linked correctly, and that the build has been run at least once to generate all necessary headers (like Torque generated files).