cpp-core-guidelines

C++ Core Guidelines by Stroustrup and Sutter for writing modern, safe, and efficient C++ code. Use when writing, reviewing, or refactoring C++ code to ensure type safety, resource safety, and performance. Triggers on C++ code tasks including interface design, resource management (memory, handles, locks), class design, error handling, concurrency, templates, and general code review. Use for questions like "review this C++ code", "how should I manage resources in C++", "best practices for C++ interfaces", or when writing any C++ code that should follow modern standards (C++11/14/17/20).

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "cpp-core-guidelines" with this command: npx skills add ariaszzzhc/cpp-core-guidelines/ariaszzzhc-cpp-core-guidelines-cpp-core-guidelines

C++ Core Guidelines

Overview

These guidelines help write C++ code that is:

  • Type-safe: No implicit violations of the type system
  • Resource-safe: No leaks (memory, handles, locks, etc.)
  • Performant: Efficient without sacrificing correctness
  • Correct: Catches more logic errors at compile time

Load Reference by Scenario

Choose the reference file based on what you're doing:

ScenarioReference FileRules
Checking memory leaks, RAII, pointersmemory-safety.mdR., ES., Con.*
Designing function signatures, APIsapi-design.mdI., F.
Designing or reviewing classesclass-design.mdC.*
Thread safety, data races, locksconcurrency.mdCP.*
Exceptions, error codes, error handlingerror-handling.mdE.*
Templates, STL, generic codetemplates.mdT., SL., Enum.*
Coding style, naming, philosophymodern-style.mdP., NL., SF.*
Performance optimization, C compatibilityperformance.mdPer., CPL., A.*

Quick Reference

Memory Safety

// Bad: manual management
X* p = new X;
delete p;

// Good: RAII
auto p = make_unique<X>();

API Design

// Bad: unclear ownership
void process(int* data, int n);

// Good: explicit ownership and size
void process(span<const int> data);

Class Design

// Rule of zero - let compiler generate
class Widget {
    unique_ptr<Impl> pImpl;  // No explicit dtor/copy/move needed
};

Concurrency

// Bad: manual lock
mutex mtx;
mtx.lock();
// ...
mtx.unlock();

// Good: RAII lock
lock_guard<mutex> lock(mtx);

Code Review Checklist

When reviewing C++ code, load the appropriate reference and check:

Memory Safetymemory-safety.md

  • No raw new/delete
  • RAII for all resources
  • No dangling pointers
  • Proper const usage

API Designapi-design.md

  • Interfaces are explicit
  • Parameters express ownership
  • Return values over output params

Class Designclass-design.md

  • Class has clear invariant
  • Rule of zero/five followed
  • Virtual destructor for base classes

Thread Safetyconcurrency.md

  • No data races
  • lock_guard/scoped_lock used
  • No deadlocks

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

gog

Google Workspace CLI for Gmail, Calendar, Drive, Contacts, Sheets, and Docs.

Archived SourceRecently Updated
Coding

obsidian-notes

Work with Obsidian vaults (plain Markdown notes) and automate via obsidian-cli.

Archived SourceRecently Updated
Coding

mcporter-cli

Use the mcporter CLI to list, configure, auth, and call MCP servers/tools directly (HTTP or stdio), including ad-hoc servers, config edits, and CLI/type generation.

Archived SourceRecently Updated
Coding

github-tools

Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.

Archived SourceRecently Updated