igmarin/agent-profiles/ownership-borrowing

Claude Code and agent skill by igmarin/agent-profiles

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Borrow before clone. Accept &[T]/&str. Arc vs Rc. Interior mutability last. Trigger: clone, borrow, lifetime, Arc, Rc, RefCell, Mutex, Cow, ownership.

Install

npx vskill@latest install igmarin/agent-profiles/ownership-borrowing

SKILL.md

Ownership and borrowing

Apply the execution contract before this procedure.

Goal

No allocation that a borrow would cover. Shared mutability only when the type system requires it.

Inputs / outputs

  • In: a function or type that owns or shares data
  • Out: API that takes the least ownership it needs

Reads / writes

  • Read: the function and its callers
  • Write: none unless a playbook opened the task

Approval

None to drop clones. State lifecycle and concurrency cost before adding Arc, Rc, Mutex, RwLock, or RefCell; stop for approval if that choice changes the accepted design or scope.

RULES — no exceptions

  1. Prefer &T / &mut T over .clone()
  2. Accept &[T] not &Vec<T>; &str not &String
  3. Cow<'_, T> only when you sometimes own
  4. Arc<T> across threads; Rc<T> single-thread only
  5. RefCell / Mutex / RwLock last; document why
  6. Copy for tiny, obviously copyable types; otherwise explicit Clone
  7. Move large values; Box if the move itself is the cost
  8. Elide lifetimes until the compiler asks

Example

rust
// ❌
fn count_words(text: &String) -> usize {
text.clone().split_whitespace().count()
}
// ✅
fn count_words(text: &str) -> usize {
text.split_whitespace().count()
}

Clone is justified when storing, sending 'static to a thread, or the type is Copy.

Steps

  1. Grep the touched fn for .clone(
  2. If the clone is not stored or sent, borrow
  3. Widen params to slices/str

Validation

cargo test on the crate (or cargo test <test_name> -- --exact if a test is already red). Diff should drop clones or justify each remainder in one comment.

Pitfalls

❌✅
data.clone() to call a readerpass &data
Mutex for a single-thread cacheRefCell or, better, owned local
Lifetime soupelide; name only 'src / 'a when needed

Integration

Predecessor: rust-essentials. Successor: type-driven-design. Do not hold a lock across .await.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
5

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/igmarin/agent-profiles/ownership-borrowing/badge)](https://verified-skill.com/skills/igmarin/agent-profiles/ownership-borrowing)

Something wrong with this skill or its page? Tell us.