m02-resource

Community

Manage C++ ownership with smart pointers

Author13eholder
Version1.0.0
Installs0

System Documentation

What problem does it solve?

This Skill helps prevent memory leaks, double frees, and ownership confusion in C++ by guiding the correct selection and usage of smart pointers and custom deleters across common code patterns.

Core Features & Use Cases

  • Ownership guidance: Choose between sole ownership with std::unique_ptr, shared ownership with std::shared_ptr, and observer semantics with std::weak_ptr.
  • Cycle detection and resolution: Identify shared_ptr cycles and recommend breaking them with weak_ptr or redesigning ownership.
  • Interoperability and cleanup: Recommend make_unique and make_shared for safe allocation and advise on custom deleters for C APIs and resource wrappers.
  • Practical examples: Patterns include heterogeneous collections using vector of std::unique_ptr<Base>, parent-child graphs with parent as weak_ptr, and using enable_shared_from_this when objects need shared_from_this.

Quick Start

Ask the skill to recommend the appropriate smart pointer for each class relationship, detect potential cycles, and suggest fixes including custom deleter designs when needed.

Dependency Matrix

Required Modules

None required

Components

Standard package

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: m02-resource
Download link: https://github.com/13eholder/Modern-Cpp-Skills/archive/main.zip#m02-resource

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 223,000+ vetted skills library on demand.