cpp-coding-standards/SKILL.md
C++ coding standards based on the C++ Core Guidelines (isocpp.github.io). Use when writing, reviewing, or refactoring C++ code to enforce modern, safe, and idiomatic practices.
npx skillsauth add lidge-jun/cli-jaw-skills cpp-coding-standardsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Coding standards for modern C++ (C++17/20/23) derived from the C++ Core Guidelines. Enforces type safety, resource safety, immutability, and clarity.
enum vs enum class, raw pointer vs smart pointer)const/constexpr; mutability is the exception| Rule | Summary | |------|---------| | P.1 | Express ideas directly in code | | P.3 | Express intent | | P.4 | Ideally, a program should be statically type safe | | P.5 | Prefer compile-time checking to run-time checking | | P.8 | Avoid leaking any resources | | P.10 | Prefer immutable data to mutable data | | I.1 | Make interfaces explicit | | I.2 | Avoid non-const global variables | | I.4 | Make interfaces precisely and strongly typed | | I.11 | Transfer ownership via smart pointers, not raw pointers or references | | I.23 | Keep the number of function arguments low |
See references/code-examples.md § Philosophy & Interfaces for examples.
| Rule | Summary |
|------|---------|
| F.1 | Package meaningful operations as carefully named functions |
| F.2 | A function should perform a single logical operation |
| F.3 | Keep functions short and simple |
| F.4 | If a function might be evaluated at compile time, declare it constexpr |
| F.6 | If your function must not throw, declare it noexcept |
| F.8 | Prefer pure functions |
| F.16 | For "in" parameters, pass cheaply-copied types by value and others by const& |
| F.20 | For "out" values, prefer return values to output parameters |
| F.21 | To return multiple "out" values, prefer returning a struct |
| F.43 | Avoid returning a pointer or reference to a local object |
Anti-patterns to avoid:
T&& from functions (F.45)va_arg / C-style variadics (F.55)const T which inhibits move semantics (F.49)See references/code-examples.md § Functions for parameter passing and constexpr examples.
| Rule | Summary |
|------|---------|
| C.2 | Use class if invariant exists; struct if data members vary independently |
| C.9 | Minimize exposure of members |
| C.20 | If you can avoid defining default operations, do (Rule of Zero) |
| C.21 | If you define or =delete any copy/move/destructor, handle them all (Rule of Five) |
| C.35 | Base class destructor: public virtual or protected non-virtual |
| C.41 | A constructor should create a fully initialized object |
| C.46 | Declare single-argument constructors explicit |
| C.67 | A polymorphic class should suppress public copy/move |
| C.128 | Virtual functions: specify exactly one of virtual, override, or final |
Anti-patterns to avoid:
memset/memcpy on non-trivial types (C.90)const or references, which suppresses move/copy (C.12)See references/code-examples.md § Classes for Rule of Zero, Rule of Five, and class hierarchy examples.
| Rule | Summary |
|------|---------|
| R.1 | Manage resources automatically using RAII |
| R.3 | A raw pointer (T*) is non-owning |
| R.5 | Prefer scoped objects; avoid heap-allocating unnecessarily |
| R.10 | Avoid malloc()/free() |
| R.11 | Avoid calling new and delete explicitly |
| R.20 | Use unique_ptr or shared_ptr to represent ownership |
| R.21 | Prefer unique_ptr over shared_ptr unless sharing ownership |
| R.22 | Use make_shared() to make shared_ptrs |
Anti-patterns to avoid:
new/delete (R.11)malloc()/free() in C++ code (R.10)shared_ptr where unique_ptr suffices (R.21)See references/code-examples.md § Resource Management for smart pointer and RAII examples.
| Rule | Summary |
|------|---------|
| ES.5 | Keep scopes small |
| ES.20 | Always initialize an object |
| ES.23 | Prefer {} initializer syntax |
| ES.25 | Declare objects const or constexpr unless modification is intended |
| ES.28 | Use lambdas for complex initialization of const variables |
| ES.45 | Avoid magic constants; use symbolic constants |
| ES.46 | Avoid narrowing/lossy arithmetic conversions |
| ES.47 | Use nullptr rather than 0 or NULL |
| ES.48 | Avoid casts |
| ES.50 | Avoid casting away const |
Anti-patterns to avoid:
0 or NULL as pointer (ES.47 — use nullptr)static_cast, const_cast, etc.)const (ES.50)See references/code-examples.md § Expressions & Statements for initialization examples.
| Rule | Summary |
|------|---------|
| E.1 | Develop an error-handling strategy early in a design |
| E.2 | Throw an exception to signal that a function can't perform its assigned task |
| E.6 | Use RAII to prevent leaks |
| E.12 | Use noexcept when throwing is impossible or unacceptable |
| E.14 | Use purpose-designed user-defined types as exceptions |
| E.15 | Throw by value, catch by reference |
| E.16 | Destructors, deallocation, and swap must not fail |
| E.17 | Avoid trying to catch every exception in every function |
Anti-patterns to avoid:
int or string literals (E.14)errno (E.28)See references/code-examples.md § Error Handling for exception hierarchy examples.
| Rule | Summary |
|------|---------|
| Con.1 | By default, make objects immutable |
| Con.2 | By default, make member functions const |
| Con.3 | By default, pass pointers and references to const |
| Con.4 | Use const for values that don't change after construction |
| Con.5 | Use constexpr for values computable at compile time |
See references/code-examples.md § Constants & Immutability for examples.
| Rule | Summary |
|------|---------|
| CP.2 | Avoid data races |
| CP.3 | Minimize explicit sharing of writable data |
| CP.4 | Think in terms of tasks, rather than threads |
| CP.8 | Avoid using volatile for synchronization |
| CP.20 | Use RAII, not plain lock()/unlock() |
| CP.21 | Use std::scoped_lock to acquire multiple mutexes |
| CP.22 | Avoid calling unknown code while holding a lock |
| CP.42 | Wait with a condition, not unconditionally |
| CP.44 | Name your lock_guards and unique_locks |
| CP.100 | Prefer higher-level concurrency over lock-free programming unless profiling demands it |
Anti-patterns to avoid:
volatile for synchronization (CP.8 — it's for hardware I/O only)std::lock_guard<std::mutex>(m); destroys immediately (CP.44)See references/code-examples.md § Concurrency for thread-safe queue and scoped_lock examples.
| Rule | Summary |
|------|---------|
| T.1 | Use templates to raise the level of abstraction |
| T.2 | Use templates to express algorithms for many argument types |
| T.10 | Specify concepts for all template arguments |
| T.11 | Use standard concepts whenever possible |
| T.13 | Prefer shorthand notation for simple concepts |
| T.43 | Prefer using over typedef |
| T.120 | Use template metaprogramming only when you really need to |
| T.144 | Overload function templates instead of specializing them |
Anti-patterns to avoid:
constexpr suffices (T.120)typedef instead of using (T.43)See references/code-examples.md § Templates for C++20 concepts examples.
| Rule | Summary |
|------|---------|
| SL.1 | Use libraries wherever possible |
| SL.2 | Prefer the standard library to other libraries |
| SL.con.1 | Prefer std::array or std::vector over C arrays |
| SL.con.2 | Prefer std::vector by default |
| SL.str.1 | Use std::string to own character sequences |
| SL.str.2 | Use std::string_view to refer to character sequences |
| SL.io.50 | Avoid endl (use '\n' — endl forces a flush) |
| Rule | Summary |
|------|---------|
| Enum.1 | Prefer enumerations over macros |
| Enum.3 | Prefer enum class over plain enum |
| Enum.5 | Avoid ALL_CAPS for enumerators |
| Enum.6 | Avoid unnamed enumerations |
| Rule | Summary |
|------|---------|
| SF.1 | Use .cpp for code files and .h for interface files |
| SF.7 | Avoid writing using namespace at global scope in a header |
| SF.8 | Use #include guards for all .h files |
| SF.11 | Header files should be self-contained |
| NL.5 | Avoid encoding type information in names (no Hungarian notation) |
| NL.8 | Use a consistent naming style |
| NL.9 | Use ALL_CAPS for macro names only |
| NL.10 | Prefer underscore_style names |
See references/code-examples.md § Source Files & Naming for header guard and naming convention examples.
| Rule | Summary | |------|---------| | Per.1 | Avoid optimizing without reason | | Per.2 | Avoid optimizing prematurely | | Per.6 | Avoid making claims about performance without measurements | | Per.7 | Design to enable optimization | | Per.10 | Rely on the static type system | | Per.11 | Move computation from run time to compile time | | Per.19 | Access memory predictably |
Anti-patterns to avoid:
Before marking C++ work complete:
new/delete — use smart pointers or RAII (R.11)const/constexpr by default (Con.1, ES.25)const where possible (Con.2)enum class instead of plain enum (Enum.3)nullptr instead of 0/NULL (ES.47)explicit (C.46)using namespace in headers at global scope (SF.7)scoped_lock/lock_guard) (CP.20)'\n' instead of std::endl (SL.io.50)development
Native Web UI structured renderer schemas for compose-block drafts, search-results cards, dataframe tables, chart-json charts, and diff output
tools
Unified search hub. Route any web/real-time/X lookup through a 4-tier escalation: built-in web search → cli-jaw browser CDP → progrok Grok OAuth → web-ai (Grok Expert / GPT Pro). Use for: search, 검색, web search, latest news, real-time info, X/Twitter, fact lookup, deep research.
development
UI/UX intent discovery, design vocabulary, product personalities, UX state patterns, typography line break judgment, favicon/product logo design, and logo trust section design. Use when user design direction is vague, when building onboarding/empty/error states, when setting up favicons or product logos, or when referencing a product aesthetic.
development
Canonical owner of module boundary rules, circular dependency detection/prevention, implicit coupling taxonomy, barrel/re-export discipline, and boundary-only defensive programming. Referenced by dev, dev-code-reviewer, dev-backend, dev-frontend stubs.