Skip to content

The one and only agent harness for complex codebases. Project memory, planning, execution, and verified completion inside Codex.

2.5 KB
Raw Blame

C / C++ — LSP setup

  • Builtin server: clangd — clangd --background-index --clang-tidy
  • Extensions: .c .cpp .cc .cxx .c++ .h .hpp .hh .hxx .h++
  • Install hint: https://clangd.llvm.org/installation

Install

  • macOS: brew install llvm (clangd ships in the LLVM keg; add its bin to PATH)
  • Linux: apt install clangd (Debian/Ubuntu); use your distro package elsewhere
  • Windows: install LLVM from https://releases.llvm.org or winget install LLVM.LLVM

See https://clangd.llvm.org/installation for other platforms.

Confirm it resolves:

command -v clangd

Configure

Builtin — usually NO config needed (auto-resolved by extension). Configure only to set priority, init options, override extensions, or disable. Same JSON shape in every harness's project config (per-harness paths: the Configure step in SKILL.md):

{ "lsp": { "clangd": { "priority": 100 } } }

For builtin ids in a PROJECT config, command is supplied automatically — only set priority/initialization/extensions/disabled (a project entry drops env). env, and a fully custom (non-builtin) server with its own command, must go in your harness's USER config (see the Configure step in SKILL.md).

Initialization options (only if commonly needed)

None commonly required. clangd reads flags from a project .clangd file rather than initializationOptions. The builtin command already passes --background-index --clang-tidy.

Compile commands

clangd needs a compile_commands.json at the project root (or in build/) for accurate diagnostics and cross-file navigation. Generate it with:

  • CMake: cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON (symlink/copy build/compile_commands.json to the root)
  • Make / other: bear -- make

Without it, clangd falls back to heuristic flags and reports spurious errors.

Alternatives

None builtin. ccls exists as a third-party server but is not builtin — it would need a custom command in the USER config.

Troubleshooting

  • PATH: clangd must be on PATH; reopen shell after install. Homebrew LLVM is keg-only — add $(brew --prefix llvm)/bin to PATH.
  • Spurious "file not found" / unknown flags: missing or stale compile_commands.json — regenerate it after changing the build.
  • Header-only diagnostics wrong: ensure the header's translation unit appears in the compile database, or add a .clangd CompileFlags block.

Verify

bun ../../scripts/verify-lsp.ts path/to/file.cpp