Agent skill

Cpp Idioms

by irahardianto in irahardianto/awesome-agv

Modern C++ (17/20/23) idioms: RAII, smart pointers, value semantics, Rule of Zero/Five, concepts, and std::expected error handling.

MITAuto-check passedDevelopment

Install Cpp Idioms

skills CLI
$ npx skills add irahardianto/awesome-agv --skill cpp-idioms -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install irahardianto/awesome-agv cpp-idioms --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/irahardianto/awesome-agv.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/cpp-idioms .claude/skills/cpp-idioms && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
cpp-idioms
GitHub stars
157
Token cost
~2.1k tokens
SKILL.md length
327 words
Files
1
Skills in repo
34
Repo updated
First seen
Licence
MIT

At a glance

Modern C++ (17/20/23) idioms: RAII, smart pointers, value semantics, Rule of Zero/Five, concepts, and std::expected error handling.

  • Works in 5 steps: RAII — resources tied to object… → std::unique_ptr for exclusive ownership,… → Move semantics — prefer moving over… → …
  • Reviewing C++ code
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Tasks that involve Error handling

What it does

Cpp Idioms is an agent skill from irahardianto/awesome-agv. Modern C++ (17/20/23) idioms: RAII, smart pointers, value semantics, Rule of Zero/Five, concepts, and std::expected error handling. Use when writing, refactoring, or reviewing C++ code, CMake targets, or native modules.

Its SKILL.md is about 2.1k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development, covering Error handling and Refactoring. It works with C++. The repository describes itself as: Comprehensive sets of standards and practices designed to elevate the capabilities of AI coding agents. The licence is MIT.

When your agent uses it

  • Reviewing C++ code
  • Tasks that involve Error handling
  • Tasks that involve Refactoring

Example prompts

  • “/cpp-idioms”

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  1. RAII — resources tied to object lifetime. No manual new/delete.
  2. std::unique_ptr for exclusive ownership, std::shared_ptr only when sharing is necessary.
  3. Move semantics — prefer moving over copying for expensive types.
  4. Rule of Five/Zero
  5. Pass by value and move for sink parameters

What it can do on your machine

Read from SKILL.md and the folder at commit 9e997ba. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are cpp).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Cpp Idioms loads about 2.1k tokens when it runs. Until then it costs about 58 tokens; SKILL.md has 327 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~58
When it runs · the whole SKILL.md, loaded when a task matches
~2.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from irahardianto/awesome-agv at commit 9e997ba, republished under its MIT licence (© irahardianto). 327 words, ~2,086 tokens.

