13eholder/modern-cpp-skills/m01-ownership

Claude Code and agent skill by 13eholder/modern-cpp-skills

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Mastering C++ Ownership: Move Semantics, RAII, and Reference Safety. Triggers: std::move, use-after-free, double-free, dangling pointer, copy elision, RVO, reference qualifiers.

Install

npx vskill@latest install 13eholder/modern-cpp-skills/m01-ownership

SKILL.md

The same SKILL.md was published earlier as 13eholder/modern-cpp-skills/m01-ownership.

C++ Ownership (Move Semantics & RAII)

Core Question

Who owns this resource, and does it need to move?

In C++, ownership is a discipline, not just a compiler check. You must decide:

  • Scope-bound? Use Stack (RAII).
  • Exclusive? Use std::unique_ptr.
  • Shared? Use std::shared_ptr.
  • View? Use T* or T& (non-owning).

Error → Design Question

Compiler/Sanitizer ErrorDesign Question
Double FreeWho owns this? Did you copy a raw pointer?
Use After FreeDid a reference outlive its owner?
Memory LeakWhere is the destructor called? (Did you use new?)
Object slicingWhy are you passing by value instead of pointer/reference?
Moved-from usageWhy are you touching a variable after std::move?

Thinking Prompt

  1. Does it need a heap allocation?
  • No? → Stack value (Rule of Zero).
  • Yes? → std::unique_ptr (Rule of Zero).
  • DO NOT write a destructor unless managing a non-RAII C handle.
  1. Is it a Transfer or a Copy?
  • Transfer? → std::move.
  • Copy? → Copy Constructor (or clone() pattern if polymorphic).
  1. Is this a View?
  • Yes? → std::string_view, std::span, or const T&.
  • Never pass std::shared_ptr unless transferring shared ownership.

Trace Up / Down

  • Trace Up (Diagnosing):
  • Error: "Segfault / Heap Corruption"
  • Ask: Is there a raw pointer (T*) managing a resource?
  • Fix: Wrap in unique_ptr or vector.
  • Trace Down (Implementing):
  • Intent: "I want to pass this big object to a function and never see it again."
  • Code: void consume(BigThing t); called with consume(std::move(thing));

Quick Reference

PatternCostUse When
Value (Stack)ZeroDefault choice. Small/Medium objects.
`unique_ptr`ZeroHeap needed. Exclusive ownership.
`shared_ptr`Atomic Inc/DecCyclic graph or true shared ownership.
`T&` (Ref)ZeroParameter passing (non-null).
`T*` (Ptr)ZeroParameter passing (nullable).
`std::move`ZeroTransferring ownership.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
12
Repository forks
1
7-day trend score
13

Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 23 Mar 2026, 8 months ago.

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
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/13eholder/modern-cpp-skills/m01-ownership/badge)](https://verified-skill.com/skills/13eholder/modern-cpp-skills/m01-ownership)

Something wrong with this skill or its page? Tell us.