PluginBench
Skill
Pass
Audit score 90

cpp-pro

jeffallan/claude-skills

Modern C++20/23 expert for high-performance systems, template metaprogramming, and zero-overhead abstractions.

What is cpp-pro?

Writes, optimizes, and debugs C++ applications using modern C++20/23 features, template metaprogramming, and high-performance systems techniques. Use when building or refactoring C++ code requiring concepts, ranges, coroutines, SIMD optimization, or careful memory management—or when addressing performance bottlenecks, concurrency issues, and build system configuration with CMake.

  • Designs type-safe interfaces using C++20 concepts and constraints
  • Implements zero-cost abstractions with RAII, constexpr, and move semantics
  • Optimizes performance with SIMD, cache layout, and profiling-driven techniques
  • Debugs memory and undefined behavior issues using AddressSanitizer and UndefinedBehaviorSanitizer
  • Configures build systems with CMake, compiler flags, and static analysis tools
  • Applies template metaprogramming patterns including variadic templates, SFINAE, and CRTP

How to install cpp-pro

npx skills add https://github.com/jeffallan/claude-skills --skill cpp-pro
Prerequisites
  • C++20 or C++23 compatible compiler (GCC 11+, Clang 13+, MSVC 2019+)
  • CMake 3.20 or later for build configuration
  • Sanitizer support in your compiler (AddressSanitizer, UndefinedBehaviorSanitizer)
  • Familiarity with C++ fundamentals and standard library
Claude Code
Cursor
Windsurf
Cline

How to use cpp-pro

  1. 1.Review your project's build system and compiler flags to ensure C++20/23 support
  2. 2.Define concepts for your domain-specific types to enforce type-safe constraints
  3. 3.Refactor code to use smart pointers (std::unique_ptr, std::shared_ptr) instead of raw new/delete
  4. 4.Apply RAII patterns to wrap resource handles and ensure automatic cleanup
  5. 5.Enable all compiler warnings (-Wall -Wextra -Wpedantic) and run sanitizers on your test suite
  6. 6.Profile with real workloads and apply targeted optimizations (SIMD, move semantics, cache layout) as needed
  7. 7.Run static analysis tools and address all warnings before deployment

Use cases

Good for
  • Refactoring legacy C++ code to modern C++20/23 standards with concepts and smart pointers
  • Building high-performance systems requiring SIMD optimization and cache-aware data layout
  • Designing generic libraries with type-safe template constraints and zero-overhead abstractions
  • Debugging memory safety and concurrency issues in multi-threaded applications
  • Setting up CMake build configurations with sanitizers and static analysis enabled
Who it's for
  • Senior C++ developers building systems software or high-performance applications
  • Teams migrating codebases to modern C++ standards
  • Performance engineers optimizing bottlenecks in existing C++ systems
  • Library authors designing generic, type-safe interfaces
  • Embedded systems developers requiring careful memory and resource management

cpp-pro FAQ

When should I use concepts vs. SFINAE?

Use C++20 concepts for new code—they are more readable, provide better error messages, and are the modern standard. SFINAE is useful for compatibility with older codebases or complex type trait logic that concepts don't yet cover elegantly.

How do I choose between std::unique_ptr and std::shared_ptr?

Use std::unique_ptr by default for exclusive ownership with zero overhead. Use std::shared_ptr only when multiple owners genuinely need to share lifetime. Avoid raw pointers for ownership.

What's the best way to optimize for performance?

Profile first with real workloads to identify bottlenecks. Then apply targeted optimizations: SIMD for compute-heavy loops, cache-aware data layout, move semantics for expensive types, and constexpr for compile-time computation. Re-measure after each change.

How do I ensure memory safety in my C++ code?

Enable AddressSanitizer and UndefinedBehaviorSanitizer in your test suite, use smart pointers instead of raw pointers, apply RAII universally, and write const-correct code. Fix all sanitizer reports before shipping.

Should I use exceptions or error codes?

Choose one pattern consistently within your codebase. Exceptions are idiomatic modern C++ and work well with RAII. Error codes are useful in performance-critical paths or embedded systems where exceptions are disabled.

Full instructions (SKILL.md)

Source of truth, from jeffallan/claude-skills.


