A modern C++ project template using CMake, GoogleTest, and TDD workflow.
Click the "Use this template" button above, or use the GitHub CLI:
gh repo create my-project --template <username>/claude-cpp-template --clone
cd my-project# Clone the template
git clone --depth 1 <template-url> my-project
cd my-project
# Remove template history and reinitialize
rm -rf .git
git init
git add .
git commit -m "Initial commit from claude-cpp-template"
# Update the project name in CMakeLists.txt
# Change: project(claude_cpp_template ...) to project(my_project ...)- Update
project()name inCMakeLists.txt - Rename
include/mylib/andsrc/library files as needed - Update test file names in
tests/
- C++20 standard with Clang toolchain
- CMake build system with presets
- GoogleTest for unit testing (via FetchContent)
- TDD workflow with dedicated presets
- Thread Sanitizer for race condition detection
- Address Sanitizer for memory error detection
- Code coverage with llvm-cov
- clang-format for code formatting (Google style)
- clang-tidy for static analysis
- VSCode integration with C++ TestMate debugging
├── include/mylib/ # Public headers
├── src/ # Library implementation
├── app/ # Application executable
├── tests/ # Unit tests
├── cmake/ # CMake modules
├── context/ # Reference documentation
│ ├── standards/ # Coding standards (linked to Claude Code)
│ ├── libraries/ # Project-specific library docs
│ └── project/ # Human reference docs
└── .claude/ # Claude Code configuration
- CMake 3.28+
- Clang 15+
- llvm-profdata, llvm-cov (for code coverage)
# Debug build
cmake --preset default
cmake --build build
# Release build
cmake --preset release
cmake --build build-release
# TDD with Thread Sanitizer (recommended for development)
cmake --preset tdd-tsan
cmake --build build-tdd-tsan
# TDD with Address Sanitizer + Coverage
cmake --preset tdd-asan
cmake --build build-tdd-asancmake -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build# Run all tests
ctest --test-dir build --output-on-failure
# Run tests by label
ctest --test-dir build -L unit
# Run specific test
ctest --test-dir build -R "MyLibTest"# Build with ASan preset (includes coverage)
cmake --preset tdd-asan
cmake --build build-tdd-asan
# Generate coverage report
cmake --build build-tdd-asan --target coverage
# View report (Linux)
xdg-open build-tdd-asan/coverage/index.html# Check formatting
clang-format --dry-run -Werror src/*.cpp include/mylib/*.hpp
# Apply formatting
clang-format -i src/*.cpp include/mylib/*.hpp
# Run static analysis
clang-tidy src/*.cpp -p buildMIT License - see LICENSE