Skip to main content
skill CX Codex

m03-mutability — Claude Code skill: fixing Rust mutability errors

A Rust skill for mutability trouble: it walks from borrow-checker errors to a decision about the data, not just another mut.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add actionbook/rust-skills --skill m03-mutability -a claude-code
Open on GitHub

What m03-mutability does

The skill fires on E0596, E0499, E0502, on “cannot borrow as mutable” messages and on RefCell panics. Its first move is a question: does this value need to change at all, and who gets to change it? Sometimes the answer is a new value instead of a mutation.

Choosing interior mutability comes down to two facts in the reference tables: is the type Copy, and does the code cross threads. Cell<T> covers Copy types on one thread; RefCell<T> handles the rest without threads; Mutex<T> and RwLock<T> take the multithreaded cases. An anti-pattern table names the usual mistakes, including a lock taken inside a hot loop and RefCell sprinkled everywhere.

When borrow conflicts keep returning, the skill points to neighbouring topics on data structure design and concurrency, because a repeated E0499 often means the struct itself is wrong. It is not a slash command — the description triggers it automatically, so the SKILL.md file has to sit in your platform's skills directory.

What it helps with

  • work out an E0596 without blindly adding mut
  • pick between Cell, RefCell and Mutex for a given field
  • track down the borrow that makes RefCell panic at runtime
  • untangle overlapping borrows in E0499 and E0502
  • spot anti-patterns such as locking inside a hot loop

Example prompts for the agent

  • I'm getting E0502, a &mut while a & is alive. What should I restructure?
  • I need to mutate a non-Copy field through &self. RefCell, or something else?
  • My RefCell panics with already borrowed. How do I find the borrow that was never dropped?

How to install m03-mutability

1Skills CLI (Vercel)

npx skills add actionbook/rust-skills --skill m03-mutability -a claude-code

2Manually: put the files in place

~/.claude/skills/m03-mutability/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/m03-mutability/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about m03-mutability

How do I install m03-mutability in Claude Code?

Run npx skills add actionbook/rust-skills --skill m03-mutability -a claude-code. The skill file lands at ~/.claude/skills/m03-mutability/SKILL.md.

What does m03-mutability do?

It helps with Rust mutability and borrow errors. Each error code leads to a design question about the data rather than a quick annotation fix.

Does m03-mutability run as a command?

No. It has user-invocable: false and triggers from its description when errors like E0596 or RefCell come up.

Similar skills

All skills for Programming languages →

From the same set33

m13-domain-error This skill helps design domain error types, recovery rules, and debugging context. Use it when Rust code needs retry, fallback, or clear error boundaries. CX Codex +1 3,300installs 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. CX Codex +1 3,300installs m09-domain Domain-driven design guide for structuring Rust code. Helps your coding agent organize entities, aggregates, and value objects under Rust ownership. CX Codex +1 3,300installs m12-lifecycle Helps design Rust resource lifecycles, from creation and scope to cleanup and error handling. Useful for connections, transactions, guards, and lazy initialization. CX Codex +1 3,300installs rust-call-graph Builds a Rust function call graph through LSP: who calls a function and what it calls. Useful when reading unfamiliar code or checking what a change will touch. CX Codex +1 3,200installs unsafe-checker Reviews unsafe Rust blocks and FFI boundaries, tracking required SAFETY comments and catching common causes of undefined behavior. CX Codex +1 3,200installs rust-learner Fetches crate versions, docs.rs API signatures, Rust changelogs, and Clippy lint descriptions directly inside coding agent sessions. CX Codex +1 3,100installs domain-web A Rust web-service skill covering async handlers, shared state, errors, extractors, and middleware. Use it when a project contains Cargo.toml. CX Codex +1 3,100installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor