loom-c
Installation
SKILL.md
C Language Expertise
Overview
Idiomatic, defensive C17 (C23 where the toolchain supports it): who owns each allocation, how failure is reported, which operations are undefined behaviour (UB), how buffers are bounded, and how the build, sanitizers and tests catch what the compiler cannot. Assumes the reader knows the language. The content is decision rules and the traps that survive review: malloc(n * size) overflow, realloc assigned back to its only pointer, strncpy leaving no terminator, signed overflow in a bounds check, a char passed to isalpha, a return value ignored.
Tooling
| Task | Command |
|---|---|
| Configure (CMake) | cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug |
| Build | cmake --build build |
| Test, whole suite (the stage gate's) | ctest --test-dir build --output-on-failure |
| One test | ctest --test-dir build -R '^spool_rejects_symlink$' --output-on-failure |
| Static analysis | clang-tidy -p build src/*.c, cppcheck --enable=warning,style,performance --error-exitcode=1 src/ |
| Format | clang-format -i src/*.c include/*.h |
| Memory check | valgrind --leak-check=full --error-exitcode=1 ./build/tests/spool_test |
Keep the build system the repository already has. A new project uses CMake (3.20+) with presets, which also feeds clang-tidy through compile_commands.json.