# m14-mental-model

A skill that explains ownership, borrowing and lifetimes in Rust through analogies and compiler error breakdowns. Useful when the borrow checker blocks your build.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 3300 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/m14-mental-model/SKILL.md
- Updated: 2026-08-23
- HTML: https://affpapa.org/en/nevibecode/skills/m14-mental-model

## What it does

The skill lays out mental models for core Rust concepts. Ownership is a single house key, a move is handing that key over, `&T` is lending a book to read, `&mut T` is being the only one allowed to edit the document. Smart pointers get their own analogies: `Box<T>` as a remote control to the TV, `Rc<T>` as several remotes where the last one turns it off, `Arc<T>` as those remotes working from any room.

A second table covers switching languages. From Java and C# the shift is that values are owned rather than referenced by default. From Python and Go it is the absence of a garbage collector and deterministic destruction. From JavaScript, `Option` replaces null.

There is a misconception table keyed to compiler errors: E0382, E0502, E0499, E0106, E0507. Each row pairs the wrong model with the correct one. The skill is not user-invocable, so you just describe what confuses you and let the agent pick it up.

## Install

### Claude Code (native platform)

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

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

### Codex

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

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

### Cursor

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

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

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install actionbook/rust-skills m14-mental-model
```

2. **Manually: put the files in place**
- File: `.github/skills/m14-mental-model/SKILL.md`

### Gemini CLI

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

2. **Platform CLI**
```bash
gemini skills install https://github.com/actionbook/rust-skills --path skills/m14-mental-model
```

### Windsurf (Devin Desktop)

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

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add actionbook/rust-skills --skill m14-mental-model -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/m14-mental-model/SKILL.md

## When to use it
- understand why a variable stops working after a move
- tell `&T` and `&mut T` apart by what access they grant
- explain lifetimes to a teammate without dry theory
- switch to Rust from Java or Python without carrying old habits
- decode a borrow checker error and find the rule you broke

## Example prompts
- Explain with analogies why Rust rejects two mutable borrows at once
- I'm coming from Python — what do I need to rethink about ownership?
- Why does the compiler throw E0382 and how should I rewrite this?

## Similar
- [rust-patterns](https://affpapa.org/en/nevibecode/skills/rust-patterns.md) — skill · 5100 installs
- [rust-systems-programming](https://affpapa.org/en/nevibecode/skills/rust-systems-programming.md) — skill · 485 installs
- [async-io-model](https://affpapa.org/en/nevibecode/skills/async-io-model.md) — skill · 1300 installs
- [memory-model](https://affpapa.org/en/nevibecode/skills/memory-model.md) — skill · 634 installs
- [kyc-doc-parse](https://affpapa.org/en/nevibecode/skills/kyc-doc-parse.md) — skill · 1200 installs
- [sigma](https://affpapa.org/en/nevibecode/skills/sigma.md) — skill · 4800 installs

From the same set: [actionbook/rust-skills](https://affpapa.org/en/nevibecode/by/actionbook/rust-skills.md) — 35 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
