igmarin/agent-profiles/rust-ownership-borrowing
Claude Code and agent skill by igmarin/agent-profiles
- community
Checking that the SKILL.md file is still in the repository.
'Borrow before clone. Accept &[T]/&str. Arc vs Rc. Interior mutability
Install
npx vskill@latest install igmarin/agent-profiles/rust-ownership-borrowingSKILL.md
Resolve skill names through ../../skill-map.json; use the source pack to disambiguate. Load only the workflow and resources needed for the authorized task.
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
- Prefer
&T/&mut Tover.clone() - Accept
&[T]not&Vec<T>;&strnot&String Cow<'_, T>only when you sometimes ownArc<T>across threads;Rc<T>single-thread onlyRefCell/Mutex/RwLocklast; document whyCopyfor tiny, obviously copyable types; otherwise explicitClone- Move large values;
Boxif the move itself is the cost - Elide lifetimes until the compiler asks
Example
Clone is justified when storing, sending 'static to a thread, or the type is Copy.
Steps
- Grep the touched fn for
.clone( - If the clone is not stored or sent, borrow
- 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 reader | pass &data | |
Mutex for a single-thread cache | RefCell or, better, owned local | |
| Lifetime soup | elide; 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
- SKILL.md in the repositoryCheckingplugins/rust-developer/skills/rust-ownership-borrowing/SKILL.md
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
[](https://verified-skill.com/skills/igmarin/agent-profiles/rust-ownership-borrowing)