8000
Skip to content

Latest commit

Β 

History

23 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ—οΈ std-c99-proj-skill

Professional framework for pure ANSI C99 projects β€” as a Pi skill.

License: MIT npm Agent Skills C Standard Podman

Memory arena Β· Containerized builds Β· Valgrind mandatory Β· -fanalyzer Β· Zero warnings Β· No recursion


Table of Contents

Overview

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.

Features

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

Install

pi install npm:std-c99-p
BBE3
roj-skill        # from npm (recommended)
pi install git:github.com/ibitato/std-c99-proj-skill   # from git

Quick Start

> /skill:std-c99-proj
> Initialize a new C99 project and build it for RHEL 9

The agent will:

  1. Run init_project.sh to scaffold the project (including AGENTS.md)
  2. Run build.sh rhel9 Debug to compile inside a Rocky Linux 9 container
  3. Run test.sh rhel9 to execute 27 tests under Valgrind

Output goes to build/rhel9/ β€” multiple targets coexist without overwriting.

Actions

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>/

Build Targets

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.

Project Layout

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/

Compiler Flags

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

Framework Rules

Every project created with this skill enforces these rules as build errors:

  1. Pure C99 β€” -std=c99 -pedantic with all warnings as errors
  2. No recursion β€” iteration only, predictable stack usage
  3. Arena-only memory β€” no direct malloc/free in application code
  4. Valgrind clean β€” --leak-check=full --error-exitcode=1 on every test
  5. Git required β€” version control from the first commit
  6. Containerized β€” all builds inside Podman, never on host

See references/RULES.md for rationale and coding conventions.

Memory Arena API

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.

Requirements

  • Podman β€” container runtime (rootless supported)
  • Git β€” version control
  • Pi β€” AI coding agent

Documentation

πŸ“– User Manual β€” complete guide from installation to advanced usage (beginner / intermediate / advanced).

Contributing

Contributions are welcome. Please read CONTRIBUTING.md before submitting a pull request.

License

This project is licensed under the MIT License β€” see the LICENSE file for details.

About

Pi skill for pure ANSI C99 projects with memory arena, containerized builds, Valgrind, and static analysis.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0