Skip to main content
skill CX Codex

cpp-expert skill for Claude Code: what it does, how to install

cpp-expert — an agent skill for C++20/23 work: STL, ownership, concurrency and CMake. Handy when the agent has to write or repair modern C++.

Apache-2.0 250 installs ★ 45 updated 2026-10-12

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add personamanagmentlayer/pcl --skill cpp-expert -a claude-code
Open on GitHub

What cpp-expert does

The skill hands the agent a reference on modern C++: concepts, ranges and views, coroutines, modules, std::format, std::span, the spaceship operator. STL containers and algorithms get their own sections, as do RAII with smart pointers, move semantics, atomics, mutexes and std::async. A sample CMakeLists.txt ships with -Wall -Wextra -Wpedantic -O3, and there is a list of habits to drop, raw owning pointers among them.

Inside are SKILL.md with code samples and two files under references/: BEST_PRACTICES.md on RAII, const correctness and the rule of zero/three/five, plus MODERN_C_SYNTAX.md. The agent opens them when a task calls for it instead of loading everything up front.

Tool permissions stay narrow. allowed-tools lists Read, Write, Edit and Bash limited to g++, clang++, cmake and make. A build driven by any other toolchain won't be run by the skill, so either spell it out for the agent or run it yourself.

What it helps with

  • Swap a raw owning pointer for std::unique_ptr
  • Work out why a vector is copied where a move would do
  • Write a C++20 CMakeLists.txt with compiler warnings on
  • Move a hand-written loop onto ranges and views
  • Trace a data race around std::atomic and a mutex

Example prompts for the agent

  • Rewrite this class for C++20 and replace the raw pointer with std::unique_ptr; explain the choice.
  • Write a CMakeLists.txt for a C++23 project with -Wall -Wextra and link Threads.
  • Where does the extra vector copy come from? Show me the move-based version.

How to install cpp-expert

1Skills CLI (Vercel)

npx skills add personamanagmentlayer/pcl --skill cpp-expert -a claude-code

2Manually: put the files in place

~/.claude/skills/cpp-expert/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/cpp-expert/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about cpp-expert

How do I install cpp-expert in Claude Code?

Run npx skills add personamanagmentlayer/pcl --skill cpp-expert -a claude-code, then check ~/.claude/skills/cpp-expert/SKILL.md.

What does cpp-expert do?

It gives the agent a C++20/23 reference covering STL, algorithms, RAII, coroutines, concurrency and CMake builds. Longer material sits in references/ and is read on demand.

Which shell commands can the skill run?

allowed-tools grants Read, Write, Edit and Bash for g++, clang++, cmake and make only. Building through another toolchain is on you.

Source text

SKILL.md · Apache-2.0
---
name: cpp-expert
version: 1.1.0
description: >-
  Expert-level C++ development with modern C++20/23, STL, memory management, and
  performance. Use when the user mentions C++, C++20, C++23, the STL, templates, or
  performance, or when the task involves Modern C++ Features, Memory Management, Ranges and
  Views, or Coroutines.
category: languages
tags: [cpp, c++, c++20, c++23, stl, templates, performance, memory]
allowed-tools:
  - Read
  - Write
  - Edit
  - Bash(g++:*, clang++:*, cmake:*, make:*)
---

# C++ Expert

Expert guidance for modern C++ development including C++20/23 features, STL, templates, memory management, and high-performance programming.

## Core Concepts

### Modern C++ Features (C++20/23)

- Concepts and constraints
- Ranges and views
- Coroutines
- Modules
- Three-way comparison (spaceship operator)
- std::format
- std::span
- Designated initializers
- consteval and constinit

### Memory Management

- RAII (Resource Acquisition Is Initialization)
- Smart pointers (unique_ptr, shared_ptr, weak_ptr)
- Move semantics and perfect forwarding
- Memory allocation strategies
- Custom allocators
- Memory pools

### Performance

- Zero-cost abstractions
- Inline optimization
- Template metaprogramming
- Compile-time computation (constexpr)
- Cache-friendly data structures
- SIMD operations

## STL Containers

### Sequential Containers

```cpp
#include <vector>
#include <deque>
#include <list>
#include <array>

// vector - dynamic array
std::vector<int> vec = {1, 2, 3, 4, 5};
vec.push_back(6);
vec.emplace_back(7); // Construct in-place
vec.reserve(100); // Pre-allocate capacity

// deque - double-ended queue
std::deque<int> deq = {1, 2, 3};
deq.push_front(0);
deq.push_back(4);

// list - doubly-linked list
std::list<int> lst = {1, 2, 3};
lst.push_front(0);
lst.push_back(4);
lst.remove(2); // Remove all elements with value 2

// array - fixed-size array
std::array<int, 5> arr = {1, 2, 3, 4, 5};
```

### Associative Containers

