# m02-resource

Guides AI agents in choosing the right Rust smart pointers and ownership models. Useful when designing data structures or preventing memory leaks.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 3400 installs · ★ 1545
- Author: actionbook
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/actionbook/rust-skills/tree/HEAD/skills/m02-resource/SKILL.md
- Updated: 2026-08-23
- HTML: https://affpapa.org/en/nevibecode/skills/m02-resource

## What it does

This skill guides coding assistants through Rust resource management. Instead of blindly wrapping types in heap allocations, it forces the agent to inspect the ownership model. The agent checks whether data has a single owner or shared access, runs on one thread or multiple threads, and contains reference cycles.

The skill includes decision flows for mapping errors to design fixes. It directs single-owner heap data to `Box`, single-threaded shared data to `Rc`, and cross-thread sharing to `Arc`. Placing `Arc` everywhere adds unneeded atomic overhead on hot paths. For interior mutability, it contrasts `Cell` for copyable types against `RefCell` and synchronization primitives, while pushing `Weak` to break reference cycles.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add actionbook/rust-skills --skill m02-resource -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/m02-resource/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/m02-resource/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add actionbook/rust-skills --skill m02-resource -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/m02-resource/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add actionbook/rust-skills --skill m02-resource -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/m02-resource/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install actionbook/rust-skills m02-resource
```

2. **Manually: put the files in place**
- File: `.github/skills/m02-resource/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add actionbook/rust-skills --skill m02-resource -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/actionbook/rust-skills --path skills/m02-resource
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/m02-resource/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add actionbook/rust-skills --skill m02-resource -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/actionbook/rust-skills/tree/HEAD/skills/m02-resource/SKILL.md

## When to use it
- select between `Rc` and `Arc` based on thread requirements
- resolve reference cycles using `Weak` pointers
- eliminate unnecessary `Box` heap allocations for small types
- configure interior mutability without runtime borrow panics

## Example prompts
- Should I use Rc or Arc for this single-threaded tree structure?
- I have a runtime panic with RefCell borrow, how should I restructure this?
- Can this recursive enum fit on the stack or does it need Box?

## Similar
- [rust-patterns](https://affpapa.org/en/nevibecode/skills/rust-patterns.md) — skill · 5100 installs
- [rust-async-patterns](https://affpapa.org/en/nevibecode/skills/rust-async-patterns.md) — skill · 20625 installs
- [memory-model](https://affpapa.org/en/nevibecode/skills/memory-model.md) — skill · 634 installs
- [concurrency-debugging](https://affpapa.org/en/nevibecode/skills/concurrency-debugging.md) — skill · 524 installs
- [rust-systems-programming](https://affpapa.org/en/nevibecode/skills/rust-systems-programming.md) — skill · 485 installs
- [c-pro](https://affpapa.org/en/nevibecode/agents/c-pro.md) — subagent · 650 installs

From the same set: [actionbook/rust-skills](https://affpapa.org/en/nevibecode/by/actionbook/rust-skills.md) — 33 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
