The m03-mutability skill diagnoses and resolves Rust mutability errors (E0596, E0499, E0502) by guiding developers to understand whether mutation is architecturally necessary and which mutability pattern fits their use case—from simple `&mut T` borrows to interior mutability types like `Cell`, `RefCell`, and `Mutex`. It serves Rust developers debugging borrow checker conflicts by transforming "add mut" impulses into design questions, then tracing issues upward to data structure problems or downward to the appropriate implementation pattern. The skill solves the common problem of developers treating mutability as a tactical syntax issue rather than a design decision about ownership and access control.

skills.sh installs
773
GitHub stars
1.3K
last updated
Jul 14, 2026

Install

$ npx -y skills add zhanghandong/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/zhanghandong/rust-skills
Category
Rust

More from zhanghandong/rust-skills

All 34

Recommended

More Rust
1zhanghandong avatardomain-webzhanghandong/rust-skillsdomain web648skills.sh installs
2zhanghandong avatardomain-iotzhanghandong/rust-skillsdomain iot568skills.sh installs
3warpdotdev avatarfix-errorswarpdotdev/common-skillsFix compilation errors, linting issues, and test failures in the warp Rust codebase. Covers presubmit checks, WASM-specific errors, and running specific tests. 28.7Kskills.sh installs
4wshobson avatarmemory-safety-patternswshobson/agentsImplement memory-safe programming with RAII, ownership, smart pointers, and resource management across Rust, C++, and C. Use when writing safe systems code, man12.2Kskills.sh installs
5dotnet avatartest-gap-analysisdotnet/skillsPerforms pseudo-mutation analysis on production code in any language to find gaps in existing tests. Use when the user asks to find weak or shallow tests, disco4.3Kskills.sh installs
6actionbook avatarm02-resourceactionbook/rust-skillsCRITICAL: Use for smart pointers and resource management. Triggers: Box, Rc, Arc, Weak, RefCell, Cell, smart pointer, heap allocation, reference counting, RAII,3.6Kskills.sh installs