cpp-coding-standards

Enforces C++ Core Guidelines when writing, reviewing, or refactoring modern C++ code.

Updated May 28, 2026
One-click install
npx skills add https://github.com/changfengpro/agent-skills --skill cpp-coding-standards-changfengpro
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cpp-coding-standards
Source: https://github.com/changfengpro/agent-skills/tree/main/skills/cpp-coding-standards
Command: npx skills add https://github.com/changfengpro/agent-skills --skill cpp-coding-standards-changfengpro

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? C++ codebases often accumulate unsafe patterns like raw new/delete, plain enums, C-style casts, and unconstrained templates. This Skill provides a consolidated, rule-referenced checklist based on the C++ Core Guidelines so code written or reviewed by an AI follows modern, safe, idiomatic C++17/20/23 practices. ## Core Features & Use Cases - Rule-Referenced Standards: Covers the major C++ Core Guidelines sections (P, I, F, C, R, ES, E, Con, CP, T, SL, Enum, SF, NL, Per) with concrete DO/DON'T code examples for each. - Code Review Checklist: Includes a quick-reference checklist for verifying RAII usage, const-correctness, smart pointers, concepts, exception safety, and concurrency locking before marking work complete. - Use Case: When refactoring a legacy class that uses raw pointers and manual delete, apply the resource management rules (R.1, R.11, R.20) to convert it to RAII with std::unique_ptr and the Rule of Zero/Five. ## Quick Start Review this C++ file against the C++ Core Guidelines and fix any violations of RAII, const-correctness, and smart pointer usage.

Frequently Asked Questions about cpp-coding-standards

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce C++ Core Guidelines in code reviews?

Use the quick-reference checklist covering raw new/delete elimination, const-correctness, enum class usage, nullptr, explicit constructors, and RAII locks. Each checklist item references a specific Core Guidelines rule number for traceability during review.

What C++ standards does this coding standard cover?

The guidelines target modern C++ including C++17, C++20, and C++23. Features like concepts, std::scoped_lock, std::string_view, and constexpr computation are covered alongside foundational rules from the C++ Core Guidelines.

When should I use unique_ptr vs shared_ptr in C++?

Prefer std::unique_ptr by default since it expresses exclusive ownership with zero overhead (rule R.21). Use std::shared_ptr only when ownership is genuinely shared, and always create shared pointers with std::make_shared (R.22).

Should I use enum or enum class in modern C++?

Prefer enum class over plain enum (rule Enum.3) because it is strongly typed and does not leak enumerator names into the enclosing scope. Avoid ALL_CAPS enumerator names (Enum.5) and unnamed enumerations (Enum.6).

When should these C++ guidelines not be applied?

They do not apply to non-C++ projects or legacy C codebases that cannot adopt modern C++ features. In embedded or bare-metal contexts where guidelines conflict with hardware constraints, adopt rules selectively rather than wholesale.

How do I avoid deadlocks with multiple mutexes in C++?

Use std::scoped_lock to acquire multiple mutexes atomically in a deadlock-free manner (rule CP.21). Always use RAII lock wrappers like lock_guard or unique_lock with names (CP.20, CP.44), and never call unknown code while holding a lock (CP.22).