
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 about ninja errors, ninja parallelism, ninja verbose output, build.ninja format, or ninja as a CMake generator.
- Installs
- 629
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/mohitmishra786/low-level-dev-skills --skill ninja- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads ninja automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
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:
# 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 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
# 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.
Related skills
- Use
skills/build-systems/cmakefor CMake configuration that generates Ninja files - Use
skills/build-systems/makefor Make-based projects
FAQ
What does the ninja skill do?
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.
How do I install ninja?
Run npx skills add https://github.com/mohitmishra786/low-level-dev-skills --skill ninja in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/ninja/ (personal) or .claude/skills/ninja/ (project).
Which AI agents can use ninja?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is ninja safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains ninja?
It is published by mohitmishra786 in mohitmishra786/low-level-dev-skills. It has 629 recorded installs.
More from mohitmishra786/low-level-dev-skills
cmake
mohitmishra786/low-level-dev-skills
CMake build system skill for C/C++ projects. Use when writing or refactoring CMakeLists.txt, configuring out-of-source builds, selecting generators (Ninja, Make, VS), managing targets and dependencies with targetlinklibraries, integrating external packages via findpackage or FetchContent, enabling sanitizers, setting up toolchain files for cross-compilation, or exporting CMake packages. Activates on queries about CMakeLists.txt, cmake configure errors, target properties, install rules, CPack, or CMake presets.
static-analysis
mohitmishra786/low-level-dev-skills
Static analysis skill for C/C++ codebases. Use when hardening code quality, triaging noisy builds, running clang-tidy, cppcheck, or scan-build, interpreting check categories, suppressing false positives, or integrating static analysis into CI. Activates on queries about clang-tidy checks, cppcheck, scan-build, compilecommands.json, code hardening, or static analysis warnings.
gdb
mohitmishra786/low-level-dev-skills
GDB debugger skill for C/C++ programs. Use when starting a GDB session, setting breakpoints, stepping through code, inspecting variables, debugging crashes, using reverse debugging (record/replay), remote debugging with gdbserver, or loading core dumps. Activates on queries about GDB commands, segfaults, hangs, watchpoints, conditional breakpoints, pretty-printers, Python GDB scripting, or multi-threaded debugging.
llvm
mohitmishra786/low-level-dev-skills
LLVM IR and pass pipeline skill. Use when working directly with LLVM Intermediate Representation (IR), running opt passes, generating IR with llc, inspecting or writing LLVM IR for custom passes, or understanding how the LLVM backend lowers IR to assembly. Activates on queries about LLVM IR, opt, llc, llvm-dis, LLVM passes, IR transformations, or building LLVM-based tools.
sanitizers
mohitmishra786/low-level-dev-skills
Compiler sanitizer skill for runtime bug detection in C/C++. Use when enabling and interpreting AddressSanitizer (ASan), UndefinedBehaviorSanitizer (UBSan), ThreadSanitizer (TSan), MemorySanitizer (MSan), or LeakSanitizer (LSan) with GCC or Clang. Activates on queries about sanitizer flags, sanitizer reports, ASANOPTIONS, memory errors, data races, undefined behaviour, uninitialised reads, or choosing which sanitizer to use for a given bug class.
core-dumps
mohitmishra786/low-level-dev-skills
Core dump analysis skill for production crash triage. Use when loading core files in GDB or LLDB, enabling core dump generation on Linux/macOS, mapping symbols with debuginfo or debuginfod, or extracting backtraces from crashes without re-running the program. Activates on queries about core files, ulimit, coredumpctl, debuginfod, crash triage, or analyzing segfaults from production binaries.
Popular other skills
hyperframes-cli
heygen-com/hyperframes
The HyperFrames CLI by job - scaffold, check, look at frames, edit the timeline, preview, render locally or in the cloud, publish, project history - plus reading its JSON and recovering from build or render failures.
triage
mattpocock/skills
Move issues and external PRs through a state machine of triage roles, categorise, verify, grill if needed, and write agent-ready briefs.
ask-matt
mattpocock/skills
Ask which skill or flow fits your situation. A router over the skills in this repo.
to-questionnaire
mattpocock/skills
Turn a decision you can't fully answer into a questionnaire for someone else to fill in.
loop-me
mattpocock/skills
Grill me about specs for the workflows I want to build, within this workspace.