wshobson avatar

Memory Safety Patterns

This one bridges the gap between C's manual memory management and Rust's compile-time guarantees by showing you the actual patterns that prevent use-after-free bugs, double-frees, and memory leaks across all three languages. It covers RAII destructors in C++, Rust's ownership system with borrowing rules, smart pointers like unique_ptr and shared_ptr, and even defensive patterns for C like goto cleanup. What I like is that it doesn't just show syntax but explains the tradeoffs between safety and control, plus it includes concrete examples of breaking reference cycles and handling interior mutability. Great for systems programmers who need to write bulletproof resource management code.

install copies · 90 days. Times the install command was copied on this site in the last 90 days, bots filtered.
5
skills.sh installs
12.2K
GitHub stars
42.4K
last updated
Aug 21, 2026

Install

$ npx -y skills add wshobson/agents --skill memory-safety-patterns --agent claude-code

Installs into .claude/skills of the current project.

Files

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 TypeDescriptionPrevention
Use-after-freeAccess freed memoryOwnership, RAII
Double-freeFree same memory twiceSmart pointers
Memory leakNever free memoryRAII, GC
Buffer overflowWrite past buffer endBounds checking
Dangling pointerPointer to freed memoryLifetime tracking
Data raceConcurrent unsynchronized accessOwnership, Sync

2. Safety Spectrum

Sponsors

Details

Repository
github.com/wshobson/agents
Categories
Documentation, Rust

More from wshobson/agents

All 174
1sveltejs avatarsvelte-core-bestpracticessveltejs/ai-toolsGuidance on writing fast, robust, modern Svelte code. Load this skill whenever in a Svelte project and asked to write/edit or analyze a Svelte component or modu12.1Kskills.sh installs
2tavily-ai avatarsearchtavily-ai/skillsSearch the web using Tavily's LLM-optimized search API. Returns relevant results with content snippets, scores, and metadata. Use when you need to find web cont11.9Kskills.sh installs
3wshobson avatarbats-testing-patternswshobson/agentsMaster Bash Automated Testing System (Bats) for comprehensive shell script testing. Use when writing tests for shell scripts, CI/CD pipelines, or requiring test11.4Kskills.sh installs
4wshobson avatardbt-transformation-patternswshobson/agentsMaster dbt (data build tool) for analytics engineering with model organization, testing, documentation, and incremental strategies. Use when building data trans11.3Kskills.sh installs
5intellectronica avatarcontext7intellectronica/agent-skillsRetrieve up-to-date documentation for software libraries, frameworks, and components via the Context7 API. This skill should be used when looking up documentati11.3Kskills.sh installs
6earthtojake avatarsendcutsendearthtojake/text-to-cadReview DXF and STEP/STP uploads for SendCutSend.com orders using its ordering guide, catalog, and specs. Use only for SendCutSend.com preflight reports covering11.2Kskills.sh installs