m02-resource

Recommend Rust pointer/resource choices based on ownership and concurrency.

1|Updated Apr 4, 2026
One-click install
npx skills add https://github.com/Jylhis/claude-marketplace --skill m02-resource-jylhis
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: m02-resource
Source: https://github.com/Jylhis/claude-marketplace/tree/main/plugins/rust-dev/skills/m02-resource
Command: npx skills add https://github.com/Jylhis/claude-marketplace --skill m02-resource-jylhis

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Helps Rust developers choose appropriate smart pointers and resource-management primitives to avoid unnecessary heap allocations, reference cycles, runtime borrow panics, and incorrect thread-safety choices when designing data ownership and access patterns.

Core Features & Use Cases

  • Ownership decision flow: Guides whether to use Box, Rc, Arc, or Weak based on single vs shared ownership and cycle risks.
  • Thread-safety and interior mutability guidance: Recommends Rc/Arc combinations with RefCell, Cell, Mutex, or RwLock according to single-threaded or multi-threaded contexts.
  • Error mitigation and anti-patterns: Identifies common pitfalls (RefCell panics, Rc cycles, unnecessary Arc overhead) and prescribes practical fixes and design questions to ask in reviews. Use case: When refactoring a data structure that moves to a background worker thread, consult this Skill to determine if Rc should be replaced with Arc and where Weak references must break cycles.

Quick Start

Use this skill to decide whether to use Box, Rc, Arc, Weak, RefCell, or Cell for a Rust value given its ownership model and threading requirements.

Frequently Asked Questions about m02-resource

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
When should I use Rc versus Arc for shared ownership in Rust?

Use Rc for single-threaded shared ownership and Arc when data crosses thread boundaries. This Rust smart pointer guidance prevents unsafe concurrency by matching the reference counter to your threading context.

How do I choose between Box, Rc, and Arc for heap allocation?

Choose Box for exclusive single ownership, Rc for shared single-threaded access, and Arc for multi-threaded scenarios. An ownership decision flow evaluates allocation needs to avoid unnecessary heap overhead.

Why does RefCell panic at runtime in Rust?

RefCell panics at runtime when its borrowing rules are violated, such as having overlapping mutable borrows. This Skill identifies common interior mutability pitfalls and prescribes design fixes to prevent them.

What is the best way to break reference cycles in Rust?

The best way to break reference cycles in Rust is using Weak references instead of Rc or Arc. This prevents memory leaks by allowing references that do not contribute to the strong reference count.

Do I need Mutex or RwLock with Arc for interior mutability in Rust?

You need Mutex or RwLock with Arc to safely achieve interior mutability across multiple threads. This combination enforces thread-safety while allowing controlled mutation of shared data.

Can I use Cell instead of RefCell for single-threaded interior mutability?

Yes, Cell is appropriate for single-threaded interior mutability when types implement Copy, avoiding runtime borrow checks. This Skill recommends Cell or RefCell based on your specific single-threaded access patterns.