Download SKILL.mdSave it as .claude/skills/cpp-idioms/SKILL.md (or your agent's skills folder).
name
cpp-idioms
description
Modern C++ (17/20/23) idioms: RAII, smart pointers, value semantics, Rule of Zero/Five, concepts, and std::expected error handling. Use when writing, refactoring, or reviewing C++ code, CMake targets, or native modules.

C++ Idioms and Patterns

Modern C++ (17/20/23) rewards RAII, value semantics, and zero-cost abstractions. Lean into the type system and smart pointers. Idiomatic C++ = safe, deterministic, performant.

Scope: C++ coding idioms. Test naming: .agents/rules/testing-strategy.md.

Ownership and Memory
  1. RAII — resources tied to object lifetime. No manual new/delete.

  2. std::unique_ptr for exclusive ownership, std::shared_ptr only when sharing is necessary.

  3. Move semantics — prefer moving over copying for expensive types.

  4. Rule of Five/Zero:

    cpp
    // ✅ Rule of Zero — let compiler-generated defaults work
    class TaskService {
        std::unique_ptr<TaskStorage> storage_;
        std::shared_ptr<Logger> logger_;
    public:
        // No destructor, copy/move constructors needed — smart pointers handle it
        explicit TaskService(std::unique_ptr<TaskStorage> storage, std::shared_ptr<Logger> logger)
            : storage_(std::move(storage)), logger_(std::move(logger)) {}
    };
    
    // ✅ Rule of Five — when managing raw resources (rare)
    class Buffer {
        char* data_;
        size_t size_;
    public:
        ~Buffer();                                   // Destructor
        Buffer(const Buffer&);                       // Copy constructor
        Buffer& operator=(const Buffer&);            // Copy assignment
        Buffer(Buffer&&) noexcept;                   // Move constructor
        Buffer& operator=(Buffer&&) noexcept;        // Move assignment
    };
  5. Pass by value and move for sink parameters:

    cpp
    // ✅ Sink parameter — takes ownership
    void addTask(Task task) {
        tasks_.push_back(std::move(task));
    }
    
    // ✅ Read-only — const reference
    void printTask(const Task& task);
    
    // ❌ Never pass smart pointers unless transferring ownership
    void processTask(std::shared_ptr<Task> task);  // Unnecessary ref-count bump
    
    // ✅ If function doesn't need ownership
    void processTask(const Task& task);
Error Handling

For universal error handling principles, see .agents/rules/error-handling-principles.md. Below: language-specific patterns only.

  1. std::expected (C++23) or Result types for expected failures:

    cpp
    // ✅ C++23 std::expected
    std::expected<Task, TaskError> getTask(std::string_view id) {
        auto it = tasks_.find(id);
        if (it == tasks_.end()) {
            return std::unexpected(TaskError::NotFound);
        }
        return it->second;
    }
    
    // Caller handles both paths
    auto result = getTask("123");
    if (!result) {
        handleError(result.error());
        return;
    }
    processTask(*result);
  2. Exceptions for exceptional conditions only. Never for control flow.

  3. noexcept on move constructors and destructors.

  4. Domain error types:

    cpp
    enum class TaskError {
        NotFound,
        ValidationFailed,
        StorageUnavailable,
    };
    
    // ✅ For exception-based paths
    class TaskNotFoundException : public std::runtime_error {
        std::string task_id_;
    public:
        explicit TaskNotFoundException(std::string id)
            : std::runtime_error("Task not found: " + id), task_id_(std::move(id)) {}
        const std::string& task_id() const noexcept { return task_id_; }
    };
Modern Features
  1. std::string_view for read-only string parameters (no allocation):

    cpp
    // ✅ Zero-copy string parameter
    void log(std::string_view message, std::string_view context);
    
    // ❌ Unnecessary copy
    void log(const std::string& message);
  2. constexpr for compile-time evaluation:

    cpp
    constexpr int maxRetries = 3;
    constexpr auto timeout = std::chrono::seconds(30);
    
    constexpr int factorial(int n) {
        return n <= 1 ? 1 : n * factorial(n - 1);
    }
  3. Structured bindings: auto [id, title] = getTask();

  4. std::optional for nullable values:

    cpp
    // ✅ Explicit nullability
    std::optional<Task> findById(std::string_view id);
    
    // Caller checks explicitly
    if (auto task = findById("123"); task.has_value()) {
        process(*task);
    }
  5. std::variant for type-safe unions (sum types):

    cpp
    using TaskResult = std::variant<Task, TaskError>;
    
    TaskResult result = getTask(id);
    std::visit(overloaded{
        [](const Task& task) { process(task); },
        [](TaskError err) { handleError(err); },
    }, result);
  6. Concepts (C++20) for constrained templates:

    cpp
    template<typename T>
    concept Storable = requires(T t) {
        { t.id() } -> std::convertible_to<std::string_view>;
        { t.serialize() } -> std::same_as<std::vector<char>>;
    };
    
    template<Storable T>
    void save(const T& entity);
  7. Ranges (C++20) for functional-style pipelines:

    cpp
    auto active_titles = tasks
        | std::views::filter([](const Task& t) { return t.is_active(); })
        | std::views::transform(&Task::title)
        | std::views::take(10);
Show full SKILL.md (175 more words)Show less
Interfaces and DI
cpp
// ✅ Interface (abstract class with pure virtuals)
class TaskStorage {
public:
    virtual ~TaskStorage() = default;
    virtual std::expected<Task, TaskError> getById(std::string_view id) = 0;
    virtual void save(const Task& task) = 0;
};

// ✅ Production implementation
class PostgresTaskStorage : public TaskStorage {
    // ...
};

// ✅ Test implementation
class MockTaskStorage : public TaskStorage {
    // MOCK_METHOD from Google Mock, or hand-rolled
};

// ✅ Constructor injection
class TaskService {
    std::unique_ptr<TaskStorage> storage_;
public:
    explicit TaskService(std::unique_ptr<TaskStorage> storage)
        : storage_(std::move(storage)) {}
};
Naming
  1. PascalCase for types. camelCase or snake_case for functions (project-consistent).
  2. _ suffix for private members: storage_, logger_.
  3. No Hungarian notation.
  4. ALL_CAPS only for macros — never for constants (use constexpr).
Anti-Patterns
  • ❌ Raw new/delete — use std::make_unique / std::make_shared
  • ❌ using namespace std; in headers — pollutes global namespace
  • ❌ Catching ... without re-throwing — swallows all errors including crashes
  • ❌ const_cast to remove constness — design flaw, fix the interface
  • ❌ reinterpret_cast without safety justification — undefined behavior risk
  • ❌ C-style casts (int)x — use static_cast<int>(x) for type safety
  • ❌ std::shared_ptr when std::unique_ptr suffices — unnecessary overhead
  • ❌ Copy-heavy loops without const auto&:
    cpp
    // ❌ Copies every Task
    for (auto task : tasks) { process(task); }
    
    // ✅ Reference — no copy
    for (const auto& task : tasks) { process(task); }
Testing

Google Test or Catch2. Google Mock for interface mocking.

cpp
// Google Test + Google Mock
TEST(TaskServiceTest, ReturnsNotFoundForMissingTask) {
    auto storage = std::make_unique<MockTaskStorage>();
    EXPECT_CALL(*storage, getById("999"))
        .WillOnce(Return(std::unexpected(TaskError::NotFound)));

    TaskService service(std::move(storage));
    auto result = service.getTask("999");

    EXPECT_FALSE(result.has_value());
    EXPECT_EQ(result.error(), TaskError::NotFound);
}
Formatting and Static Analysis
ToolPurposeCommand
clang-formatFormattingclang-format -i src/**/*.cpp
clang-tidyStatic analysisclang-tidy src/*.cpp --
cppcheckBug detectioncppcheck --enable=all src/
AddressSanitizerMemory errors-fsanitize=address
ThreadSanitizerRace conditions-fsanitize=thread
UBSanitizerUndefined behavior-fsanitize=undefined
  • Code Idioms and Conventions .agents/rules/code-idioms-and-conventions.md
  • Resources and Memory Management @.agents/rules/resources-and-memory-management-principles.md
  • Concurrency and Threading Principles @.agents/rules/concurrency-and-threading-principles.md
  • Error Handling Principles @.agents/rules/error-handling-principles.md

© irahardianto, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/cpp-idioms of irahardianto/awesome-agv.

Open the folder on GitHubat commit 9e997ba

Compare with similar skills

Cpp Idioms next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Cpp Idioms compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Cpp Idioms this skillirahardianto/awesome-agv157—~2.1kAutomated safety check: PassMIT
Rust Best Practicesfarm-fe/farm5.6k3 repos~1.1kAutomated safety check: PassMIT
SeekDB Code Reviewoceanbase/seekdb3.1k—~2.1kAutomated safety check: PassApache-2.0
Better Result Adoptnikivdev/ts820—~1.4kAutomated safety check: PassMIT
Embedded Cpp14 MisraBlueAndi/Pixelix443—~2kAutomated safety check: PassMIT
Ss Cpp ModernSerial-Studio/Serial-Studio7.2k—~1.6kAutomated safety check: PassCustom licence

Similar skills

  • Guide for writing idiomatic Rust code based on Apollo GraphQL's best practices handbook.

    5.6k GitHub starsUsed in 3 repos~1.1k tokens
    DevelopmentAuto-check passed
  • SeekDB Code Review

    oceanbase/seekdb

    Reviews seekdb pull requests and diffs for real defects in correctness, resources, concurrency, security and tests, reporting only Blocker or Major findings.

    3.1k GitHub stars~2.1k tokensUpdated today
    DevelopmentAuto-check passed
  • Migrate codebase from try/catch or Promise-based error handling to better-result.

    820 GitHub stars~1.4k tokensUpdated 7 mo ago
    DevelopmentAuto-check passed
  • Embedded Cpp14 Misra

    BlueAndi/Pixelix

    A skill your agent uses when writing, reviewing, or refactoring C/C++ firmware code in this repository (src/, lib/, test/) — creating or editing .h/.hpp/.cpp files, applying MISRA-oriented and…

    443 GitHub stars~2k tokensUpdated today
    DevelopmentAuto-check passed
  • Ss Cpp Modern

    Serial-Studio/Serial-Studio

    Modern C++20 authoring guidance for Serial Studio (Qt 6.11, C++20): concepts, ranges, move/RAII, std smart pointers, constexpr, lock-free SPSC atomics.

    7.2k GitHub stars~1.6k tokensUpdated today
    DevelopmentAuto-check passed
  • Cpp Pro

    Yikai-Liao/symusic

    Writes, optimizes, and debugs C++ applications using modern C++20/23 features, template metaprogramming, and high-performance systems techniques.

    189 GitHub starsUsed in 1 repo~1.1k tokens
    DevelopmentAuto-check passed

More from irahardianto/awesome-agv

All 34 skills in this repo
  • Distinctive Frontend Design Builder

    irahardianto/awesome-agv

    Commits to one bold aesthetic direction, sets up a CSS token system for it, then builds the interface in Vue or plain HTML using those tokens.

    157 GitHub stars~2.4k tokensUpdated 3 days ago
    Auto-check passed
  • Perf Optimization

    irahardianto/awesome-agv

    Profile-driven performance optimization protocol. An agent skill from irahardianto/awesome-agv.

    157 GitHub stars~4.3k tokensUpdated 3 days ago
    Auto-check passed
  • Angular Idioms and Patterns

    irahardianto/awesome-agv

    Coding conventions for Angular 19 and later: standalone components, signals, OnPush change detection, lazy routes and where RxJS still belongs.

    157 GitHub stars~3.8k tokensUpdated 3 days ago
    Auto-check passed
  • CI/CD Pipeline Principles

    irahardianto/awesome-agv

    Rules for designing CI/CD pipelines in layers: universal lint, test and scan stages, container builds with SBOM attestation, and GitOps for orchestrated deployments.

    157 GitHub stars~2.7k tokensUpdated 3 days ago
    Auto-check: notes
  • Hono Idioms

    irahardianto/awesome-agv

    Hono lightweight web framework patterns: type-safe route handlers, middleware composition, Zod validation, and RPC clients for Cloudflare Workers, Node, or Bun.

    157 GitHub stars~3k tokensUpdated 3 days ago
    Auto-check passed
  • Mobile Testing

    irahardianto/awesome-agv

    Mobile E2E testing patterns — Flutter integrationtest, Patrol, Maestro, golden testing, device matrix, and test data management.

    157 GitHub stars~1.8k tokensUpdated 3 days ago
    Auto-check: notes

Works with

Categories

Questions about Cpp Idioms

What does Cpp Idioms do?

Modern C++ (17/20/23) idioms: RAII, smart pointers, value semantics, Rule of Zero/Five, concepts, and std::expected error handling. Cpp Idioms is an agent skill from irahardianto/awesome-agv. Modern C++ (17/20/23) idioms: RAII, smart pointers, value semantics, Rule of Zero/Five, concepts, and std::expected error handling.

When should I use Cpp Idioms?

Cpp Idioms fits situations like: reviewing C++ code; tasks that involve Error handling; tasks that involve Refactoring.

How do I install Cpp Idioms in Claude Code?

Run `npx skills add irahardianto/awesome-agv --skill cpp-idioms -a claude-code`. Or copy the skill folder (.agents/skills/cpp-idioms in irahardianto/awesome-agv) into .claude/skills/cpp-idioms in your project. Claude Code loads it when a task matches its description.

How do I install Cpp Idioms in Codex?

Run `npx skills add irahardianto/awesome-agv --skill cpp-idioms -a codex`. Or copy the skill folder (.agents/skills/cpp-idioms in irahardianto/awesome-agv) into .agents/skills/cpp-idioms in your project. Codex loads it when a task matches its description.

Can I use Cpp Idioms in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add irahardianto/awesome-agv --skill cpp-idioms -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/cpp-idioms, .gemini/skills/cpp-idioms, .github/skills/cpp-idioms and .opencode/skills/cpp-idioms in your project.

What does Cpp Idioms need to run?

SKILL.md names no scripts, command-line tools or credentials: Cpp Idioms is instructions for the agent only.

Does Cpp Idioms access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Cpp Idioms safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Cpp Idioms use?

Cpp Idioms is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Cpp Idioms use?

About 2.1k tokens (SKILL.md is roughly 8.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Cpp Idioms?

Skills that share tags, products or a category with Cpp Idioms: Rust Best Practices (farm-fe/farm, 5.6k stars), SeekDB Code Review (oceanbase/seekdb, 3.1k stars), Better Result Adopt (nikivdev/ts, 820 stars) and Embedded Cpp14 Misra (BlueAndi/Pixelix, 443 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Cpp Idioms?

irahardianto (a GitHub user) maintains it in irahardianto/awesome-agv, which has 157 GitHub stars. The repository holds 34 skills in this directory. The repository was last updated on October 5, 2026.

Source: irahardianto/awesome-agv on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.