About cpp
cpp is a skill with C++ coding guidance focused on smart pointers, RAII, and modern language patterns. It also provides a decision guide for standard library types and example build commands.
Key features
- 01Smart-pointer ownership guidance
- 02RAII-based resource management
- 03Modern C++ patterns
- 04Decision guide for standard types
- 05g++、clang++、and CMake commands
Use cases
- 01Choosing a pointer for ownership needs
- 02Managing resources with RAII
- 03Building a C++ project with provided commands
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ odjaramillo/ custom-rules --skill cppAfter installing, type/cppin Claude Code to confirm it loaded.
Details
From the project READMECritical Patterns
Smart Pointers (REQUIRED)
// ✅ ALWAYS: Use smart pointers
auto user = std::make_unique<User>("John");
auto shared = std::make_shared<Config>();
// ❌ NEVER: Raw new/delete
User* user = new User("John");
delete user;
RAII (REQUIRED)
// ✅ ALWAYS: Resource management through constructors/destructors
class FileHandle {
std::fstream file_;
public:
FileHandle(const std::string& path) : file_(path) {}
~FileHandle() { if (file_.is_open()) file_.close(); }
};
Modern Patterns (REQUIRED)
// ✅ Use auto for type deduction
auto items = std::vector<int>{1, 2, 3};
// ✅ Use range-based for loops
for (const auto& item : items) {
process(item);
}
// ✅ Use structured bindings
auto [name, age] = getPerson();
Decision Tree
Need unique ownership? → std::unique_ptr
Need shared ownership? → std::shared_ptr
Need optional value? → std::optional
Need multiple types? → std::variant
Need string views? → std::string_view
Commands
g++ -std=c++20 -Wall -Wextra main.cpp -o app
clang++ -std=c++20 main.cpp -o app
cmake -B build && cmake --build build
Comments
Markdown supported