cpp-coding-standards

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

Updated Mar 25, 2026
One-click install
npx skills add https://github.com/Femad-6/my-skills --skill cpp-coding-standards-femad-6
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cpp-coding-standards
Source: https://github.com/Femad-6/my-skills/tree/main/.github/skills/cpp-coding-standards
Command: npx skills add https://github.com/Femad-6/my-skills --skill cpp-coding-standards-femad-6

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 reviews and refactoring decisions stay consistent and grounded in an authoritative standard. ## 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. - Modern C++ Enforcement: Promotes RAII, smart pointers, const/constexpr by default, enum class, concepts-constrained templates, and scoped_lock-based concurrency for C++17/20/23 code. - Review Checklist: Includes a quick-reference checklist for verifying completed C++ work against key rules like Rule of Zero/Five, explicit constructors, and noexcept usage. - Use Case: When reviewing a pull request that introduces a new class managing a file handle, use this Skill to verify RAII compliance, correct special member functions, and proper const-correctness before approving. ## Quick Start Review this C++ class against the C++ Core Guidelines and flag any violations of resource management, const-correctness, or type safety rules.

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 a rule-referenced checklist mapping each guideline section (R for resources, C for classes, ES for expressions) to concrete DO and DON'T examples. Check for raw new/delete, missing const, plain enums, and unconstrained templates against rules like R.11, Con.1, Enum.3, and T.10.

What is the difference between Rule of Zero and Rule of Five in C++?

Rule of Zero (C.20) means letting the compiler generate all special members by using value types and smart pointers. Rule of Five (C.21) applies when you manage a resource directly: if you define any of destructor, copy, or move operations, you must define all five.

Should I use unique_ptr or shared_ptr for ownership?

Prefer unique_ptr by default (R.21) since it has zero overhead and expresses exclusive ownership clearly. Use shared_ptr only when ownership is genuinely shared, and create it with make_shared (R.22). Raw pointers should represent non-owning observers only (R.3).

Does this guidance apply to embedded or legacy C codebases?

Not fully. The guidelines target modern C++17/20/23 and explicitly exclude legacy C codebases that cannot adopt modern features. Embedded or bare-metal contexts with hardware constraints should adapt the rules selectively rather than applying them wholesale.

Why avoid volatile for thread synchronization in C++?

Volatile (CP.8) does not provide atomicity or memory ordering guarantees; it only prevents compiler optimization of accesses, making it suitable for hardware I/O only. Use std::mutex with RAII locks like scoped_lock or lock_guard, or std::atomic, for correct synchronization.