
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-codeInstalls 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 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
Sponsors
Details
- Repository
- github.com/wshobson/agents
- Categories
- Documentation, Rust
More from wshobson/agents
All 174- Gitops Workflow12.1K
- Python Observability12K
- Shellcheck Configuration12K
- Python Configuration12K
- Cost Optimization11.9K
- Embedding Strategies11.8K
- Data Quality Frameworks11.7K
- Startup Metrics Framework11.7K
- Go Concurrency Patterns11.7K
- Prometheus Configuration11.6K
- Billing Automation11.6K
- K8s Manifest Generator11.6K
- Python Background Jobs11.6K
- Ml Pipeline Workflow11.5K
- Context Driven Development11.5K
- Dependency Upgrade11.5K
- Competitive Landscape11.5K
- Bats Testing Patterns11.4K
- Memory Forensics11.4K
- Risk Metrics Calculation11.4K
- Python Resource Management11.4K
- Binary Analysis Patterns11.4K
- Cqrs Implementation11.4K
- Workflow Patterns11.4K