tylores/dotfiles/cpp-paradigms
Claude Code and agent skill by tylores/dotfiles
- community
Checking that the SKILL.md file is still in the repository.
Modern C++ (C++17/C++20/C++23) architecture, RAII resource safety, thread management, type safety, and CMake best practices. Use when reading, writing, or editing C++ files (*.cpp, *.hpp, *.cc, *.h, CMakeLists.txt).
Install
npx vskill@latest install tylores/dotfiles/cpp-paradigmsSKILL.md
The same SKILL.md was published earlier as tylores/dotfiles/cpp-paradigms.
C++ Paradigms & Context
This skill defines the rules, paradigms, and safety guardrails for writing and refactoring C++ code. The target is modern C++ (C++17/C++20/C++23), focusing on memory safety, resource management, performance, and clear API design.
All agents must adhere to these directives to prevent memory leaks, undefined behavior (UB), race conditions, and build system degradation.
Trigger Conditions
Activate this skill dynamically when reading, writing, or editing files matching:
- File extensions:
.cpp,.hpp,.cc,.h,.cxx,.ixx - Build files:
CMakeLists.txt,*.cmake - Key C++ include headers or keywords (e.g.,
#include <iostream>,#include <memory>,std::,class,template <)
Core Directives & Lifecycle Invariants
1. Resource Management (RAII)
- Strict Ownership: Every resource (memory, file descriptors, sockets, mutexes) must be owned by an RAII object.
- Smart Pointers over Raw Pointers:
- Use
std::unique_ptrfor exclusive ownership. Preferstd::make_unique<T>(). - Use
std::shared_ptrandstd::weak_ptrfor shared ownership. Preferstd::make_shared<T>(). - Raw pointers (
T*) are allowed ONLY as non-owning observers. They must never calldeleteor own the resource lifetime. - Rule of Zero/Three/Five:
- Prefer the Rule of Zero: design classes such that they don't need custom destructors, copy/move constructors, or copy/move assignment operators (by using standard components like
std::string,std::vector, smart pointers). - If a custom destructor is needed, explicitly declare or delete all five special member functions (Destructor, Copy Constructor, Copy Assignment, Move Constructor, Move Assignment).
2. Concurrency and Thread Safety
- Mutex Guarding: Always use
std::lock_guardorstd::unique_lockto manage mutex lifetimes. Never callmutex.lock()andmutex.unlock()manually. - Avoid Deadlocks: When acquiring multiple mutexes, use
std::lockor C++17std::scoped_lock. - Thread-Safe Data Structures: Ensure shared state is protected against concurrent read-write access. Prefer using standard synchronization primitives (
std::atomic,std::shared_mutex).
3. Modern Language Features & Type Safety
- Const Correctness: Make member functions
constif they do not modify state. Mark variablesconstorconstexprby default. - Auto Type Deduction: Use
autowhen the type is redundant, long, or returned by a factory/iterator. Ensure it doesn't obscure the code's readability. - Type-Safe Casts: Use
static_cast,const_cast,reinterpret_cast, ordynamic_cast. Never use C-style casts(Type)value. - Zero Initialization: Always initialize variables immediately upon declaration.
4. Build System (CMake) Integration
- Modern CMake (Target-Based): Use
target_link_libraries,target_include_directories, andtarget_compile_optionsinstead of directory-level commands (include_directories,link_libraries). - Warning Levels: Set compiler warning levels high (e.g.,
-Wall -Wextra -Wpedantic -Wconversion) and treat warnings as errors in CI/CD.
Hard Constraints & Banned Actions
- No Raw Memory Allocation: Never use
malloc,calloc,realloc, orfree. Never use rawnewordeleteunless writing custom low-level data structures (which must be wrapped in RAII classes). - No `using namespace std;` in Headers: Never use
using namespace std;(or any other namespace) in the global scope of header files. - No C-Style Arrays: Never use raw arrays (e.g.,
int arr[10];). Usestd::arrayorstd::vectorinstead. - No Raw C Strings: Avoid
char*andconst char*for string manipulation. Usestd::stringorstd::string_view(C++17) for read-only string parameters. - No Preprocessor Macros for Constants/Functions: Use
constexprorconstfor constants, andinlineorconstexprfunctions/templates instead of#definemacros. - No Undefined Behavior (UB): Avoid returning references or pointers to local/temporary variables, accessing out-of-bounds container indices, or dereferencing null pointers.
Verification & Triage Protocol
Before declaring a change or fix complete:
- Compile cleanly: Compile the project using the configured build tool (e.g.,
cmake --build build). Ensure zero warnings. - Run Clang-Tidy / Static Analysis: If available, run static analysis to check for guideline violations:
``bash clang-tidy -p build/ path/to/file.cpp ``
- Execute Unit Tests: Run the test suite (e.g.,
ctest --test-dir buildor direct executable invocation) to verify that no functional regressions were introduced. - Sanitizer Checks: If compiling with sanitizers (ASan, UBSan, TSan), run tests to ensure no memory leaks, buffer overflows, or data races are flagged.
Quick Reference / Cheat Sheet
Directive | Standard Pattern | Anti-Pattern --- | --- | --- Smart Allocation | auto ptr = std::make_unique<T>(); | T* ptr = new T(); Mutex Locking | std::scoped_lock lock(m1, m2); | m1.lock(); m2.lock(); Type Casting | static_cast<int>(val) | (int)val String Parameters | void print(std::string_view s) | void print(const char* s) Container Choice | std::array<int, 10> or std::vector<int> | int arr[10]; Header Namespace | Explicit namespace prefix std::string | using namespace std; in .hpp
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingbotfiles/.gemini/antigravity-cli/skills/cpp-paradigms/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/tylores/dotfiles/cpp-paradigms)