cpp-rules

Solid

C++ coding rules: style, patterns, security, testing. Triggers: .cpp, .cc, .cxx, .hpp, .h, CMakeLists.txt, Makefile, GoogleTest, clang-tidy.

AI & Automation 155 stars 19 forks Updated 2 days ago MIT

Install

View on GitHub

Quality Score: 93/100

Stars 20%
73
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

# C++ Rules These rules come from `app/rules/cpp/` in ai-toolkit. They cover the project's standards for coding style, frameworks, patterns, security, and testing in C++. Apply them when writing or reviewing C++ code. # C++ Coding Style ## Naming - PascalCase: classes, structs, enums, type aliases, concepts. - camelCase or snake_case: functions, methods, variables (be consistent per project). - UPPER_SNAKE: macros, compile-time constants. - Prefix member variables with `m_` or suffix with `_` (pick one convention). - Namespace names: lowercase, short (`namespace io`, `namespace util`). ## Modern C++ (17/20/23) - Use `auto` for iterator types and complex template deductions. - Use `std::optional<T>` instead of sentinel values or pointers for optional returns. - Use `std::variant` over union types. Use `std::visit` for dispatch. - Use `std::string_view` for non-owning string parameters. - Use structured bindings: `auto [key, value] = *map.begin();`. - Use `constexpr` for compile-time evaluation. Prefer over macros. ## Memory Management - Use RAII exclusively. Every resource acquisition is an initialization. - Use `std::unique_ptr` for exclusive ownership (default choice). - Use `std::shared_ptr` only when ownership is genuinely shared. - Never use raw `new`/`delete`. Use `std::make_unique` / `std::make_shared`. - Use `std::span<T>` (C++20) for non-owning views over contiguous data. ## Functions - Pass small types by value. Pass large types by `const&`. - Use `[[nodiscard]...

Details

Author
softspark
Repository
softspark/ai-toolkit
Created
2 months ago
Last Updated
2 days ago
Language
Python
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category