cpp-build-systems
Skill13 starsChanged 4 months agoMITView on GitHub
Use in C/C++ projects for build configure/errors, compile_commands.json generation, or selecting CMake/Meson/Make/Bazel commands.
In this repository14 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- anti-hallucination-gatesSkill
- capturing-golden-rulesSkill
- context-budget-disciplineSkill
- cpp-formattingSkill
- cpp-sanitizersSkill
- cpp-static-analysisSkill
- docs-lookupSkill
- feature-state-keeperSkill
- init-verificationSkill
- project-indexingSkill
- self-correction-loopSkill
- test-coverage-designSkill
- using-harness-anchorSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 82
Keep separate build dirs:
- Distinctive: line 93
Don't pick one for them. Ask:
- Very specific: line 102
Run bash ${CLAUDE_PLUGIN_ROOT}/scripts/cpp-detect.sh --target .
- Distinctive: line 118
If you propose a build fix you haven't verified by running the build:
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill 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
C/C++ Build Systems
The build system is the single most important piece of C/C++ tooling — it determines how every other tool (clang-tidy, IWYU, language servers, debuggers) understands your code.
The compile_commands.json invariant
Every C/C++ project must export
compile_commands.json.
It's a JSON database of compiler invocations per file. Without it, clang-tidy/IWYU/clangd can't parse your code correctly (they need to know macros, includes, standard, flags). The cpp-static-analysis skill enforces this prerequisite.
Per-build-system commands
CMake
cmake -S . -B .build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
cmake --build .build -j-DCMAKE_EXPORT_COMPILE_COMMANDS=ONis mandatory unless already inCMakeLists.txtviaset(CMAKE_EXPORT_COMPILE_COMMANDS ON)- Out-of-source build (
.build/) keeps the source tree clean - Symlink from project root so tools find it:
ln -sf .build/compile_commands.json .
Meson
meson setup builddir
meson compile -C builddir- Meson emits
compile_commands.jsonin builddir automatically. Symlink it to root if tooling expects it there.
Make (raw)
Pure Makefile projects don't generate compile_commands.json natively. Use bear:
bear -- make -jOr compiledb:
compiledb make -jBazel
bazel build //...
bazel run @hedron_compile_commands//:refresh_allBazel requires the hedron_compile_commands rule. If not configured, suggest the user add it; do NOT try to hand-edit BUILD files.
Build failure triage (you fix common ones, escalate the rest)
- CMake "could not find package X" → likely missing
find_package(X REQUIRED)cleanup or wrong CMAKE_PREFIX_PATH. Suggest:cmake -L .buildto inspect, or pass-DX_DIR=.... - Linker "undefined reference" → missing source in target or missing link library. Check
target_link_libraries(...)lists everything. - "No such file: <header.h>" → missing
target_include_directoriesor system header missing. For system headers, suggest installing the dev package. - Configure step fails on macOS → often missing Command Line Tools:
xcode-select --install. - Anything cryptic → escalate: dispatch the
cpp-build-doctorsubagent with the full error log. - Anything you have now failed to fix twice → escalate, even if it looked obvious. The first diagnosis is yours; a second failed attempt at the same failure means your hypothesis is the problem, and fresh context beats another iteration on a wrong prior. (Fixing it on the first try and moving on is the expected path — this is a repeat-failure trigger, not a "always delegate build errors" rule. The Session Pulse hook independently nudges at ≥3 repeats; this fires earlier and is yours to honour.)
Multi-config builds (Debug + Release + Sanitizer)
Keep separate build dirs:
.build/debug
.build/release
.build/asanThis is critical for cpp-sanitizers skill — the sanitizer build is a separate config, not a flag toggle on the same build.
When the user has NO build system yet
Don't pick one for them. Ask:
- Single-file experiment → suggest plain CMake (most portable)
- Header-only library → suggest CMake INTERFACE target
- Existing autotools project → keep it; just add
bearfor compile_commands.json - Bazel monorepo → it's a one-way door, only suggest if user already uses it elsewhere
Detection helper
Run bash ${CLAUDE_PLUGIN_ROOT}/scripts/cpp-detect.sh --target . to get a JSON summary of what's present. Used by the SessionStart hook to gate C/C++ skills.
References
- See
cmake-reference.mdfor CMake idioms used in this codebase / project conventions. - See
meson-reference.mdfor Meson equivalents. - See
compile-commands-guide.mdfor the deep-dive on compile_commands.json semantics.
When NOT to invoke this skill
- Pure C/C++ language questions (use docs / Context7 instead)
- Build performance tuning — separate concern; use after the build works
- Cross-compilation — out of scope for harness-anchor; consult build system docs
Calibrated uncertainty
If you propose a build fix you haven't verified by running the build:
"I believe the fix is
<change>. Please runcmake -S . -B .build && cmake --build .buildand share the output before we mark this resolved."
Looking up tool errors
Unfamiliar CMake/Meson/Bazel error or missing-package message? Don't guess — invoke the docs-lookup skill, which encodes the canonical Context7 → WebSearch → calibrated-uncertainty fallback chain (with explicit "Context7 is unavailable" detection so you don't silently degrade to guessing).
Typical entry queries: cmake find_package, meson dependency, bazel cc_binary, exact error string in quotes.
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.

