agentsclimarketplace

Cpp coding

Skill nguyenthdat/opencode-manager/registry/skills/cpp-coding

Project-scoped OpenCode TUI plugin for grouping and managing MCP servers, custom agent skills, and pinned vendor skill registries.

Install
npx -y skills add nguyenthdat/opencode-manager --skill cpp-coding

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • 13 days oldThe repository was created 13 days ago. New is not bad, but a brand new repository carrying a familiar-sounding name is the shape a typosquat arrives in, and there has been no time for anyone else to find a problem with it.
  • 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Comprehensive idiomatic modern C++ guidance: 176 prioritized rules across 15 categories covering RAII, smart pointers, memory safety, templates, concurrency, and performance. Use when writing, reviewing, refactoring, or optimizing C++ (`.cpp`, `.cc`, `.cxx`, `.hpp`, `.h`, `.hh`, `CMakeLists.txt`). Targets C++17/20/23; prefer the project's declared standard version and only apply concepts/ranges/coroutines/modules/`std::expected` when the project's compiler and `CMAKE_CXX_STANDARD` actually support them.

SKILL.md

28.5 KB, as published. Nobody here has run it

C++ Best Practices

Comprehensive guide for writing high-quality, idiomatic modern C++. Contains 176 rules across 15 categories, prioritized by impact. Project constraints override generic defaults: preserve the declared CMAKE_CXX_STANDARD/-std= flag, compiler support matrix, and existing memory-management conventions unless the user explicitly requests a modernization pass.

This skill is for idiomatic modern C++ — RAII, smart pointers, templates, the STL, exceptions/std::expected. For plain C code (manual memory management, no classes/templates/exceptions, C ABI), use the sibling c-coding skill instead. Do not apply C++-only idioms (RAII, unique_ptr, templates, exceptions) to a .c file, and do not apply C-style manual memory management to idiomatic C++.

When to Apply

Reference these guidelines when:

  • Writing new C++ classes, functions, or headers
  • Choosing between unique_ptr, shared_ptr, raw pointers, and references
  • Implementing error handling (exceptions, std::expected, error codes)
  • Designing public APIs for a library or shared object
  • Reviewing code for ownership, lifetime, or memory-safety issues
  • Writing template or generic code, or migrating SFINAE to concepts
  • Writing or reviewing concurrent code (threads, atomics, coroutines)
  • Optimizing hot paths or reducing allocations
  • Setting up CMakeLists.txt, .clang-tidy, or CI sanitizer builds

Modern C++ (C++17 / C++20 / C++23)

Preserve the project's declared standard (CMAKE_CXX_STANDARD, -std=c++XX) and compiler baseline unless migration is explicitly in scope. For new projects, prefer at minimum C++17 for structured bindings and if constexpr, and C++20 where the toolchain (GCC 10+, Clang 14+, MSVC 19.29+) reliably supports it.

C++17 — genuinely current baseline:

  • Structured bindings (auto [it, ok] = map.insert(...)) instead of .first/.second
  • if constexpr for compile-time branching without SFINAE tricks
  • std::optional<T>, std::variant<T...>, std::any for absence/sum-types/type-erasure
  • std::string_view for non-owning string parameters
  • Class template argument deduction (CTAD) — std::vector v{1, 2, 3}; needs no <int>
  • std::filesystem for portable path/file operations
  • [[nodiscard]], [[maybe_unused]], [[fallthrough]] attributes

C++20 — adopt where the toolchain supports it:

  • Concepts (std::integral, std::invocable, user-defined requires clauses) instead of enable_if/SFINAE
  • Ranges (std::ranges::sort, views, pipe composition) instead of iterator-pair algorithms
  • Coroutines (co_await/co_yield/co_return) for structured async code
  • std::span<T> for bounds-aware, non-owning views over contiguous data
  • std::jthread (auto-joining, cooperatively cancellable thread)
  • Modules (import/export module) — adopt only after confirming build-system maturity (CMake 3.28+, compiler support); header/#include remains the safe default otherwise
  • Three-way comparison (operator<=>) to replace hand-written relational operator sets
  • Designated initializers, std::atomic_ref, std::format (or {fmt} as the pre-standard equivalent)

C++23 — use only when the project's toolchain is confirmed current enough:

  • std::expected<T, E> for explicit, allocation-free error returns as an alternative to exceptions
  • Deducing this (explicit object parameters) to de-duplicate const/non-const and ref-qualified overloads
  • std::mdspan for multi-dimensional array views
  • if consteval for compile-time-vs-runtime branching
  • std::ranges::to for materializing ranges into containers

