This is your go-to when the borrow checker is yelling at you about E0596, E0499, or E0502. Instead of just slapping `mut` everywhere or reaching for RefCell, it walks you through the actual design question: does this data really need to change, and who should control that mutation? The decision trees are solid, like mapping from "need mutable access from &self" straight to Cell vs RefCell based on Copy, or choosing between Rc<RefCell<T>> and Arc<Mutex<T>> based on threading. The anti-patterns section alone will save you from runtime panics. Honestly, this reframes mutability errors from compiler complaints into architecture decisions, which is the right way to think about Rust's ownership model anyway.

skills.sh installs
3.6K
GitHub stars
1.6K
last updated
Aug 21, 2026

Install

$ npx -y skills add actionbook/rust-skills --skill m03-mutability --agent claude-code

Installs into .claude/skills of the current project.

Files

Mutability

Layer 1: Language Mechanics

Core Question

Why does this data need to change, and who can change it?

Before adding interior mutability, understand:

  • Is mutation essential or accidental complexity?
  • Who should control mutation?
  • Is the mutation pattern safe?

Error → Design Question

ErrorDon't Just SayAsk Instead
E0596"Add mut"Should this really be mutable?
E0499"Split borrows"Is the data structure right?
E0502"Separate scopes"Why do we need both borrows?
RefCell panic"Use try_borrow"Is runtime check appropriate?

Thinking Prompt

Before adding mutability:

  1. Is mutation necessary?

    • Maybe transform → return new value
    • Maybe builder → construct immutably
  2. Who controls mutation?

    • External caller → &mut T
    • Internal logic → interior mutability
    • Concurrent access → synchronized mutability
  3. What's the thread context?

    • Single-thread → Cell/RefCell
    • Multi-thread → Mutex/RwLock/Atomic

Trace Up ↑

When mutability conflicts persist:

Sponsors

Details

Repository
github.com/actionbook/rust-skills
Category
Rust
First seen
May 16, 2026

More from actionbook/rust-skills

All 38

Recommended

More Rust
1actionbook avatarcore-dynamic-skillsactionbook/rust-skillsInternal command support for dynamic Rust crate skill management. Use only when explicitly invoked by /sync-crate-skills, /clean-crate-skills, or /update-crate-2Kskills.sh installs
2actionbook avatarm07-concurrencyactionbook/rust-skillsCRITICAL: Use for concurrency/async. Triggers: E0277 Send Sync, cannot be sent between threads, thread, spawn, channel, mpsc, Mutex, RwLock, Atomic, async, awai3.7Kskills.sh installs
3actionbook avatarcore-agent-browseractionbook/rust-skillsInternal support skill for agent-browser CLI workflows used by rust-learner, docs-researcher, and crate-researcher. Use only when browser automation is explicit2.2Kskills.sh installs
4zhanghandong avatarm15-anti-patternzhanghandong/rust-skillsm15 anti pattern5.6Kskills.sh installs
5actionbook avatardomain-embeddedactionbook/rust-skillsUse when developing embedded/no_std Rust. Keywords: embedded, no_std, microcontroller, MCU, ARM, RISC-V, bare metal, firmware, HAL, PAC, RTIC, embassy, interrup3.1Kskills.sh installs
6actionbook avatardomain-fintechactionbook/rust-skillsUse when building fintech apps. Keywords: fintech, trading, decimal, currency, financial, money, transaction, ledger, payment, exchange rate, precision, roundin3Kskills.sh installs