Your first ten minutes with CLAP
A zero-to-tested-project walkthrough. Every command below is copy-pasteable and was run exactly as written before this page was published. No compiler installation, no admin rights, no PATH editing — if you have Python (or even less on Windows), you are ready.
1. Install
pip install clap-compilerOr the one-liner that needs no Python at all on Windows:
irm https://bratan-corp.github.io/clap/install.ps1 | iex # Windows PowerShell
curl -fsSL https://bratan-corp.github.io/clap/install.sh | sh # Linux/macOS2. Your first program (one minute)
clap init hello
cd hello
clap runThe first run downloads the pinned, hash-verified compiler into your user cache — about a minute, with honest progress messages instead of silence. Everything after that is instant:
Hello from CLAPLook at what was created: main.c (or .cpp), a small clap.toml, and a .gitignore that already excludes build artifacts and vendored dependencies.
3. Break it — and read your first error (two minutes)
Open main.c and delete a semicolon. Run clap build:
[1/2] compiling main.c
main.c:4:5: error: expected ';' after expressionThe compiler's own diagnostic — with the caret pointing at the line — owns the screen. No wall of build-system noise around it. Fix the semicolon, rebuild, it passes. (clap build --verbose shows the exact compiler commands when you actually want them.)
4. Watch mode: the edit-run loop disappears (one minute)
clap run --watchNow edit the greeting in main.c and save. CLAP rebuilds incrementally and restarts the program — you never type the build command again. Ctrl-C stops it.
5. Your first real test (three minutes)
C++ projects get the doctest framework in one word:
clap init calc --template cpp
cd calc
clap add doctest --devThe --dev matters: doctest is a test framework, so it belongs in [dev-dependencies] — visible to test builds, invisible to production ones. Without it the pin lands in production dependencies and compiles into the binary you ship. clap add downloads the header, verifies it against the pinned hash, writes the pin into clap.toml and vendors it — #include <doctest.h> now compiles in tests with zero flags. Write test_calc.cpp:
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include <doctest.h>
int add(int a, int b) { return a + b; }
TEST_CASE("addition works") {
CHECK(add(2, 2) == 4);
CHECK(add(-1, 1) == 0);
}clap test test_calc.cpp[doctest] assertions: 2 | 2 passed | 0 failed |
[doctest] Status: SUCCESS!For plain-C classroom-style tests (each file a standalone program), there is a ready-made layout:
clap init lab --template test
cd lab
clap test # tests/ is discovered automatically — no arguments neededPASS test_arithmetic in 0.001s
PASS test_boolean in 0.001s
2 tests: 2 passed, 0 failed5b. Keeping pins fresh (ten seconds)
Curated pins move as the registry verifies newer upstream releases. See what aged, and refresh in one step:
clap update # report only — nothing changes
clap update --apply # re-pin the stale onesEvery pin is re-verified byte-for-byte on the next clap sync, so an update can never silently change what you build against.
5c. Adopting existing code (two minutes)
Already have sources? Don't scaffold over them — adopt them:
cd your-project
clap init --adopt .Adoption writes only clap.toml around what's there. It recurses the tree (skipping tests/examples/bench — not part of the artifact), resolves every quoted #include against the tree's headers and derives the include directories itself — the lib/programs shape that real C projects use just works. Several main() carriers in one tree (the lua/luac case)? The likely primary entry point is kept, the rest excluded with instructions to swap.
Then it's the same loop: clap build, clap run, clap test. See REAL_WORLD_BUILDS.md for verbatim proof on SQLite, lua and lz4 — none of them needed a single edit.
6. Where to go next
- COMMANDS.md — the full reference: cross-compilation to Windows/macOS/Linux-aarch64 in one
--targetflag, fully static musl binaries, sanitizers, coverage, CMake projects, pkg-config dependencies - Ship it when it is ready —
clap distpacks release archives for Linux (static musl, x86+ARM) and Windows with checksums in one command;clap installputs the binary into~/.local/bin;clap init --ciprojects already release themselves on tag pushes - LIBRARY_RECIPES.md — verified copy-paste recipes for popular libraries
- TROUBLESHOOTING.md — when something does go wrong
Stuck in the editor? The VS Code extension runs everything above from the sidebar and the Test Explorer.