Back to list
mvillmow

mojo-memory-check

by mvillmow

Training framework written in Mojo

11🍴 4📅 Jan 24, 2026

SKILL.md


name: mojo-memory-check description: "Verify memory safety in Mojo code including ownership, borrowing, and lifetime management. Use when reviewing code or debugging memory issues." mcp_fallback: none category: mojo agent: test-engineer user-invocable: false

Memory Safety Check Skill

Validate Mojo ownership and borrowing rules.

When to Use

  • Reviewing code for memory safety
  • Debugging memory or segfault issues
  • Before merging code
  • Performance testing reveals corruption

Quick Reference

# Owned parameter - takes ownership
fn consume(var data: Tensor):
    process(data)  # data moved here

# Borrowed parameter - read-only reference
fn read_only(data: Tensor):
    let value = data[0]  # OK: read-only

# Mutable reference - in-place modification
fn modify(mut data: Tensor):
    data[0] = 42  # Mutate in caller's variable

Workflow

  1. Trace ownership - Which function owns each value
  2. Check borrows - Are references short-lived
  3. Verify moves - Use ^ operator for ownership transfer
  4. Test lifetimes - Compile and run with memory checks
  5. Debug issues - Identify use-after-move or dangling refs

Mojo-Specific Notes

  • Use ^ operator ONLY when transferring ownership
  • mut self for mutating methods (NOT out self)
  • out self ONLY for constructors (__init__)
  • List/Dict/String are non-copyable - must use ^ when returning

Error Handling

ErrorCauseSolution
Use after moveVariable used after ownership transferCreate copy or don't move
Dangling referenceReference to local variableReturn owned value with ^
Mutable aliasingMultiple mutable refs to same dataEnsure single mutable reference
Type not copyableMissing ^ on non-copyable returnAdd transfer operator ^

References

  • .claude/shared/mojo-anti-patterns.md - Ownership violations section
  • .claude/shared/mojo-guidelines.md - Parameter conventions table

Score

Total Score

60/100

Based on repository quality metrics

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

Reviews

💬

Reviews coming soon