m01-ownership/SKILL.md
Mastering C++ Ownership: Move Semantics, RAII, and Reference Safety. Triggers: std::move, use-after-free, double-free, dangling pointer, copy elision, RVO, reference qualifiers.
npx skillsauth add 13eholder/modern-cpp-skills m01-ownershipInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Who owns this resource, and does it need to move?
In C++, ownership is a discipline, not just a compiler check. You must decide:
std::unique_ptr.std::shared_ptr.T* or T& (non-owning).| Compiler/Sanitizer Error | Design Question |
| ------------------------ | ---------------------------------------------------------- |
| Double Free | Who owns this? Did you copy a raw pointer? |
| Use After Free | Did a reference outlive its owner? |
| Memory Leak | Where is the destructor called? (Did you use new?) |
| Object slicing | Why are you passing by value instead of pointer/reference? |
| Moved-from usage | Why are you touching a variable after std::move? |
Does it need a heap allocation?
std::unique_ptr (Rule of Zero).Is it a Transfer or a Copy?
std::move.clone() pattern if polymorphic).Is this a View?
std::string_view, std::span, or const T&.std::shared_ptr unless transferring shared ownership.Trace Up (Diagnosing):
T*) managing a resource?unique_ptr or vector.Trace Down (Implementing):
void consume(BigThing t); called with consume(std::move(thing));| Pattern | Cost | Use When |
| ----------------- | -------------- | -------------------------------------- |
| Value (Stack) | Zero | Default choice. Small/Medium objects. |
| unique_ptr | Zero | Heap needed. Exclusive ownership. |
| shared_ptr | Atomic Inc/Dec | Cyclic graph or true shared ownership. |
| T& (Ref) | Zero | Parameter passing (non-null). |
| T* (Ptr) | Zero | Parameter passing (nullable). |
| std::move | Zero | Transferring ownership. |
tools
Common C++ Anti-Patterns. Triggers: global variables, new/delete, C-style cast, macros, void*.
data-ai
C++ Mental Models: Pointer vs Reference, Initialization, Undefined Behavior.
data-ai
Mastering C++ Domain Errors: Exception Hierarchies, System Errors, and Expected.
data-ai
Mastering C++ Lifecycle: RAII, Destructors, Static Initialization, Rule of 5.