For the authoritative, evolving detail, consult the C++ Core Guidelines and cppreference.com's per-standard feature pages. Everything below applies across C++17/20/23; prefer the newer forms above where the project's standard version allows.

Rule Categories by Priority

PriorityCategoryImpactPrefixRules
1RAII & Resource ManagementCRITICALraii-12
2Smart Pointers & OwnershipCRITICALown-13
3Memory SafetyCRITICALmem-14
4Error HandlingCRITICALerr-13
5Templates & Generic ProgrammingHIGHtmpl-12
6API DesignHIGHapi-14
7ConcurrencyHIGHconc-14
8Naming ConventionsMEDIUMname-10
9Type SafetyMEDIUMtype-11
10TestingMEDIUMtest-10
11DocumentationMEDIUMdoc-8
12Performance PatternsMEDIUMperf-12
13Project StructureLOWproj-9
14Linting & Static AnalysisLOWlint-9
15Anti-patternsREFERENCEanti-15

Quick Reference

1. RAII & Resource Management (CRITICAL)

2. Smart Pointers & Ownership (CRITICAL)

3. Memory Safety (CRITICAL)

4. Error Handling (CRITICAL)

5. Templates & Generic Programming (HIGH)

6. API Design (HIGH)

7. Concurrency (HIGH)

8. Naming Conventions (MEDIUM)

9. Type Safety (MEDIUM)

10. Testing (MEDIUM)

11. Documentation (MEDIUM)

12. Performance Patterns (MEDIUM)

13. Project Structure (LOW)

14. Linting & Static Analysis (LOW)

15. Anti-patterns (REFERENCE)


Recommended Tooling & Config

CMakeLists.txt warnings and sanitizers

add_library(myproject_warnings INTERFACE)
target_compile_options(myproject_warnings INTERFACE
  $<$<CXX_COMPILER_ID:GNU,Clang>:-Wall -Wextra -Wpedantic -Wshadow
    -Wconversion -Wsign-conversion -Wnon-virtual-dtor -Wold-style-cast
    -Woverloaded-virtual -Wnull-dereference -Wdouble-promotion
    -Werror>
  $<$<CXX_COMPILER_ID:MSVC>:/W4 /permissive- /WX>
)

option(ENABLE_SANITIZERS "Build with ASan+UBSan" OFF)
if(ENABLE_SANITIZERS)
  add_compile_options(-fsanitize=address,undefined -fno-omit-frame-pointer)
  add_link_options(-fsanitize=address,undefined)
endif()

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

target_link_libraries(my_target PRIVATE myproject_warnings)

.clang-tidy

Checks: >
  -*,
  bugprone-*,
  clang-analyzer-*,
  cppcoreguidelines-*,
  -cppcoreguidelines-avoid-magic-numbers,
  modernize-*,
  -modernize-use-trailing-return-type,
  performance-*,
  portability-*,
  readability-*,
  -readability-magic-numbers,
  -readability-identifier-length

WarningsAsErrors: 'bugprone-*,clang-analyzer-*,cppcoreguidelines-slicing'
HeaderFilterRegex: '^(include|src)/'
FormatStyle: file

How to Use

This skill provides rule identifiers for quick reference. When generating or reviewing C++ code:

  1. Check relevant category based on task type
  2. Apply rules with matching prefix
  3. Prioritize CRITICAL > HIGH > MEDIUM > LOW
  4. Read rule files in rules/ for detailed examples

Rule Application by Task

TaskPrimary Categories
New class/structraii-, own-, api-
New free functionerr-, name-, type-
Ownership/lifetime reviewown-, mem-, raii-
Error handlingerr-, api-
Generic/template codetmpl-, type-
Concurrent codeconc-, own-, mem-
Performance tuningperf-, mem-, conc-
Code reviewanti-, lint-

Related Skills

  • design-patterns - choosing and implementing GoF and idiomatic design patterns (also covers C++: RAII-based patterns, CRTP, PIMPL).
  • security-review - security-audit checklists (memory safety, integer overflow, injection, concurrency hazards) for reviewing/auditing C++.
  • c-coding - sibling skill for plain C (manual memory management, no classes/templates/exceptions, C ABI). Use cpp-coding for idiomatic modern C++ with RAII, smart pointers, templates, and the STL; use c-coding when the codebase is C or a C-compatible subset.

Sources

This skill synthesizes best practices from:

  • C++ Core Guidelines (Stroustrup/Sutter)
  • Effective Modern C++ by Scott Meyers
  • cppreference.com per-standard feature documentation
  • CERT C++ Coding Standard
  • Production codebases: LLVM, Chromium, Abseil, Folly
  • clang-tidy / cppcoreguidelines-* and modernize-* check documentation
  • Community conventions (2024-2026)

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.