skills/build-systems/ninja/SKILL.md
Ninja build system skill. Use when diagnosing Ninja build failures, understanding Ninja's role as a low-level build executor generated by CMake or other meta-build systems, tuning parallelism, interpreting Ninja output, or working with build.ninja files. Activates on queries about ninja errors, ninja parallelism, ninja verbose output, build.ninja format, or ninja as a CMake generator.
npx skillsauth add mohitmishra786/low-level-dev-skills ninjaInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Guide agents through Ninja as a build executor: diagnosing failures, controlling parallelism, generating from CMake, and understanding the .ninja file format when needed.
build.ninja file?"The most common use of Ninja is as the build executor for CMake:
# Configure with Ninja
cmake -S . -B build -G Ninja
cmake --build build # uses ninja internally
# Or invoke ninja directly
cd build && ninja
# Specify parallelism
ninja -j4
ninja -j$(nproc)
# Build specific target
ninja myapp
ninja install
CMake also supports Ninja Multi-Config:
cmake -S . -B build -G "Ninja Multi-Config"
cmake --build build --config Release
cmake --build build --config Debug
# Show full commands (not just [CC] foo.c)
ninja -v
# Dry run (show what would be built)
ninja -n
# Show why a target needs rebuilding
ninja -d explain myapp
# Print all targets
ninja -t targets all
# Print targets grouped by rule
ninja -t targets rule cc
# Dependency graph (graphviz)
ninja -t graph myapp | dot -Tsvg -o deps.svg
| Flag | Effect |
|------|--------|
| -j N | Parallel jobs (default: CPUs + 2) |
| -l N | Don't start new jobs if load average > N |
| -k N | Keep going after N failures (default 1) |
| -v | Verbose: show full command lines |
| -n | Dry run |
| -C dir | Change to dir before doing anything |
| -t tool | Run a sub-tool (clean, query, targets, graph, compdb) |
ninja -t clean # remove build outputs
ninja -t clean -g # also remove generated files
Or via CMake:
cmake --build build --target clean
Ninja (via CMake) can generate a compile_commands.json for IDE integration and clang-tidy:
cmake -S . -B build -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
ln -sf build/compile_commands.json .
Rarely hand-written, but useful to understand for debugging:
# Variable
cflags = -Wall -O2
# Rule
rule cc
command = gcc $cflags -c $in -o $out
description = CC $in
# Build edge
build foo.o: cc foo.c
# Phony target
build all: phony foo.o
# Default target
default all
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 .PHONY in make)# List all build targets
ninja -t targets
# Query dependencies of a target
ninja -t query myapp
# Clean (already mentioned)
ninja -t clean
# Generate compile_commands.json (if supported by generator)
ninja -t compdb cc cxx > compile_commands.json
# List rules
ninja -t rules
| Issue | Cause | Fix |
|-------|-------|-----|
| ninja: error: 'foo.o', needed by 'prog', missing and no known rule to make it | Missing build rule | Regenerate with CMake; check add_executable source list |
| Build not picking up changes | Stale build.ninja | Re-run cmake -S . -B build |
| Very slow parallel build | -j too high for I/O-bound build | Use -l$(nproc) to limit by load |
| Circular dependency | Rule depends on itself | Check CMake target dependencies |
For the full Ninja command reference, build.ninja format details, and CMake integration patterns, see references/cheatsheet.md.
skills/build-systems/cmake for CMake configuration that generates Ninja filesskills/build-systems/make for Make-based projectsdevelopment
QEMU/KVM skill for virtualization and kernel development. Use when running qemu-system-x86_64 with KVM, configuring virtio devices, VFIO passthrough, QMP monitor, libvirt, or booting custom kernels. Activates on queries about QEMU, KVM, virtio, VFIO, virsh, virt-install, or -kernel -append.
development
Hardware virtualization internals skill for Intel VT-x and AMD-V. Use when studying VMCS/VMCB, EPT/NPT page tables, VMEXIT handling, APIC virtualization, or building minimal hypervisors. Activates on queries about VMX, SVM, VMCS, EPT, NPT, VMEXIT, or type-1 hypervisor.
testing
Linux containers internals skill for namespaces, cgroups, and OCI. Use when understanding clone/unshare namespaces, cgroups v2 limits, overlayfs, runc, seccomp profiles, capabilities, or escape mitigations. Activates on queries about namespaces, cgroups, overlayfs, runc, seccomp-bpf, OCI spec, or container escape.
tools
Reverse engineering skill for binary analysis. Use when decompiling with Ghidra, analyzing with radare2, scripting RE tools, triaging with strings/file/xxd, or diffing binaries. Activates on queries about Ghidra, radare2, r2, decompiler, Binary Ninja, Diaphora, or stripped binary analysis.