Guide · Agent skill
How to use the cpp-testing agent skill for GoogleTest
Updated · written with AI from the project's own documentation and checked against our catalogue data
The cpp-testing skill is an agent skill: a SKILL.md instruction file that tells an AI agent how to handle C++ testing work using GoogleTest, GoogleMock, CMake and CTest. This guide explains what the skill changes about the agent's behaviour, how to install it from the ZIP or the Claude apps, how to phrase requests so it triggers, and what your project needs. By the end you will be able to ask an agent to write, repair or debug C++ tests and know what it will follow.
Quick start
- 1Download and unzip the skill. Download the cpp-testing ZIP from this page and unzip it so SKILL.md sits in a cpp-testing folder.
- 2Place it where your agent can read it. Copy the folder into ~/.claude/skills/ for personal use or into .claude/skills/ in your project. Alternatively, upload the ZIP under Settings → Capabilities → Skills in the Claude apps.
- 3Check your C++ toolchain. Make sure CMake, a C++ compiler such as GCC or Clang, and GoogleTest (fetched by CMake in the example) are available. CTest comes with CMake.
- 4Ask for a specific testing task. Describe the test you want in plain language, naming the function or file and mentioning GoogleTest or CTest.
- 5Build and run with CTest. Run cmake -S . -B build, then cmake --build build -j, then ctest --test-dir build --output-on-failure to confirm the results.
What the cpp-testing skill makes the agent do
When installed, the skill tells the agent to follow a red, green, refactor workflow for C++ projects: write a failing test first, make the smallest change that passes it, then clean up while keeping tests green. It also sets layout conventions such as tests/unit, tests/integration and tests/testdata, and recommends dependency injection and fakes over global state.
- Write or update GoogleTest unit tests and fixtures
- Use GoogleMock for interactions and fakes for stateful behaviour
- Configure CMake and CTest, including gtest_discover_tests()
- Run tests, filter failures and diagnose flaky tests
- Add coverage (GCC with lcov, or Clang with llvm-cov) and sanitizer builds
How to install the cpp-testing skill
Option 1 is a personal install: download the ZIP from the skill's page on this site and unzip it into ~/.claude/skills/ so the skill folder sits there. Option 2 is a project install: unzip it into the .claude/skills/ folder inside your project so only that project uses it.
Option 3 is to upload the ZIP in the Claude apps under Settings → Capabilities → Skills. The skill package contains a single file, SKILL.md, so after unzipping you should see that file inside the skill folder.
- Personal: ~/.claude/skills/
- Project: .claude/skills/ inside your repository
- Claude apps: Settings → Capabilities → Skills, then upload the ZIP
How to trigger the skill with natural requests
You do not need a special command. Describe the C++ testing task in plain language and mention GoogleTest, CMake or CTest where relevant. The skill's description covers creating or updating C++ tests, setting up GoogleTest and CTest, diagnosing failing or flaky tests, and adding coverage or sanitizers.
The skill is scoped to testing work. It is not meant for feature implementation without test changes, large refactors unrelated to tests, or non-C++ projects, so ask for those without the testing framing.
- 'Write GoogleTest unit tests for the Clamp function in src/clamp.cpp.'
- 'Our CTest run fails on UserStoreTest in CI. Find out why and fix it.'
- 'Set up a coverage build with GCC and lcov for this CMake project.'
- 'Add an AddressSanitizer build option and run the tests under it.'
- 'These tests are flaky because of sleep calls. Replace the synchronization.'
Example: a first GoogleTest with CMake and CTest
The skill's basic example is a small unit test that calls an Add function from production code. The agent writes the test first, then the implementation, following the red, green, refactor loop.
The skill's CMake quick start links the test executable against GTest::gtest, GTest::gmock and GTest::gtest_main, enables testing and registers tests with gtest_discover_tests(). The build and test commands are below. The skill's example fetches GoogleTest from GitHub with FetchContent, so the first configure step needs network access.
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build -j
ctest --test-dir build --output-on-failureRun, filter and debug failing tests
Run the full suite with CTest first, then narrow down. The skill's CI guidance is to run a subset first and then the full suite with --output-on-failure. To debug one failure, re-run that single test with a gtest filter, add scoped logging around the failing assertion, rerun with sanitizers enabled, and expand to the full suite once the cause is fixed.
- Filter CTest by name pattern with -R
- Filter the test binary directly with --gtest_filter
- Use ASSERT_* for preconditions and EXPECT_* for multiple checks
ctest --test-dir build -R ClampTest
ctest --test-dir build -R "UserStoreTest.*" --output-on-failure
./build/example_tests --gtest_filter=UserStoreTest.FindsExistingUserSet up coverage and sanitizers
The skill adds coverage and sanitizers as CMake options that default to OFF, so normal builds are unaffected. Coverage is enabled with ENABLE_COVERAGE=ON. For GCC the skill uses gcov with lcov and genhtml; for Clang it uses llvm-profdata and llvm-cov. Sanitizer options cover AddressSanitizer (ENABLE_ASAN), UndefinedBehaviorSanitizer (ENABLE_UBSAN) and ThreadSanitizer (ENABLE_TSAN).
Keep sanitizer and coverage builds in their own build directories, as the skill's examples do, so flags do not mix with your normal build.
- GCC coverage needs lcov and genhtml installed
- Clang coverage needs llvm-profdata and llvm-cov
- Run the sanitizer builds in CI, not only on a developer machine
cmake -S . -B build-cov -DENABLE_COVERAGE=ON
cmake --build build-cov -j
ctest --test-dir build-cov
lcov --capture --directory build-cov --output-file coverage.info
genhtml coverage.info --output-directory coverageSafety notes: scripts and network
The skill's package contains only SKILL.md. According to the listing, it does not run scripts. It does use the network: the example CMake setup downloads GoogleTest from GitHub during configuration, so builds that run it need outbound access to GitHub.
Review any test or CMake change the agent proposes before committing. The skill's guardrails ask for deterministic tests, no real time, network or filesystem dependencies in unit tests, unique cleaned-up temporary directories, and no fixed temporary paths.
- No scripts are run by this skill
- Network is used by the example FetchContent download from GitHub
- Requires CMake, a C++ compiler such as GCC or Clang, and CTest (bundled with CMake)
What people use it for
- Adding GoogleTest unit tests for an existing C++ function or class
- Converting a flaky sleep-based test to condition variables or latches
- Setting up a CMake option for coverage reports in a C++ project
- Adding an AddressSanitizer or ThreadSanitizer build to CI
- Diagnosing a single failing test with a gtest filter and CTest output
Frequently asked questions
Is the cpp-testing skill free?
The skill is published under the MIT licence, according to the listing. The skill itself is a single SKILL.md file, and you install it by unzipping the download or uploading it in the Claude apps.
How do I install the cpp-testing agent skill?
Download the ZIP from this page and unzip it into ~/.claude/skills/ for personal use or into .claude/skills/ in a project. You can also upload the ZIP in the Claude apps under Settings → Capabilities → Skills.
What do I need to use the cpp-testing skill?
You need CMake, a C++ compiler such as GCC or Clang, and GoogleTest/GoogleMock. The example fetches GoogleTest from GitHub with CMake FetchContent, and CTest is bundled with CMake. Coverage needs lcov and genhtml for GCC, or llvm-profdata and llvm-cov for Clang.
Does the cpp-testing skill work with projects that do not use GoogleTest or CMake?
The skill's examples assume GoogleTest and CMake. The listing says the agent would need to adapt them for other setups, and the skill is not meant for non-C++ projects.
Does the cpp-testing skill run scripts or use the internet?
According to the listing, it does not run scripts. It does use the network, because the example CMake setup downloads GoogleTest from GitHub during configuration.
How is this different from just asking an AI to write C++ tests?
The skill adds a set of project conventions: a red, green, refactor workflow, a tests/unit and tests/integration layout, guardrails against flaky tests, and steps for coverage and sanitizers. Without it, the agent will not necessarily follow those patterns. Alternatives named in the source include Catch2 and doctest.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
Use this skill if you are a C++ developer or team that wants an AI agent to write, repair or diagnose GoogleTest tests with CMake and CTest, or to set up coverage and sanitizer builds. Pick something else if your project does not use GoogleTest or CMake, or if you only need feature code with no test work, since the skill is scoped to testing.
Download the skill