Skip to main content
skill Claude Code CX Codex Cursor

memory-safety-patterns — Claude Code skill: install guide

This skill applies ownership, RAII, smart pointers, and resource management to Rust, C++, and C. Use it for systems code or memory-bug debugging.

Install into Claude Code · Plugin marketplace All methods and platforms ↓
/plugin marketplace add wshobson/agents
/plugin install systems-programming@claude-code-workflows
Open on GitHub

What memory-safety-patterns does

memory-safety-patterns covers ownership, object lifetimes, smart pointers, and RAII across Rust, C++, and C. It helps agents reason about use-after-free, double-free errors, leaks, buffer overflows, dangling pointers, and data races. The guidance also compares manual memory control with safer ownership models.

Detailed patterns are stored in references/details.md. The skill includes commands for AddressSanitizer, Valgrind, Rust Miri, and ThreadSanitizer, so you can connect the advice to a concrete debugging pass. In C++, it recommends limiting raw pointers; in Rust, it calls for care with unsafe. Install it when resource lifetime is part of the task; it adds little for code with no memory-management concerns.

What it helps with

  • stop use-after-free and double-free errors
  • tie file, socket, and memory lifetimes to scope
  • choose between manual control, smart pointers, and ownership
  • check for buffer overflows and data races
  • run AddressSanitizer, Valgrind, or Miri during debugging

Example prompts for the agent

  • Review this C++ code for use-after-free and rewrite it with RAII.
  • Compare resource ownership in these Rust and C modules.
  • Prepare commands to check this program with AddressSanitizer and Valgrind.

How to install memory-safety-patterns

1Plugin marketplace

/plugin marketplace add wshobson/agents
/plugin install systems-programming@claude-code-workflows

This installs the whole systems-programming plugin with all its skills

2Skills CLI (Vercel)

npx skills add wshobson/agents --skill memory-safety-patterns -a claude-code

3Manually: put the files in place

~/.claude/skills/memory-safety-patterns/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/memory-safety-patterns/

From the same set213

The whole set →
typescript-advanced-types Seth Hobson Guides an agent through advanced TypeScript types, from generics to conditional and mapped types. Use it for typed libraries, API clients, or strict configuration objects. Claude Code CX Codex Cursor 92,169installs tailwind-design-system Seth Hobson Helps build design systems with Tailwind CSS v4, from theme tokens to component variants. Use it when a project needs shared UI patterns. Claude Code CX Codex Cursor 70,180installs brand-landingpage Travis D. Elliott This skill interviews you about the product and its visual direction, then builds a landing page through Stitch. Use it when there’s no established design yet. Claude Code CX Codex Cursor 39,476installs python-testing-patterns Seth Hobson This skill guides Python testing with pytest, fixtures and mocks. Use it when building a test suite or tracking down failing checks. Claude Code CX Codex Cursor 36,943installs python-performance-optimization Seth Hobson This skill profiles Python code to locate CPU and memory bottlenecks. Use it when an application responds slowly or consumes too many resources. Claude Code CX Codex Cursor 35,675installs nextjs-app-router-patterns Seth Hobson This skill covers Next.js App Router patterns for rendering, routing, and data fetching. Use it when starting an App Router project or moving from Pages Router. Claude Code CX Codex Cursor 32,529installs api-design-principles Seth Hobson Use this skill to plan or review REST and GraphQL APIs. It helps when writing a specification or setting API conventions for a team. Claude Code CX Codex Cursor 30,348installs code-review-excellence Seth Hobson This skill guides pull request reviews, catches logic and security issues, and helps teams give specific feedback. Use it for review standards or developer mentoring. Claude Code CX Codex Cursor 30,193installs

Similar

