Expert modern C++ (17/20/23): safe, performant code, RAII, move semantics, templates/concepts, and UB diagnosis. Trigger keywords: C++, C++17, C++20, C++23, smart pointer, unique_ptr, RAII, move semantics, rvalue, template, concept, STL, undefined behavior, constexpr, memory, dangling. Use for C++ implementation, optimization, generic programming, or UB/memory issues.
How this skill is triggered — by the user, by Claude, or both
Slash command
/cpp-expert:cpp-expertThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
> RAII owns every resource; values move, don't copy. Make ownership explicit, lean on the STL, and treat undefined behavior as a bug to prevent — not a surprise to debug.
RAII owns every resource; values move, don't copy. Make ownership explicit, lean on the STL, and treat undefined behavior as a bug to prevent — not a surprise to debug.
competitive-programming-expert.software-architect.auto, range-based for, structured bindings, std::optional/variant/string_view/span.static_assert so errors surface at the call site, not deep in instantiation.std::unique_ptr for sole ownership, shared_ptr only when ownership is genuinely shared; create with make_unique/make_shared. Raw pointers/references are non-owning observers.std::scoped_lock/lock_guard.const& for read-only, by value + std::move to sink, string_view/span for non-owning views. Rely on (N)RVO — return by value.shared_ptr (atomic refcount cost) and needless copies; emplace_back, reserve. Choose containers deliberately (vector by default). constexpr/consteval for compile-time work. Profile before micro-optimizing.-Wall -Wextra), sanitizers (ASan/UBSan/TSan), and tools (clang-tidy).new/delete → leaks/double-free; use smart pointers + RAII.string_view/reference to a local/temporary → dangling.shared_ptr everywhere → atomic overhead + cycles (use weak_ptr to break).reinterpret_cast → use static_cast/dynamic_cast.std::endl in loops → forced flush; use '\n'.RAII + move-only ownership (C++17)
#include <memory>
#include <string>
#include <utility>
class Connection {
public:
explicit Connection(std::string dsn) : dsn_(std::move(dsn)) { /* open */ }
~Connection() noexcept { /* close */ }
Connection(const Connection&) = delete; // non-copyable
Connection& operator=(const Connection&) = delete;
Connection(Connection&&) noexcept = default; // movable
Connection& operator=(Connection&&) noexcept = default;
private:
std::string dsn_;
};
auto make_conn(std::string dsn) {
return std::make_unique<Connection>(std::move(dsn)); // ownership is explicit
}
Concept-constrained template (clear errors, no overflow)
#include <concepts>
template <std::integral T>
constexpr T midpoint(T a, T b) noexcept { return a + (b - a) / 2; }
competitive-programming-expert — STL-heavy solutions and constant-factor tuning.performance-expert — profiling and allocation reduction.rust-expert — comparing systems-language ownership models.rules/cpp-style-guide.md — enforceable style rules.Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub miaoge-ge/coding-agent-skills --plugin cpp-expert