This is a decision framework for choosing between Box, Rc, Arc, and other smart pointers in Rust. It walks you through ownership patterns (single vs shared), threading context (Rc vs Arc), and cycle prevention (when to use Weak). The error table is smart, it reframes "use Weak" as "is the cycle necessary in design?" instead of just throwing syntax at you. The trace up/down sections connect pointer choices to broader architecture questions, which is useful when you're stuck deciding between Rc and Arc but the real issue is whether you actually need shared ownership at all. Comes with a flowchart and anti-pattern warnings about overusing Arc or RefCell everywhere.

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

Install

$ npx -y skills add actionbook/rust-skills --skill m02-resource --agent claude-code

Installs into .claude/skills of the current project.

Files

Resource Management

Layer 1: Language Mechanics

Core Question

What ownership pattern does this resource need?

Before choosing a smart pointer, understand:

  • Is ownership single or shared?
  • Is access single-threaded or multi-threaded?
  • Are there potential cycles?

Error → Design Question

ErrorDon't Just SayAsk Instead
"Need heap allocation""Use Box"Why can't this be on stack?
Rc memory leak"Use Weak"Is the cycle necessary in design?
RefCell panic"Use try_borrow"Is runtime check the right approach?
Arc overhead complaint"Accept it"Is multi-thread access actually needed?

Thinking Prompt

Before choosing a smart pointer:

  1. What's the ownership model?

    • Single owner → Box or owned value
    • Shared ownership → Rc/Arc
    • Weak reference → Weak
  2. What's the thread context?

    • Single-thread → Rc, Cell, RefCell
    • Multi-thread → Arc, Mutex, RwLock
  3. Are there cycles?

    • Yes → One direction must be Weak
    • No → Regular Rc/Arc is fine

Trace Up ↑

When pointer choice is unclear, trace to design:

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 avatarm09-domainactionbook/rust-skillsCRITICAL: Use for domain modeling. Triggers: domain model, DDD, domain-driven design, entity, value object, aggregate, repository pattern, business rules, valid3.5Kskills.sh installs
2actionbook avatarm13-domain-erroractionbook/rust-skillsUse when designing domain error handling. Keywords: domain error, error categorization, recovery strategy, retry, fallback, domain error hierarchy, user-facing 3.5Kskills.sh installs
3actionbook avatarmeta-cognition-parallelactionbook/rust-skillsEXPERIMENTAL: Three-layer parallel meta-cognition analysis. Triggers on: /meta-parallel, 三层分析, parallel analysis, 并行元认知3.2Kskills.sh installs
4actionbook avatardomain-cloud-nativeactionbook/rust-skillsUse when building cloud-native apps. Keywords: kubernetes, k8s, docker, container, grpc, tonic, microservice, service mesh, observability, tracing, metrics, hea3Kskills.sh installs
5zhanghandong avatarm12-lifecyclezhanghandong/rust-skillsm12 lifecycle764skills.sh installs
6zhanghandong avatarm14-mental-modelzhanghandong/rust-skillsm14 mental model751skills.sh installs