From 79d3b92511eab4f9afa4674f3b906bdd8b1f4413 Mon Sep 17 00:00:00 2001 From: portersky <24420859+portersky@users.noreply.github.com> Date: Mon, 15 Jun 2026 04:27:39 +0200 Subject: [PATCH] chore: add pi skills for tdd, cmake, and git Create .pi/skills/ with three skills: - tdd: Red-Green-Refactor workflow, Unity assertions, CMock patterns - cmake: build commands, adding modules, dependency FetchContent pattern - git: conventional commits, semver tagging, branching conventions Update AGENTS.md and README.md to reference the skills and template project description. --- .pi/README.md | 43 ++++++++ .pi/skills/cmake/SKILL.md | 145 +++++++++++++++++++++++++ .pi/skills/git/SKILL.md | 167 ++++++++++++++++++++++++++++ .pi/skills/tdd/SKILL.md | 223 ++++++++++++++++++++++++++++++++++++++ AGENTS.md | 117 +++++++------------- README.md | 5 +- 6 files changed, 623 insertions(+), 77 deletions(-) create mode 100644 .pi/README.md create mode 100644 .pi/skills/cmake/SKILL.md create mode 100644 .pi/skills/git/SKILL.md create mode 100644 .pi/skills/tdd/SKILL.md diff --git a/.pi/README.md b/.pi/README.md new file mode 100644 index 0000000..4f42b6b --- /dev/null +++ b/.pi/README.md @@ -0,0 +1,43 @@ +# Pi Skills + +Project-level skills loaded by Pi on-demand. + +## Skills + +| Skill | Description | +| ------------------------------ | ---------------------------------------------------- | +| [tdd](skills/tdd/SKILL.md) | TDD workflow with Unity and CMock | +| [cmake](skills/cmake/SKILL.md) | Build configuration, adding modules and dependencies | +| [git](skills/git/SKILL.md) | Commit messages, tagging, and branching workflow | + +## Installation + +Skills are auto-discovered by Pi from `.pi/skills/`. No extra setup +required. + +To install this project's skills into another project: + +```sh +pi install -l git:github.com/portersky/helloctdd +``` + +Or as a temporary package for the current session: + +```sh +pi -e git:github.com/portersky/helloctdd +``` + +Pi auto-discovers `skills/` directories from installed packages. + +## Adding a New Skill + +Place a `SKILL.md` inside a directory under `.pi/skills/`: + +``` +.pi/skills/ + my-skill/ + SKILL.md +``` + +Pi validates the frontmatter and registers `/skill:my-skill` in the +TUI. diff --git a/.pi/skills/cmake/SKILL.md b/.pi/skills/cmake/SKILL.md new file mode 100644 index 0000000..1034f28 --- /dev/null +++ b/.pi/skills/cmake/SKILL.md @@ -0,0 +1,145 @@ +--- +name: cmake +description: CMake build configuration for the ctdd template project. Use when + adding modules, adding dependencies, configuring coverage or sanitizers, or + understanding the build system. +--- + +# CMake Skill + +## Build Commands + +| Action | Command | +| --------- | ------------------------------------------------------------------------------------------ | +| Configure | `cmake -S . -B build -G Ninja` | +| Build | `ninja -C build` | +| Run tests | `ninja -C build check` | +| Coverage | `cmake -S . -B build-cov -G Ninja -DENABLE_COVERAGE=ON` then `ninja -C build-cov coverage` | +| ASan | `cmake -S . -B build-asan -G Ninja -DENABLE_ASAN=ON` then `ninja -C build-asan` | + +> ASan and coverage cannot be used together. + +## Adding a Module + +Modules live in `ctdd/` as static libraries. Register them in +`ctdd/CMakeLists.txt`: + +```cmake +add_library(ctdd_ .c) +target_include_directories(ctdd_ PUBLIC "${CMAKE_SOURCE_DIR}") +target_compile_features(ctdd_ PRIVATE c_std_23) +``` + +Link into `main` in the root `CMakeLists.txt`: + +```cmake +target_link_libraries(main PRIVATE ... ctdd_) +``` + +## Adding a Dependency + +Dependencies are fetched via custom `Find.cmake` scripts in `deps/`. +`deps/` is on `CMAKE_MODULE_PATH` so `find_package()` resolves to these +scripts first. + +### 1. Create `deps/Find.cmake` + +Pattern (follow `deps/FindUnity.cmake` or `deps/FindCMock.cmake`): + +```cmake +if (DEFINED _FIND_INCLUDED) + return() +endif() +set(_FIND_INCLUDED TRUE) + +set(_VERSION "x.y.z") +message(STATUS "Fetching ${_VERSION}") + +include(FetchContent) + +FetchContent_Declare( + + URL https://github.com/org//archive/refs/tags/v${_VERSION}.zip + DOWNLOAD_EXTRACT_TIMESTAMP TRUE +) + +FetchContent_MakeAvailable() + +if (NOT TARGET ::) + add_library(:: ALIAS ) +endif() + +set(_FOUND TRUE) +``` + +For libraries without CMakeLists.txt (like CMock), use +`FetchContent_Populate` and compile manually. See `FindCMock.cmake` +for the pattern. + +### 2. Add `find_package( REQUIRED)` to `CMakeLists.txt` + +Place it after `include(Platform)` and `include(Flags)`. + +### 3. Link with `::` + +In `ctdd/CMakeLists.txt` or `tests/CMakeLists.txt` as needed: + +```cmake +target_link_libraries(ctdd_ PRIVATE ::) +``` + +## Platform Flags + +`deps/Platform.cmake` sets these variables for conditional logic: + +| Variable | Meaning | +| ----------------- | ------------------------------------------------ | +| `IS_CLANG_OR_GCC` | Clang or GCC compiler | +| `IS_MSVC` | MSVC compiler | +| `IS_WINDOWS` | Windows target | +| `IS_LINUX` | Linux target | +| `IS_MACOS` | macOS target | +| `IS_IOS` | iOS target | +| `IS_ANDROID` | Android target | +| `IS_EMSCRIPTEN` | Emscripten/WASM target | +| `ARCH` | Normalized arch (`amd64`, `arm64`, `wasm`, etc.) | +| `IS_AMD64` | x86_64 | +| `IS_ARM64` | arm64/aarch64 | + +## Compiler Flags + +`deps/Flags.cmake` defines `BASE_OPTIONS` (warning flags) and +`BASE_DEFINITIONS`. Apply per-target to avoid polluting fetched +dependencies: + +```cmake +target_compile_options( PRIVATE ${BASE_OPTIONS}) +target_compile_definitions( PRIVATE ${BASE_DEFINITIONS}) +``` + +## CMock Mock Generation + +`tests/CMakeLists.txt` provides a `cmock_generate_mock` helper function: + +```cmake +cmock_generate_mock( "") +``` + +With optional config file: + +```cmake +cmock_generate_mock( "
" "cmock_config.yml") +``` + +Generated mocks go into `build/mocks/` as `Mock.h/.c`. + +## Coverage + +Enabled via `-DENABLE_COVERAGE=ON`. Requires GCC or Clang + `gcovr`. +Report at `build-cov/coverage/index.html`. Only `ctdd/` sources are +measured; Unity, CMock, and mocks are excluded. + +## Sanitizers + +`deps/Sanitizers.cmake` provides AddressSanitizer via `-DENABLE_ASAN=ON`. +Incompatible with coverage. diff --git a/.pi/skills/git/SKILL.md b/.pi/skills/git/SKILL.md new file mode 100644 index 0000000..4df2c17 --- /dev/null +++ b/.pi/skills/git/SKILL.md @@ -0,0 +1,167 @@ +--- +name: git +description: Git workflow for the ctdd template project. Use when committing + changes, creating tags for releases, or following the branching and commit + message conventions. +--- + +# Git Skill + +## Commit Messages + +Follow [Conventional Commits](https://www.conventionalcommits.org/) with the +50/72 rule. + +### Format + +``` +: + + + +