Modern C++ Project Setup
Overview
Create or modernize a C++ project around a reproducible toolchain:
Git -> GitHub -> VS Code -> CMakePresets + vcpkg -> Ninja -> compiler -> tests/lint/docs
Prefer project-local, repeatable setup over global machine assumptions. First classify the user's working directory and host platform, then either generate a greenfield scaffold or patch the existing project without erasing its current pipeline.
Workflow
Determine the user's working directory and whether a project already exists.
- Check the user-provided path or current working directory before writing files.
- Treat the directory as an existing project if it already has source files,
CMakeLists.txt, build scripts, package metadata, editor config, CI, docs, or a git history.
- For existing work, inventory the full development pipeline before editing: build system, dependency manager, compiler and standard, presets/tasks/scripts, tests, format/lint/static analysis, docs, debugger/editor integration, CI, packaging/install rules, and generated artifacts.
- For greenfield work, default to an app plus reusable library target, C++20, Ninja, vcpkg manifest mode, GoogleTest, clang-format, clang-tidy, Doxygen, and VS Code settings.
- If the request is about MCU firmware, OpenOCD, linker scripts, startup code,
arm-none-eabi, or Cortex-Debug, switch to embedded-project-setup.
Detect the user's host development environment.
- Determine OS and architecture: macOS/Linux/Windows plus arm64 or x64. Use local commands such as
uname -s, uname -m, sysctl -n machdep.cpu.brand_string, or PowerShell/.NET runtime information where appropriate.
- Select a host profile:
macos-arm64, macos-x64, linux-x64, linux-arm64, windows-x64, or windows-arm64.
- If the agent is running somewhere other than the user's real development machine, ask for the user's OS/architecture instead of assuming the sandbox matches their workstation.
Generate or update the project.
- For greenfield scaffolding, run from this skill directory:
python3 scripts/scaffold_cpp_project.py \
--name my_app \
--out /path/to/workspace/my_app \
--host-platform macos-arm64
- The scaffold script renders reusable standard configuration from
assets/ for CMake, CMake presets, vcpkg, and VS Code. Update those assets when the shared project standard changes; update the Python script when generation logic, arguments, or dynamic source files change.
- For existing projects, use
references/cpp-project-blueprint.md as a checklist and adapt to the repository's current style instead of replacing unrelated files.
- Omit
--host-platform only when generating on the same machine where the project will be developed; the script will auto-detect that host.
Keep the toolchain contract explicit.
- Use
CMakePresets.json for configure/build profiles.
- Use vcpkg manifest mode through
vcpkg.json.
- Use host-specific vcpkg triplets such as
arm64-osx, x64-osx, x64-linux, arm64-linux, x64-windows, and arm64-windows.
- Use Ninja as the generator unless the user or platform requires otherwise.
- Use Clang on macOS, GCC on Linux, and MSVC on Windows by default.
Wire editor support.
- Recommend VS Code extensions: CMake Tools, clangd, CodeLLDB for macOS/Linux, and Microsoft C/C++ debugging support for Windows.
- Disable competing IntelliSense when clangd is responsible for semantic analysis.
- Make
compile_commands.json available through CMake configure output and point clangd at the active preset's build directory.
- Add launch configurations for the generated executable on macOS/Linux and Windows when creating a cross-platform scaffold.
Add quality gates.
- Add GoogleTest tests with
ctest.
- Add
.clang-format and .clang-tidy.
- Add a Doxygen configuration path, but do not require docs generation for a normal build.
- Add CI only when requested or when the project setup task includes GitHub/GitHub Actions.
Validation
Run the strongest available validation for the target machine:
cmake --list-presets
bash scripts/bootstrap_vcpkg.sh
cmake --preset macos-arm64-debug
cmake --build --preset macos-arm64-debug
ctest --test-dir build/macos-arm64-debug --output-on-failure
bash scripts/format.sh --check
cmake --preset macos-arm64-tidy
cmake --build --preset macos-arm64-tidy
cmake --build --preset macos-arm64-debug --target docs
Adjust preset names for the selected host profile. On Windows, use pwsh scripts/bootstrap_vcpkg.ps1 and pwsh scripts/format.ps1 -Check. If vcpkg, compilers, or Doxygen are unavailable, report exactly what was skipped and why.
References
- Read
references/cpp-project-blueprint.md when choosing project layout, presets, dependency policy, editor settings, tests, formatting, linting, docs, or CI details.
- Read the scaffold script before changing its generated files or adding new options.
- Read
assets/ before changing standard generated configuration files; treat those files as templates and keep project-specific values behind @PLACEHOLDER@ variables.
1---2name: cpp-project-setup3description: Modern C++ project setup: CMake/CMakePresets, vcpkg, Ninja, VS Code/clangd, GoogleTest, clang-format/tidy, Doxygen, CI, macOS/Linux/Windows. Use for bootstrapping or modernizing host-side C++ apps and libraries; prefer embedded-project-setup for MCU firmware and cross-debug flows.4---56# Modern C++ Project Setup78## Overview910Create or modernize a C++ project around a reproducible toolchain:1112```text13Git -> GitHub -> VS Code -> CMakePresets + vcpkg -> Ninja -> compiler -> tests/lint/docs14```1516Prefer project-local, repeatable setup over global machine assumptions. First classify the user's working directory and host platform, then either generate a greenfield scaffold or patch the existing project without erasing its current pipeline.1718## Workflow19201. Determine the user's working directory and whether a project already exists.21 - Check the user-provided path or current working directory before writing files.22 - Treat the directory as an existing project if it already has source files, `CMakeLists.txt`, build scripts, package metadata, editor config, CI, docs, or a git history.23 - For existing work, inventory the full development pipeline before editing: build system, dependency manager, compiler and standard, presets/tasks/scripts, tests, format/lint/static analysis, docs, debugger/editor integration, CI, packaging/install rules, and generated artifacts.24 - For greenfield work, default to an app plus reusable library target, C++20, Ninja, vcpkg manifest mode, GoogleTest, clang-format, clang-tidy, Doxygen, and VS Code settings.25 - If the request is about MCU firmware, OpenOCD, linker scripts, startup code, `arm-none-eabi`, or Cortex-Debug, switch to `embedded-project-setup`.26272. Detect the user's host development environment.28 - Determine OS and architecture: macOS/Linux/Windows plus arm64 or x64. Use local commands such as `uname -s`, `uname -m`, `sysctl -n machdep.cpu.brand_string`, or PowerShell/.NET runtime information where appropriate.29 - Select a host profile: `macos-arm64`, `macos-x64`, `linux-x64`, `linux-arm64`, `windows-x64`, or `windows-arm64`.30 - If the agent is running somewhere other than the user's real development machine, ask for the user's OS/architecture instead of assuming the sandbox matches their workstation.31323. Generate or update the project.33 - For greenfield scaffolding, run from this skill directory:3435```bash36python3 scripts/scaffold_cpp_project.py \37 --name my_app \38 --out /path/to/workspace/my_app \39 --host-platform macos-arm6440```4142 - The scaffold script renders reusable standard configuration from `assets/` for CMake, CMake presets, vcpkg, and VS Code. Update those assets when the shared project standard changes; update the Python script when generation logic, arguments, or dynamic source files change.43 - For existing projects, use `references/cpp-project-blueprint.md` as a checklist and adapt to the repository's current style instead of replacing unrelated files.44 - Omit `--host-platform` only when generating on the same machine where the project will be developed; the script will auto-detect that host.45464. Keep the toolchain contract explicit.47 - Use `CMakePresets.json` for configure/build profiles.48 - Use vcpkg manifest mode through `vcpkg.json`.49 - Use host-specific vcpkg triplets such as `arm64-osx`, `x64-osx`, `x64-linux`, `arm64-linux`, `x64-windows`, and `arm64-windows`.50 - Use Ninja as the generator unless the user or platform requires otherwise.51 - Use Clang on macOS, GCC on Linux, and MSVC on Windows by default.52535. Wire editor support.54 - Recommend VS Code extensions: CMake Tools, clangd, CodeLLDB for macOS/Linux, and Microsoft C/C++ debugging support for Windows.55 - Disable competing IntelliSense when clangd is responsible for semantic analysis.56 - Make `compile_commands.json` available through CMake configure output and point clangd at the active preset's build directory.57 - Add launch configurations for the generated executable on macOS/Linux and Windows when creating a cross-platform scaffold.58596. Add quality gates.60 - Add GoogleTest tests with `ctest`.61 - Add `.clang-format` and `.clang-tidy`.62 - Add a Doxygen configuration path, but do not require docs generation for a normal build.63 - Add CI only when requested or when the project setup task includes GitHub/GitHub Actions.6465## Validation6667Run the strongest available validation for the target machine:6869```bash70cmake --list-presets71bash scripts/bootstrap_vcpkg.sh72cmake --preset macos-arm64-debug73cmake --build --preset macos-arm64-debug74ctest --test-dir build/macos-arm64-debug --output-on-failure75bash scripts/format.sh --check76cmake --preset macos-arm64-tidy77cmake --build --preset macos-arm64-tidy78cmake --build --preset macos-arm64-debug --target docs79```8081Adjust preset names for the selected host profile. On Windows, use `pwsh scripts/bootstrap_vcpkg.ps1` and `pwsh scripts/format.ps1 -Check`. If vcpkg, compilers, or Doxygen are unavailable, report exactly what was skipped and why.8283## References8485- Read `references/cpp-project-blueprint.md` when choosing project layout, presets, dependency policy, editor settings, tests, formatting, linting, docs, or CI details.86- Read the scaffold script before changing its generated files or adding new options.87- Read `assets/` before changing standard generated configuration files; treat those files as templates and keep project-specific values behind `@PLACEHOLDER@` variables.