cmux-architecture manaflow-ai Guides modular Swift package architecture, strict 5-layer dependency inversion, and Swift 6 concurrency rules in the cmux codebase. Claude Code CX Codex Cursor +1 4,800installs typescript-pro https://github.com/Jeffallan Implements advanced TypeScript type systems, branded types, and tRPC configurations. Use it when building type-first APIs or complex discriminated unions. Claude Code CX Codex Cursor +1 14,200installs developing-genkit-python official google A skill for building Genkit apps in Python: generation, streaming, tools, flows and agents. Useful when your agent fumbles imports or Genkit API calls. Claude Code Gemini CLI CX Codex 3,600installs migrate-to-shoehorn Matt Pocock Replaces as type assertions in tests with helpers from @total-typescript/shoehorn. Use it when tests need partial objects or deliberately invalid data. Claude Code 475,388installs write-swift emilkowalski This skill guides Swift coding, reviews, and migrations using the language’s current practices. Use it to investigate concurrency errors, hangs, data races, or retain cycles. Claude Code CX Codex Cursor +1 117,500installs megacave JuliusBrussee Switches agent responses to Classical Chinese (wenyan) to reduce terminal output. Activated via /megacave or /caveman wenyan. Claude Code CX Codex Cursor +1 24,400installs find-docs upstash Pulls up-to-date documentation, API references and code examples for any library through the Context7 CLI. Useful when the model's training data lags behind the API. Claude Code CX Codex Cursor +1 9,400installs smart-explore thedotmack Uses tree-sitter to map code structure and find symbols. Useful when you need to explore a codebase without loading every full file. Claude Code CX Codex Cursor +1 7,300installs

Questions about memory-safety-patterns

How do I install memory-safety-patterns in Claude Code?

Run npx skills add wshobson/agents --skill memory-safety-patterns -a claude-code. The skill file is placed at ~/.claude/skills/memory-safety-patterns/SKILL.md.

What does memory-safety-patterns do?

It guides memory-safe programming with RAII, ownership, and smart pointers in Rust, C++, and C. It also covers ways to diagnose leaks, freed-memory access, and related bugs.

Which languages does memory-safety-patterns cover?

The skill covers Rust, C++, and C. Its debugging examples use AddressSanitizer, Valgrind, Rust Miri, and ThreadSanitizer.

Source text

SKILL.md · MIT
---
name: memory-safety-patterns
description: Implement memory-safe programming with RAII, ownership, smart pointers, and resource management across Rust, C++, and C. Use when writing safe systems code, managing resources, or preventing memory bugs.
---

# Memory Safety Patterns

Cross-language patterns for memory-safe programming including RAII, ownership, smart pointers, and resource management.

## When to Use This Skill

- Writing memory-safe systems code
- Managing resources (files, sockets, memory)
- Preventing use-after-free and leaks
- Implementing RAII patterns
- Choosing between languages for safety
- Debugging memory issues

## Core Concepts

### 1. Memory Bug Categories

| Bug Type             | Description                      | Prevention        |
| -------------------- | -------------------------------- | ----------------- |
| **Use-after-free**   | Access freed memory              | Ownership, RAII   |
| **Double-free**      | Free same memory twice           | Smart pointers    |
| **Memory leak**      | Never free memory                | RAII, GC          |
| **Buffer overflow**  | Write past buffer end            | Bounds checking   |
| **Dangling pointer** | Pointer to freed memory          | Lifetime tracking |
| **Data race**        | Concurrent unsynchronized access | Ownership, Sync   |

### 2. Safety Spectrum

```
Manual (C) → Smart Pointers (C++) → Ownership (Rust) → GC (Go, Java)
Less safe                                              More safe
More control                                           Less control
```

## Detailed patterns and worked examples

Detailed pattern documentation lives in `references/details.md`. Read that file when the navigation tier above is insufficient.

## Best Practices

### Do's

- **Prefer RAII** - Tie resource lifetime to scope
- **Use smart pointers** - Avoid raw pointers in C++
- **Understand ownership** - Know who owns what
- **Check bounds** - Use safe access methods
- **Use tools** - AddressSanitizer, Valgrind, Miri

### Don'ts

- **Don't use raw pointers** - Unless interfacing with C
- **Don't return local references** - Dangling pointer
- **Don't ignore compiler warnings** - They catch bugs
- **Don't use `unsafe` carelessly** - In Rust, minimize it
- **Don't assume thread safety** - Be explicit

## Debugging Tools

```bash
# AddressSanitizer (Clang/GCC)
clang++ -fsanitize=address -g source.cpp

# Valgrind
valgrind --leak-check=full ./program

# Rust Miri (undefined behavior detector)
cargo +nightly miri run

# ThreadSanitizer
clang++ -fsanitize=thread -g source.cpp
```

© Seth Hobson · MIT · wshobson/agents

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor