scaffold-cmake-cxx-sanitize-gtest-env
Skill4 starsChanged 3 months agoMITView on GitHub
WHEN/WHERE/WHO: [Scheduling: Use when an AI Agent needs to bootstrap a C/C++ project with robust testing and security guardrails.] HOW: [Structural: Use this SKILL to inject a standardized CMakeLists.txt that auto-discovers Google Tests and supports Clang/GCC Sanitizers, and to generate a build guide.] WHY: [Scheduling: Ensures all C/C++ projects have a uniform, secure, and easily testable baseline environment without manual configuration.]
In this repository61 other files it gives its agents.
- activate-personalSkill
- analyze-with-tactics-questionnairesSkill
- apply-agile-testing-quadrantsSkill
- apply-architectural-tacticsSkill
- apply-attribute-driven-designSkill
- apply-fundamentals-of-data-visualizationSkill
- apply-oopsi-modelSkill
- apply-screenplay-patternSkill
- apply-specification-by-exampleSkill
- blog-topic-discoverSkill
- build-agent-memory-systemsSkill
- build-business-objectives-modelSkill
- build-data-dictionarySkill
- build-feature-treeSkill
- comment-alive-test-driven-developmentSkill
- conduct-event-stormingSkill
- create-ecosystem-mapSkill
- create-living-documentationSkill
- create-skill-from-bookSkill
- CREATING-SKILL-TEMPLATESkill
- define-architectural-driversSkill
- define-bounded-contextsSkill
- define-ubiquitous-languageSkill
- design-agentic-screenplay-modelSkill
- design-agent-perception-layersSkill
- design-agent-planningSkill
- design-agent-reward-functionsSkill
- design-agents-using-patternsSkill
- design-architecture-viewpointsSkill
- design-autonomous-ai-interfacesSkill
- design-ddd-aggregatesSkill
- design-tool-use-sandboxingSkill
- document-architectural-decisionsSkill
- document-legacy-codebaseSkill
- doc-with-usage-exampleSkill
- draft-srs-documentSkill
- elicit-requirements-modelsSkill
- evolve-skill-with-wikiSkill
- extract-business-rulesSkill
- facilitate-example-mappingSkill
- facilitate-user-story-mappingSkill
- implement-agent-observabilitySkill
- implement-agent-reflectionSkill
- improve-existing-skillSkill
- improve-user-storySkill
- managing-ai-projectsSkill
- orchestrate-multi-agent-collaborationSkill
- prioritize-requirementsSkill
- review-c4-modelSkill
- review-data-engineeringSkill
- save-as-skillSkill
- skill-commonSkill
- task-commit-triggerSkill
- test-case-with-demoSkill
- test-case-with-readmeSkill
- test-driven-developmentSkill
- UnitTesting-convert2CaTDDSkill
- update-my-resumeSkill
- update-spec-contextSkill
- validate-requirements-criteriaSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
19 rules. About 0 are common, 4 are distinctive, and 15 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
15
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
When this skill is activated, first load skill-common and apply the shared conventions it defines: canonical section order, frontmatter …
- Very specific: line 47
Transfer Check: Verify the workflow still works for empty projects and for projects with an existing complex CMakeLists.txt that require …
- Distinctive: line 48
Stop Rule: If the project layout or merge strategy is unclear, stop and ask before writing build files.
- Very specific: line 52
macOS Compatibility: MUST include the -Wno-availability compiler option to suppress macOS system header warnings.
- Very specific: line 54
DO NOT hardcode test executable names manually in CMake.
- Very specific: line 55
DO NOT overwrite an existing CMakeLists.txt without the user's explicit confirmation or taking a backup.
- Very specific: line 58
If the project already has a complex CMakeLists.txt, stop and ask the user if they want to merge the sanitizer/GTest logic into the …
- Very specific: line 64
Check for the existence of an existing CMakeLists.txt.
- Very specific: line 70
Read the template from details/cmake-template.md.
- Very specific: line 72
Write the resulting configuration to CMakeLists.txt in the target directory.
- Very specific: line 77
Check if the Test/ directory exists in the target directory.
- Very specific: line 85
Write the resulting markdown to README_BuildRunTest.md in the target directory.
- Very specific: line 90
Check if the .vscode/ directory exists.
- Very specific: line 92
Write the configuration to .vscode/settings.json (merging with existing settings if necessary).
- Distinctive: line 100
Do the generated files enforce C11/CXX17, compiler fallbacks, sanitizers, and GTest auto-discovery as claimed?
- Very specific: line 105
Verify that CMakeLists.txt exists and contains the string DiagASAN.
- Very specific: line 106
Verify that the Test/ directory exists.
- Very specific: line 107
Verify that README_BuildRunTest.md exists.
- Distinctive: line 108
If verification passes, report successful scaffolding to the user.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Scaffold CMake C++ Sanitize & GTest Environment
Common Contract (Load First)
When this skill is activated, first load skill-common and apply the shared conventions it defines: canonical section order, frontmatter rules, anti-pattern guidance, and the Review In Mind loop in review-in-mind. This skill adds only domain-specific rules below.
Who
AI Agents, C/C++ Developers, and Build Engineers setting up or upgrading a project repository.
What
Injects a battle-tested CMakeLists.txt template that enforces C11/CXX17 standards, provides compiler fallbacks (e.g., macOS Homebrew LLVM), configures Address/Thread/Memory/UndefinedBehavior Sanitizers, and uses a custom function to auto-discover and build Google Tests. It also generates a README_BuildRunTest.md guide for the project.
When
Invoke this skill when a user asks to "set up a C++ project", "configure CMake with GTest", "add sanitizers to this C project", or "scaffold the C++ testing environment". Near-miss: Do not use this if the user explicitly wants to use a different build system like Bazel or Make.
Where
Applies to the root directory of a C or C++ codebase.
Why
Manually configuring CMake for cross-platform compilation, sanitizer flags, and GTest linkage is highly error-prone. Standardizing this via an agentic skill ensures that every codebase is immediately ready for secure, test-driven development.
Inputs
- Project Name: The name of the C/C++ project.
- Target Directory: The root directory of the project.
Output (Logical Evidence)
- A configured
CMakeLists.txtin the root directory. - A
Test/directory for unit tests. - A
README_BuildRunTest.mdexplaining how to build and test the project. - A
.vscode/settings.jsonfile configuring CMake Tools and clangd.
Optimization Readiness
- Failure Signals: The scaffold overwrites existing build files without consent, sanitizer branches are missing, test discovery is manual, or the generated environment fails on the target platform.
- Evidence To Collect: Generated CMake files, build/run docs, VSCode settings, and examples where the scaffolded environment handled sanitizer and test setup correctly.
- Safe Mutation Boundaries: Refine template substitution, test-directory scaffolding, build-guide generation, and VSCode settings merging without changing the core CMake-plus-sanitizer bootstrap.
- Acceptance Criteria: Accept revisions only if the scaffolding is present, sanitizer flags are included, test discovery is automatic, and existing configuration is respected rather than overwritten blindly.
- Rejected Revision Handling: Record overwrite attempts, missing sanitizer branches, and brittle test-name assumptions so they are not repeated.
- Transfer Check: Verify the workflow still works for empty projects and for projects with an existing complex
CMakeLists.txtthat require merge decisions. - Stop Rule: If the project layout or merge strategy is unclear, stop and ask before writing build files.
Constraints (Logical Boundaries)
- Sanitizer Flags: The
CMakeLists.txtMUST include branches forDiagASAN,DiagTSAN,DiagUBSAN,DiagMSAN, andDiagLSAN. - macOS Compatibility: MUST include the
-Wno-availabilitycompiler option to suppress macOS system header warnings. - Anti-Pattern Mapping:
- DO NOT hardcode test executable names manually in CMake; use the template's auto-discovery loop for
*.cxxfiles. - DO NOT overwrite an existing
CMakeLists.txtwithout the user's explicit confirmation or taking a backup.
- DO NOT hardcode test executable names manually in CMake; use the template's auto-discovery loop for
One More Thing
If the project already has a complex CMakeLists.txt, stop and ask the user if they want to merge the sanitizer/GTest logic into the existing file or replace it entirely.
How (The 4-Phase Refinement Protocol)
Phase 1: Environment Analysis
Input State: A target directory and project name.
- Check for the existence of an existing
CMakeLists.txt. - Branch: If it exists, pause and ask the user how to proceed (merge or overwrite). Output State: Clearance to write CMake configuration.
Phase 2: Scaffold CMakeLists.txt
Input State: Clearance to write.
- Read the template from
details/cmake-template.md. - Replace the placeholder project name (
MyCraftCodes) with the user's Project Name. - Write the resulting configuration to
CMakeLists.txtin the target directory. Output State: A robust CMake configuration file created.
Phase 3: Scaffold Test Directory
Input State: CMake configured.
- Check if the
Test/directory exists in the target directory. - Branch: If it does not exist, create it.
Output State: A
Test/directory ready to receive*.cxxfiles.
Phase 4: Generate Build/Run/Test Documentation
Input State: Scaffolding complete.
- Read the template from
details/readme-build-run-test-template.md. - Replace any placeholders with the Project Name.
- Write the resulting markdown to
README_BuildRunTest.mdin the target directory. Output State: Project documentation generated.
Phase 5: Scaffold VSCode Configuration
Input State: Workspace prepared.
- Check if the
.vscode/directory exists. If not, create it. - Read the template from
details/vscode-settings-template.md. - Write the configuration to
.vscode/settings.json(merging with existing settings if necessary). Output State: VSCode environment fully configured for CMake and Sanitizers.
Review In Mind (ReviewInMindGenie)
Execute the common review loop in review-in-mind before delivering.
Review lens for this skill:
- Do the generated files enforce C11/CXX17, compiler fallbacks, sanitizers, and GTest auto-discovery as claimed?
- Does the build/run guide match the actual generated CMake behavior?
- Would a fresh checkout build and run the tests successfully?
Validation (Verifiable Rewards)
- Verify that
CMakeLists.txtexists and contains the stringDiagASAN. - Verify that the
Test/directory exists. - Verify that
README_BuildRunTest.mdexists. - If verification passes, report successful scaffolding to the user.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

