スキル一覧に戻る
caioniehues

rust-borrow-checker

by caioniehues

My dotfiles - Claude Code configuration

0🍴 0📅 2025年12月23日
GitHubで見るManusで実行

SKILL.md


name: rust-borrow-checker description: Debug Rust ownership, borrowing, and lifetime errors. Use when encountering borrow checker errors (E0382, E0502, E0597, etc.) or when code won't compile due to ownership issues.

<essential_principles> The Rust borrow checker enforces memory safety at compile time through three rules:

  1. Each value has exactly one owner - When the owner goes out of scope, the value is dropped
  2. You can have either one mutable reference OR any number of immutable references - Never both simultaneously
  3. References must always be valid - No dangling references, lifetimes must be sufficient

Understanding these rules is the key to fixing borrow checker errors. </essential_principles>

  1. Diagnose a borrow checker error (paste the error)
  2. Fix a lifetime annotation issue
  3. Fix an ownership transfer problem
  4. Fix a mutable/immutable borrow conflict
  5. Understand a specific error code

Paste the compiler error or describe the issue, then I'll route to the appropriate workflow.

<quick_fixes> Common solutions for frequent errors:

E0382 (use of moved value): Clone, use references, or restructure to avoid the move E0502 (cannot borrow as mutable, already borrowed as immutable): Separate the borrows into different scopes, or use interior mutability (RefCell, Mutex) E0499 (cannot borrow as mutable more than once): Split into separate scopes or use indices instead of references E0597 (borrowed value does not live long enough): Extend the lifetime of the owner, or use owned types instead E0506 (cannot assign, already borrowed): Complete borrow before assignment, or use Cell/RefCell </quick_fixes>

<reference_index> Domain knowledge in references/:

Core Rules:

  • ownership-rules.md - The three ownership rules with examples
  • borrowing-rules.md - Borrowing and reference rules
  • lifetime-syntax.md - Lifetime annotation patterns and elision

Problem Solving:

  • common-errors.md - Detailed breakdown of E0XXX errors
  • patterns.md - Clone, Rc, Arc, RefCell, Cow patterns </reference_index>

<workflows_index>

WorkflowPurpose
diagnose-error.mdSystematically diagnose any borrow checker error
fix-lifetime.mdResolve lifetime annotation issues
fix-ownership.mdFix ownership transfer problems
fix-borrowing.mdHandle borrow conflicts
</workflows_index>

<success_criteria> A fix is complete when:

  • cargo check passes without borrow checker errors
  • The solution doesn't introduce unnecessary cloning
  • The fix maintains the original intent of the code
  • Lifetimes are as simple as possible (rely on elision when possible) </success_criteria>

スコア

総合スコア

60/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です