Professional framework for pure ANSI C99 projects β as a Pi skill.
Memory arena Β· Containerized builds Β· Valgrind mandatory Β· -fanalyzer Β· Zero warnings Β· No recursion
- Overview
- Features
- Install
- Quick Start
- Actions
- Build Targets
- Project Layout
- Compiler Flags
- Framework Rules
- Memory Arena API
- Requirements
- Documentation
- Contributing
- License
std-c99-proj-skill is an installable Pi package that provides a complete, opinionated framework for pure ANSI C99 development. It follows the Agent Skills standard and can be invoked manually via /skill:std-c99-proj or detected automatically by the agent.
The skill scaffolds projects with a hardened memory arena allocator, strict compiler flags, containerized builds via Podman, mandatory Valgrind analysis, and clang-tidy static analysis β enforcing professional-grade quality from the first commit. An AGENTS.md is generated in every project so any AI coding agent automatically follows the framework rules.
| Feature | Description |
|---|---|
| π§ Memory Arena | Aligned, hardened allocator β overflow protection, double-init guard, zero leaks |
| π¦ Containerized Builds | All compilation inside Podman containers β per-target output in build/<target>/ |
| π Strict Compilation | -std=c99 -pedantic -Werror -Wall -Wextra -Wconversion -Wshadow |
π¬ -fanalyzer |
GCC compile-time static analysis (GCC β₯ 10) β catches use-after-free, null deref |
| π‘οΈ Hardened Release | -O2 -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fPIE |
| π No Recursion | Iteration only β predictable stack usage, no overflow risk |
| π Valgrind Mandatory | Every test run checks for leaks and memory errors |
| π§Ή Static Analysis | clang-tidy with --warnings-as-errors |
| π Doxygen Docs | API documentation generated inside containers |
| π§ͺ 27 Tests Included | Arena tests with alignment, overflow, and edge case coverage |
| π€ AGENTS.md | Generated in every project β AI agents auto-follow framework rules |
pi install npm:std-c99-p
BBE3
roj-skill # from npm (recommended)
pi install git:github.com/ibitato/std-c99-proj-skill # from git> /skill:std-c99-proj
> Initialize a new C99 project and build it for RHEL 9
The agent will:
- Run
init_project.shto scaffold the project (includingAGENTS.md) - Run
build.sh rhel9 Debugto compile inside a Rocky Linux 9 container - Run
test.sh rhel9to execute 27 tests under Valgrind
Output goes to build/rhel9/ β multiple targets coexist without overwriting.
| Action | Script | Description |
|---|---|---|
| init | init_project.sh |
Scaffold project with git, templates, tests, Containerfiles, and AGENTS.md |
| build | build.sh <target> [Debug|Release] |
Compile inside container β build/<target>/ |
| test | test.sh <target> |
Tests + Valgrind β build/<target>/ (leaks = hard failure) |
| static-analysis | static_analysis.sh <target> |
clang-tidy with --warnings-as-errors |
| docs | docs.sh <target> |
Doxygen documentation β docs/<target>/ |
All builds run inside Podman containers. Two parametrized Containerfiles cover all targets:
| Target | Family | Base Image | GCC | -fanalyzer |
|---|---|---|---|---|
rhel8 |
RHEL | rockylinux:8 |
8.x | β |
rhel9 |
RHEL | rockylinux:9 |
11.x | β |
rhel10 |
RHEL | quay.io/rockylinux/rockylinux:10 |
14.x | β |
debian11 |
Debian | debian:bullseye |
10.x | β |
debian12 |
Debian | debian:bookworm |
12.x | β |
ubuntu2204 |
Ubuntu | ubuntu:22.04 |
11.x | β |
ubuntu2404 |
Ubuntu | ubuntu:24.04 |
13.x | β |
Each container includes: gcc, clang, clang-tidy, cmake, make, git, valgrind, doxygen.
After running init, the generated project has this structure:
my-project/
βββ AGENTS.md # AI agent rules (auto-loaded by Pi, Claude Code, etc.)
βββ CMakeLists.txt # C99 strict, Debug/Release flags, BUILD_TESTS option
βββ Doxyfile # Doxygen configuration
βββ .gitignore
βββ containers/
β βββ Containerfile.rhel
β βββ Containerfile.debian
βββ src/
β βββ main.c # Entry point using memory arena
β βββ mem_arena.c # Hardened arena allocator
β βββ utils.c # Utility functions
βββ include/
β βββ mem_arena.h # Arena API (aligned, overflow-safe)
β βββ utils.h # Utility headers
βββ tests/
β βββ test_arena.c # 27 assertions, Valgrind-clean
βββ build/ # Per-target output (gitignored)
β βββ rhel9/
β βββ debian12/
βββ docs/ # Per-target docs (gitignored)
βββ rhel9/
| Debug | Release | |
|---|---|---|
| Optimization | -O0 |
-O2 |
| Debug info | -g3 (full + macros) |
β |
| Warnings | -Wall -Wextra -Werror -Wconversion -Wshadow -Wfloat-conversion -pedantic |
same |
| Static analysis | -fanalyzer (GCC β₯ 10) |
β |
| Stack protection | -fstack-protector-strong |
-fstack-protector-strong |
| Buffer overflow | β | -D_FORTIFY_SOURCE=2 |
| PIE | β | -fPIE |
Every project created with this skill enforces these rules as build errors:
- Pure C99 β
-std=c99 -pedanticwith all warnings as errors - No recursion β iteration only, predictable stack usage
- Arena-only memory β no direct
malloc/freein application code - Valgrind clean β
--leak-check=full --error-exitcode=1on every test - Git required β version control from the first commit
- Containerized β all builds inside Podman, never on host
See references/RULES.md for rationale and coding conventions.
int mem_arena_init(MemArena *arena, size_t size); /* 0 on success, -1 on failure */
void *mem_arena_alloc(MemArena *arena, size_t size); /* aligned, NULL on failure */
void mem_arena_reset(MemArena *arena); /* reuse without freeing */
void mem_arena_free(MemArena *arena); /* single free, idempotent */Hardened: aligned allocations, integer overflow protection, double-init guard.
See references/ARENA_API.md for full documentation.
π User Manual β complete guide from installation to advanced usage (beginner / intermediate / advanced).
Contributions are welcome. Please read CONTRIBUTING.md before submitting a pull request.
This project is licensed under the MIT License β see the LICENSE file for details.