```cpp
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

// map - ordered key-value pairs
std::map<std::string, int> ages;
ages["Alice"] = 30;
ages["Bob"] = 25;
ages.insert({"Charlie", 35});

// set - ordered unique elements
std::set<int> numbers = {3, 1, 4, 1, 5, 9};
numbers.insert(2);

// unordered_map - hash table
std::unordered_map<std::string, int> hash_map;
hash_map["key"] = 42;

// unordered_set - hash set
std::unordered_set<int> hash_set = {1, 2, 3};
```

## Algorithms

```cpp
#include <algorithm>
#include <numeric>
#include <vector>

std::vector<int> numbers = {5, 2, 8, 1, 9, 3, 7};

// Sorting
std::sort(numbers.begin(), numbers.end());
std::sort(numbers.begin(), numbers.end(), std::greater<int>());

// Searching
auto it = std::find(numbers.begin(), numbers.end(), 8);
bool found = std::binary_search(numbers.begin(), numbers.end(), 5);

// Transforming
std::vector<int> doubled(numbers.size());
std::transform(numbers.begin(), numbers.end(), doubled.begin(),
    [](int n) { return n * 2; });

// Filtering
std::vector<int> evens;
std::copy_if(numbers.begin(), numbers.end(), std::back_inserter(evens),
    [](int n) { return n % 2 == 0; });

// Accumulate
int sum = std::accumulate(numbers.begin(), numbers.end(), 0);
int product = std::accumulate(numbers.begin(), numbers.end(), 1,
    std::multiplies<int>());

// Partition
auto pivot = std::partition(numbers.begin(), numbers.end(),
    [](int n) { return n < 5; });

// Remove
numbers.erase(std::remove(numbers.begin(), numbers.end(), 5), numbers.end());

// Unique (remove consecutive duplicates)
std::sort(numbers.begin(), numbers.end());
numbers.erase(std::unique(numbers.begin(), numbers.end()), numbers.end());
```

## Concurrency

```cpp
#include <thread>
#include <mutex>
#include <future>
#include <atomic>

// Thread
void worker(int id) {
    std::cout << "Thread " << id << '\n';
}

std::thread t1(worker, 1);
std::thread t2(worker, 2);
t1.join();
t2.join();

// Mutex
std::mutex mtx;
int shared_data = 0;

void increment() {
    std::lock_guard<std::mutex> lock(mtx);
    ++shared_data;
}

// Atomic
std::atomic<int> counter{0};
counter++; // Thread-safe
counter.fetch_add(5);

// Future and promise
std::promise<int> prom;
std::future<int> fut = prom.get_future();

std::thread t([&prom]() {
    std::this_thread::sleep_for(std::chrono::seconds(1));
    prom.set_value(42);
});

int result = fut.get(); // Blocks until ready
t.join();

// async
auto future = std::async(std::launch::async, []() {
    return 42;
});

int value = future.get();
```

## Build Systems

### CMake

```cmake
# CMakeLists.txt
cmake_minimum_required(VERSION 3.20)
project(MyApp VERSION 1.0.0 LANGUAGES CXX)

# Set C++ standard
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Compiler flags
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
    add_compile_options(-Wall -Wextra -Wpedantic -O3)
endif()

# Find packages
find_package(Threads REQUIRED)
find_package(Boost 1.75 REQUIRED COMPONENTS system filesystem)

# Add executable
add_executable(myapp
    src/main.cpp
    src/module.cpp
    include/module.h
)

# Include directories
target_include_directories(myapp PRIVATE include)

# Link libraries
target_link_libraries(myapp PRIVATE
    Threads::Threads
    Boost::system
    Boost::filesystem
)

# Install
install(TARGETS myapp DESTINATION bin)
```

## Anti-Patterns to Avoid

❌ **Raw pointers for ownership**: Use smart pointers
❌ **Manual memory management**: Use RAII
❌ **Using C-style arrays**: Use std::array or std::vector
❌ **Ignoring const correctness**: Mark everything const that can be
❌ **Unnecessary copies**: Use move semantics and references
❌ **Premature optimization**: Profile before optimizing
❌ **Using `new` without `delete`**: Use smart pointers

## Reference Documentation

Detailed material lives alongside this skill and is read on demand:

- [Best Practices](references/BEST_PRACTICES.md) — RAII, Const Correctness, Rule of Zero/Three/Five
- [Modern C++ Syntax](references/MODERN_C_SYNTAX.md) — Concepts (C++20), Ranges and Views (C++20), Coroutines (C++20), Smart Pointers, Move Semantics, Templates and Metaprogramming, std::format (C++20)

## Resources

- C++ Reference: https://en.cppreference.com/
- C++ Core Guidelines: https://isocpp.github.io/CppCoreGuidelines/
- Compiler Explorer: https://godbolt.org/
- CPP Reference: https://cplusplus.com/

© personamanagmentlayer · Apache-2.0 · personamanagmentlayer/pcl

Similar skills

All skills for Programming languages →

From the same set104

The whole set →

Project sponsors

Companies that keep this analytics open