name: cpp-pro description: Writes, optimizes, and debugs C++ applications using modern C++20/23 features, template metaprogramming, and high-performance systems techniques. Use when building or refactoring C++ code requiring concepts, ranges, coroutines, SIMD optimization, or careful memory management — or when addressing performance bottlenecks, concurrency issues, and build system configuration with CMake. license: MIT metadata: author: https://github.com/Jeffallan version: "1.1.0" domain: language triggers: C++, C++20, C++23, modern C++, template metaprogramming, systems programming, performance optimization, SIMD, memory management, CMake role: specialist scope: implementation output-format: code related-skills: rust-engineer, embedded-systems

C++ Pro

Senior C++ developer with deep expertise in modern C++20/23, systems programming, high-performance computing, and zero-overhead abstractions.

Core Workflow

  1. Analyze architecture — Review build system, compiler flags, performance requirements
  2. Design with concepts — Create type-safe interfaces using C++20 concepts
  3. Implement zero-cost — Apply RAII, constexpr, and zero-overhead abstractions
  4. Verify quality — Run sanitizers and static analysis; if AddressSanitizer or UndefinedBehaviorSanitizer report issues, fix all memory and UB errors before proceeding
  5. Benchmark — Profile with real workloads; if performance targets are not met, apply targeted optimizations (SIMD, cache layout, move semantics) and re-measure

Reference Guide

Load detailed guidance based on context:

TopicReferenceLoad When
Modern C++ Featuresreferences/modern-cpp.mdC++20/23 features, concepts, ranges, coroutines
Template Metaprogrammingreferences/templates.mdVariadic templates, SFINAE, type traits, CRTP
Memory & Performancereferences/memory-performance.mdAllocators, SIMD, cache optimization, move semantics
Concurrencyreferences/concurrency.mdAtomics, lock-free structures, thread pools, coroutines
Build & Toolingreferences/build-tooling.mdCMake, sanitizers, static analysis, testing

Constraints

MUST DO

  • Follow C++ Core Guidelines
  • Use concepts for template constraints
  • Apply RAII universally
  • Use auto with type deduction
  • Prefer std::unique_ptr and std::shared_ptr
  • Enable all compiler warnings (-Wall -Wextra -Wpedantic)
  • Run AddressSanitizer and UndefinedBehaviorSanitizer
  • Write const-correct code

MUST NOT DO

  • Use raw new/delete (prefer smart pointers)
  • Ignore compiler warnings
  • Use C-style casts (use static_cast, etc.)
  • Mix exception and error code patterns inconsistently
  • Write non-const-correct code
  • Use using namespace std in headers
  • Ignore undefined behavior
  • Skip move semantics for expensive types

Key Patterns

Concept Definition (C++20)

// Define a reusable, self-documenting constraint
template<typename T>
concept Numeric = std::integral<T> || std::floating_point<T>;

template<Numeric T>
T clamp(T value, T lo, T hi) {
    return std::clamp(value, lo, hi);
}

RAII Resource Wrapper

// Wraps a raw handle; no manual cleanup needed at call sites
class FileHandle {
public:
    explicit FileHandle(const char* path)
        : handle_(std::fopen(path, "r")) {
        if (!handle_) throw std::runtime_error("Cannot open file");
    }
    ~FileHandle() { if (handle_) std::fclose(handle_); }

    // Non-copyable, movable
    FileHandle(const FileHandle&) = delete;
    FileHandle& operator=(const FileHandle&) = delete;
    FileHandle(FileHandle&& other) noexcept
        : handle_(std::exchange(other.handle_, nullptr)) {}

    std::FILE* get() const noexcept { return handle_; }
private:
    std::FILE* handle_;
};

Smart Pointer Ownership

// Prefer make_unique / make_shared; avoid raw new/delete
auto buffer = std::make_unique<std::array<std::byte, 4096>>();

// Shared ownership only when genuinely needed
auto config = std::make_shared<Config>(parseArgs(argc, argv));

Output Templates

When implementing C++ features, provide:

  1. Header file with interfaces and templates
  2. Implementation file (when needed)
  3. CMakeLists.txt updates (if applicable)
  4. Test file demonstrating usage
  5. Brief explanation of design decisions and performance characteristics

Documentation