/ninja
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
$ npx -y skills add mohitmishra786/low-level-dev-skills --skill ninja --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/ninja
Context preview
The summary Claude sees to decide when to auto-load this skill.
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
SKILL.md
ninja.SKILL.mdname: ninja
description: 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.
user-invocable: true
triggers:
- ninja build failure
- ninja parallelism tuning
- cmake ninja generator
- interpret ninja output
- build.ninja file format
- ninja verbose output
- ninja as cmake generator
- diagnose ninja errors
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.ninja` file?"
Workflow
1. Ninja as a CMake generator
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
2. Verbose output and diagnostics
# 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
3. Common Ninja flags
| 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`) |
4. Cleaning
ninja -t clean # remove build outputs
ninja -t clean -g # also remove generated files
Or via CMake:
cmake --build build --target clean
5. compile_commands.json
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 .
6. build.ninja format (reference)
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 inputs
- `build`: instantiates a rule with specific files
- `$in` / `$out`: automatic variables for inputs/outputs
- `phony`: a target that is always considered out of date (like `.PHONY` in make)
7. Ninja sub-tools
# 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
8. Common issues
| 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](references/cheatsheet.md).
Related skills
- Use `skills/build-systems/cmake` for CMake configuration that generates Ninja files
- Use `skills/build-systems/make` for Make-based projects
Read more
name: ninja description: 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. user-invocable: true triggers: - ninja build failure - ninja parallelism tuning - cmake ninja generator - interpret ninja output - build.ninja file format - ninja verbose output - ninja as cmake generator - diagnose ninja errors
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.ninja` file?"
Workflow
1. Ninja as a CMake generator
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
2. Verbose output and diagnostics
# 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
3. Common Ninja flags
| 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`) |
4. Cleaning
ninja -t clean # remove build outputs ninja -t clean -g # also remove generated files
Or via CMake:
cmake --build build --target clean
5. compile_commands.json
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 .
6. build.ninja format (reference)
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 inputs
- `build`: instantiates a rule with specific files
- `$in` / `$out`: automatic variables for inputs/outputs
- `phony`: a target that is always considered out of date (like `.PHONY` in make)
7. Ninja sub-tools
# 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
8. Common issues
| 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](references/cheatsheet.md).
Related skills
- Use `skills/build-systems/cmake` for CMake configuration that generates Ninja files
- Use `skills/build-systems/make` for Make-based projects
A curated suite of AI agent skills for systems and low-level programming — C/C++, Rust, Zig, GPU, bare-metal firmware, Linux kernel/driver development, computer architecture, compiler internals, HPC, and more.
Repo: mohitmishra786/low-level-dev-skills
Other skills on low-level-dev-skills.
- /custom-allocators
Custom allocator skill for memory allocation strategies. Use when implementing pool/slab/arena allocators, tuning jemalloc/mimalloc, writing Rust GlobalAlloc, or benchmarking allocator performance. Activates on queries about jemalloc, mimalloc, tcmalloc, arena allocator,
Open skill - /numa-programming
NUMA programming skill for multi-socket memory locality. Use when detecting NUMA topology, binding processes with numactl, using libnuma API, building NUMA-aware data structures, or measuring remote access penalties. Activates on queries about numactl, libnuma, NUMA topology,
Open skill - /af-xdp
AF_XDP skill for high-performance XDP sockets. Use when creating AF_XDP sockets, configuring UMEM and XSK rings, XDP_REDIRECT programs, copy vs zero-copy mode, or comparing with DPDK. Activates on queries about AF_XDP, xsk_umem, XDP_REDIRECT, libbpf xsk, or zero-copy XDP.
Open skill - /dpdk
DPDK skill for userspace packet I/O. Use when initializing EAL, configuring PMD drivers, using mbuf pools and rte_ring, setting up huge pages, RSS, or testpmd validation. Activates on queries about DPDK, EAL, rte_eth_rx_burst, hugepages, PMD, or testpmd.
Open skill - /io-uring
io_uring skill for Linux async I/O. Use when building high-performance servers with liburing, multi-shot operations, provided buffers, fixed files, zero-copy send, or tokio-uring. Activates on queries about io_uring, SQE/CQE, liburing, IORING_OP_PROVIDE_BUFFERS, or io_uring vs
Open skill - /adc-dac-baremetal
Bare-metal ADC and DAC skill. Use when configuring analog sampling, DMA-driven ADC, calibration, or DAC output on MCUs. Activates on queries about ADC bare-metal, sampling time, DMA ADC, or DAC channel setup.
Open skill

