agentsclimarketplace

M02 resource

Skill moeru-ai/auv/.agents/skills/m02-resource

๐Ÿ“ฑ๐Ÿญ No we are not computer use, it's Application Use Via... a unified orchestration layer of OS automation, 0 token cost

Install
npx -y skills add moeru-ai/auv --skill m02-resource

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 20 stars20 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

CRITICAL: Use for smart pointers and resource management. Triggers: Box, Rc, Arc, Weak, RefCell, Cell, smart pointer, heap allocation, reference counting, RAII, Drop, should I use Box or Rc, when to use Arc vs Rc, ๆ™บ่ƒฝๆŒ‡้’ˆ, ๅผ•็”จ่ฎกๆ•ฐ, ๅ †ๅˆ†้…

SKILL.md

4.3 KB, as published. Nobody here has run it

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:

"Should I use Arc or Rc?"
    โ†‘ Ask: Is this data shared across threads?
    โ†‘ Check: m07-concurrency (thread model)
    โ†‘ Check: domain-* (performance constraints)
SituationTrace ToQuestion
Rc vs Arc confusionm07-concurrencyWhat's the concurrency model?
RefCell panicsm03-mutabilityIs interior mutability right here?
Memory leaksm12-lifecycleWhere should cleanup happen?

Trace Down โ†“

From design to implementation:

"Need single-owner heap data"
    โ†“ Use: Box<T>

"Need shared immutable data (single-thread)"
    โ†“ Use: Rc<T>

"Need shared immutable data (multi-thread)"
    โ†“ Use: Arc<T>

"Need to break reference cycle"
    โ†“ Use: Weak<T>

"Need shared mutable data"
    โ†“ Single-thread: Rc<RefCell<T>>
    โ†“ Multi-thread: Arc<Mutex<T>> or Arc<RwLock<T>>

Quick Reference

TypeOwnershipThread-SafeUse When
Box<T>SingleYesHeap allocation, recursive types
Rc<T>SharedNoSingle-thread shared ownership
Arc<T>SharedYesMulti-thread shared ownership
Weak<T>Weak refSame as Rc/ArcBreak reference cycles
Cell<T>SingleNoInterior mutability (Copy types)
RefCell<T>SingleNoInterior mutability (runtime check)

Decision Flowchart

Need heap allocation?
โ”œโ”€ Yes โ†’ Single owner?
โ”‚        โ”œโ”€ Yes โ†’ Box<T>
โ”‚        โ””โ”€ No โ†’ Multi-thread?
โ”‚                โ”œโ”€ Yes โ†’ Arc<T>
โ”‚                โ””โ”€ No โ†’ Rc<T>
โ””โ”€ No โ†’ Stack allocation (default)

Have reference cycles?
โ”œโ”€ Yes โ†’ Use Weak for one direction
โ””โ”€ No โ†’ Regular Rc/Arc

Need interior mutability?
โ”œโ”€ Yes โ†’ Thread-safe needed?
โ”‚        โ”œโ”€ Yes โ†’ Mutex<T> or RwLock<T>
โ”‚        โ””โ”€ No โ†’ T: Copy? โ†’ Cell<T> : RefCell<T>
โ””โ”€ No โ†’ Use &mut T

Common Errors

ProblemCauseFix
Rc cycle leakMutual strong refsUse Weak for one direction
RefCell panicBorrow conflict at runtimeUse try_borrow or restructure
Arc overheadAtomic ops in hot pathConsider Rc if single-threaded
Box unnecessaryData fits on stackRemove Box

Anti-Patterns

Anti-PatternWhy BadBetter
Arc everywhereUnnecessary atomic overheadUse Rc for single-thread
RefCell everywhereRuntime panicsDesign clear ownership
Box for small typesUnnecessary allocationStack allocation
Ignore Weak for cyclesMemory leaksDesign parent-child with Weak

Related Skills

WhenSee
Ownership errorsm01-ownership
Interior mutability detailsm03-mutability
Multi-thread contextm07-concurrency
Resource lifecyclem12-lifecycle

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.