Ninja
Purpose
Guide agents through Ninja as a build executor: diagnosing failures, controlling parallelism, generating from CMake, and understanding the .ninja file format when needed.
Triggers
- "Ninja is failing — how do I get more output?"
- "How do I use Ninja with CMake?"
- "How many parallel jobs does Ninja use?"
- "How do I add a custom build step in Ninja?"
- "What is a
build.ninjafile?"
Workflow
1. Ninja as a CMake generator
The most common use of Ninja is as the build executor for CMake:
CMake also supports Ninja Multi-Config:
2. Verbose output and diagnostics
3. Common Ninja flags
4. Cleaning
Or via CMake:
5. compile_commands.json
Ninja (via CMake) can generate a compile_commands.json for IDE integration and clang-tidy:
6. build.ninja format (reference)
Rarely hand-written, but useful to understand for debugging:
Key concepts:
rule: defines how to produce outputs from inputsbuild: instantiates a rule with specific files$in/$out: automatic variables for inputs/outputsphony: a target that is always considered out of date (like.PHONYin make)
7. Ninja sub-tools
8. Common issues
For the full Ninja command reference, build.ninja format details, and CMake integration patterns, see references/cheatsheet.md [blocked].
Related skills
- Use
skills/build-systems/cmakefor CMake configuration that generates Ninja files - Use
skills/build-systems/makefor Make-based projects


