
Cpp Pro
Ship modern C++20 libraries and apps with CMake targets, warnings-as-errors, FetchContent deps, tests, and install rules.
Overview
Cpp Pro is an agent skill for the Build phase that guides modern C++20 development with CMake targets, strict warnings, dependency fetching, tests, and install packaging.
Install
npx skills add https://github.com/jeffallan/claude-skills --skill cpp-proWhat is this skill?
- CMake 3.20+ projects with cxx_std_20, EXPORT_COMPILE_COMMANDS, and GNU install layouts
- Strict warnings treated as errors (MSVC /W4 /WX or GCC -Wall -Wextra -Wpedantic -Werror)
- INTERFACE/INSTALL_INTERFACE include patterns and target_compile_features on libraries
- FetchContent for pinned third-party deps (e.g., fmt) linked via imported targets
- Separate library and executable targets with enable_testing and install(EXPORT) hooks
- CMake minimum 3.20
- C++20 standard enforcement block
Adoption & trust: 3k installs on skills.sh; 9.7k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your C++ repo is a pile of ad hoc compile lines without standard targets, warning policy, or a path to test and install artifacts.
Who is it for?
Indie developers standing up native CLIs, services, or libraries where CMake and C++20 conventions must be correct on day one.
Skip if: Frontend-only stacks, greenfield projects that will stay in Rust/Go, or teams that already maintain a mature Bazel/Conan monorepo they will not migrate.
When should I use this skill?
User is authoring or refactoring C++/CMake projects, wiring libraries and executables, or needs strict warning and dependency patterns for native code.
What do I get? / Deliverables
You get CMake layouts with library/executable separation, pinned dependencies, and CI-friendly warning discipline ready for local builds and packaging.
- CMakeLists with library/app targets, tests hook, and install rules
- Dependency declarations via FetchContent or equivalent imported targets
Recommended Skills
Journey fit
C++ implementation and build-system work sits squarely in Build when you are turning designs into compiled artifacts and linkable modules. Backend subphase covers native services, performance-critical modules, and CMake-first repo layout rather than UI polish.
How it compares
Skill package for CMake/C++ structure—not a hosted compiler, container image, or CI runner.
Common Questions / FAQ
Who is cpp-pro for?
Solo builders and small teams shipping C++20 binaries or libraries who want agent help aligned to modern CMake practices rather than generic coding tips.
When should I use cpp-pro?
During Build while scaffolding backends or CLIs, wiring FetchContent dependencies, tightening warning flags, or adding test and install targets before Ship.
Is cpp-pro safe to install?
It describes build files and toolchain commands; review the Security Audits panel on this page and audit any FetchContent URLs and tags before agents pull dependencies.
SKILL.md
READMESKILL.md - Cpp Pro
# Build Systems and Tooling ## Modern CMake ```cmake cmake_minimum_required(VERSION 3.20) project(MyProject VERSION 1.0.0 LANGUAGES CXX) # Set C++ standard set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) # Export compile commands for tools set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Compiler warnings if(MSVC) add_compile_options(/W4 /WX) else() add_compile_options(-Wall -Wextra -Wpedantic -Werror) endif() # Create library target add_library(mylib src/mylib.cpp include/mylib.h ) target_include_directories(mylib PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include> PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) target_compile_features(mylib PUBLIC cxx_std_20) # Create executable add_executable(myapp src/main.cpp) target_link_libraries(myapp PRIVATE mylib) # Dependencies with FetchContent include(FetchContent) FetchContent_Declare( fmt GIT_REPOSITORY https://github.com/fmtlib/fmt.git GIT_TAG 10.1.1 ) FetchContent_MakeAvailable(fmt) target_link_libraries(mylib PUBLIC fmt::fmt) # Testing enable_testing() add_subdirectory(tests) # Install rules include(GNUInstallDirs) install(TARGETS mylib myapp EXPORT MyProjectTargets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) ``` ## Sanitizers ```cmake # AddressSanitizer (ASan) - memory errors set(CMAKE_CXX_FLAGS_ASAN "-g -O1 -fsanitize=address -fno-omit-frame-pointer" CACHE STRING "Flags for ASan build" ) # UndefinedBehaviorSanitizer (UBSan) set(CMAKE_CXX_FLAGS_UBSAN "-g -O1 -fsanitize=undefined -fno-omit-frame-pointer" CACHE STRING "Flags for UBSan build" ) # ThreadSanitizer (TSan) - data races set(CMAKE_CXX_FLAGS_TSAN "-g -O1 -fsanitize=thread -fno-omit-frame-pointer" CACHE STRING "Flags for TSan build" ) # MemorySanitizer (MSan) - uninitialized reads set(CMAKE_CXX_FLAGS_MSAN "-g -O1 -fsanitize=memory -fno-omit-frame-pointer" CACHE STRING "Flags for MSan build" ) # Usage: cmake -DCMAKE_BUILD_TYPE=ASAN .. ``` ## Static Analysis ```yaml # .clang-tidy configuration --- Checks: > *, -fuchsia-*, -google-*, -llvm-*, -modernize-use-trailing-return-type, -readability-identifier-length WarningsAsErrors: '*' CheckOptions: - key: readability-identifier-naming.ClassCase value: CamelCase - key: readability-identifier-naming.FunctionCase value: lower_case - key: readability-identifier-naming.VariableCase value: lower_case - key: readability-identifier-naming.ConstantCase value: UPPER_CASE - key: readability-identifier-naming.MemberCase value: lower_case - key: readability-identifier-naming.MemberSuffix value: '_' - key: modernize-use-nullptr.NullMacros value: 'NULL' ``` ```bash # Run clang-tidy clang-tidy src/*.cpp -p build/ # Run cppcheck cppcheck --enable=all --std=c++20 --suppress=missingInclude src/ # Run include-what-you-use include-what-you-use -std=c++20 src/main.cpp ``` ## Testing with Catch2 ```cpp #include <catch2/catch_test_macros.hpp> #include <catch2/benchmark/catch_benchmark.hpp> #include "mylib.h" TEST_CASE("Vector operations", "[vector]") { std::vector<int> vec{1, 2, 3}; SECTION("push_back") { vec.push_back(4); REQUIRE(vec.size() == 4); REQUIRE(vec.back() == 4); } SECTION("pop_back") { vec.pop_back(); REQUIRE(vec.size() == 2); REQUIRE(vec.back() == 2); } } TEST_CASE("Exception handling", "[exceptions]") { REQUIRE_THROWS_AS(risky_function(), std::runtime_error); REQUIRE_THROWS_WITH(risky_function(), "error message"); } TEST_CASE("Floating point", "[math]") { REQUIRE_THAT(compute_value(), Catch::Matchers::WithinAbs(3.14, 0.01)); } BENCHMARK("Vector creation") { return