スキル一覧に戻る
mvillmow

mojo-type-safety

by mvillmow

Training framework written in Mojo

11🍴 4📅 2026年1月24日
GitHubで見るManusで実行

SKILL.md


name: mojo-type-safety description: "Validate type safety in Mojo code including parametric types and trait constraints. Use during code review or when type errors occur." mcp_fallback: none category: mojo agent: test-engineer user-invocable: false

Type Safety Validation Skill

Ensure Mojo code follows type safety principles.

When to Use

  • Type errors during compilation
  • Code review for type safety
  • Designing generic functions
  • Working with trait constraints

Quick Reference

# Generic function with type parameter
fn add[dtype: DType](a: Scalar[dtype], b: Scalar[dtype]) -> Scalar[dtype]:
    return a + b

# Trait constraint
fn process[T: Copyable](data: T):
    let copy = data  # T is Copyable

# Compile-time check
@parameter
fn validate[size: Int]():
    constrained[size > 0, "Size must be positive"]()

Workflow

  1. Add type annotations - All parameters and returns
  2. Use type parameters - For generic code
  3. Add trait constraints - When required
  4. Run compiler - Verify type checking passes
  5. Test generic code - With multiple types

Mojo-Specific Notes

  • Prefer fn over def for type safety
  • Generic type parameters use [T] syntax
  • Traits constrain what operations are allowed
  • Compile-time checks prevent runtime errors

Error Handling

ErrorCauseSolution
Missing type annotationUntyped parameterAdd : Type to parameter
Type mismatchIncompatible typesAdd explicit conversion
Unsupported operationTrait not constrainedAdd trait constraint
Constraint failedCompile-time check failedVerify constraint conditions

References

  • .claude/shared/mojo-guidelines.md - Current syntax and patterns
  • .claude/shared/mojo-anti-patterns.md - Common constructor mistakes

スコア

総合スコア

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

レビュー

💬

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