# Build Safer Systems with Memory Safety Patterns

Memory errors and unsafe resource ownership can cause crashes, leaks, and data races. This skill applies proven patterns across C, C++, and Rust.

## Install

```bash
npx skillstore add sickn33/memory-safety-patterns
```

## Metadata

- Status: approved
- Slug: sickn33-memory-safety-patterns
- Skillstore revision: r2
- Version status: missing
- Tree hash: 69584b5aa65d8d9a52f4d6e1dca1105118c8975164451c28528c6312991a5c6e
- Author: sickn33
- GitHub username: sickn33
- License: MIT
- Repository: https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/memory-safety-patterns
- Ref: 81e05e636292629114b76cbb3922fbe57672fc02
- Supported tools: Claude, Codex, Claude Code
- Audit status: complete
- Agent install advisory: allowed
- Manual install advisory: allowed
- Artifact signature: available
- Audit attestation: unavailable
- Human verification: not\_verified
- Risk factors: external\_commands, filesystem
- Quality score: 78
- Quality tier: bronze
- Public page: https://skillstore.pages.dev/skills/sickn33-memory-safety-patterns
- Manifest: https://skillstore.pages.dev/api/skills/sickn33-memory-safety-patterns/manifest

## Capabilities

- Explains RAII patterns for files, mutexes, and transactional rollback in C\+\+.
- Compares unique, shared, and weak pointer ownership models.
- Demonstrates Rust ownership, borrowing, lifetimes, and synchronized sharing.
- Shows structured cleanup patterns for manually managed C resources.
- Reviews bounds checking and data race prevention approaches.

## Use Cases

- Review Systems Code: Identify ownership, lifetime, cleanup, bounds, and synchronization risks in a focused code review.
- Design Resource Lifecycles: Choose RAII, smart pointers, or explicit cleanup for files, sockets, memory, and locks.
- Learn Rust Ownership: Understand moves, borrowing, lifetimes, reference counting, and thread-safe shared state through practical examples.

## Prompt Templates

### Explain a Memory Safety Pattern

```
Explain how [pattern] prevents [memory bug]. Include one concise example in [language] and list its main tradeoffs.
```

### Review Resource Cleanup

```
Review this [C or C++] resource lifecycle. Find leak, double-free, and exception-safety risks, then recommend specific cleanup changes.
```

### Compare Ownership Designs

```
Compare RAII, reference counting, and Rust ownership for this component: [description]. Recommend one model based on concurrency and lifetime needs.
```

### Audit Concurrent Memory Safety

```
Audit this concurrent systems code for data races, invalid lifetimes, lock misuse, and unsafe sharing. Prioritize findings and propose verification steps.
```

## Limitations

- Does not execute sanitizers, compilers, or test suites.
- Does not prove that a complete program is memory safe.
- Examples require adaptation for project APIs and platform constraints.
- C, C\+\+, and Rust receive more coverage than managed languages.

## Best Practices

- State the resource owner and expected lifetime before selecting a pattern.
- Provide the relevant code, language version, concurrency model, and failure behavior.
- Verify recommendations with compiler warnings, sanitizers, and targeted tests.

## Anti Patterns

- Do not assume smart pointers automatically make object graphs cycle free.
- Do not use unchecked access or unsafe blocks without a documented invariant.
- Do not apply examples unchanged without checking project APIs and error handling.

## Security Audit

- Audited at: 2026-08-04T13:47:43.199\+00:00
- Summary: All 26 static findings are false positives caused by documentation examples and scanner keyword collisions. The skill contains no executable scripts, prompt injection, external process execution, reconnaissance, or malicious intent.

## Stats

- Views: 134
- Downloads: 18
- Favorites: 0
- Popularity score: 0
