
M03 Mutability
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-codeInstalls 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
| Error | Don't Just Say | Ask 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:
-
Is mutation necessary?
- Maybe transform → return new value
- Maybe builder → construct immutably
-
Who controls mutation?
- External caller →
&mut T - Internal logic → interior mutability
- Concurrent access → synchronized mutability
- External caller →
-
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- M12 Lifecycle764
- M14 Mental Model751
- M09 Domain750
- M11 Ecosystem747
- M13 Domain Error738
- Rust Trait Explorer731
- Rust Code Navigator728
- Unsafe Checker726
- Domain Cli709
- Rust Symbol Analyzer702
- Rust Call Graph699
- Rust Router698
- Rust Learner688
- Rust Deps Visualizer684
- Rust Skill Creator670
- Domain Web648
- Meta Cognition Parallel635
- Rust Daily635
- Domain Embedded625
- Domain Cloud Native596
- Domain Fintech581
- Domain Ml573
- Domain Iot568
- M15 Anti Pattern5.6K