Claude Cursor Skill

magnus-bindings

Magnus conventions for building Ruby native extensions from a Rust core: define_class, TryConvert/IntoValue, exception mapping, GVL handling, TypedData GC integration, and rake-compiler distribution. Load when generating or reviewing Magnus Ruby bindings for a Rust library.

LLM Mart · 0 points · 0 views 0 listing impressions 0 install-command copies
Virus-scanned Reviewed automatically before listing.

Full trust report

Download goldziher-ai-rulez-internal_builtins_bindings_magnus_skills_magnus-bindings-ca967ad.zip · 0 KB
Part of goldziher/ai-rulez — 151 skills

Install

skills CLI npx skills add https://github.com/Goldziher/ai-rulez/tree/main/internal/builtins/bindings/magnus/skills/magnus-bindings
Claude Code claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install goldziher-ai-rulez@llmmart
Git git clone https://github.com/Goldziher/ai-rulez.git

The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole goldziher/ai-rulez collection as a plugin from our marketplace. Git is the plain clone.

Skill manifest

  • Use magnus crate for Ruby native extensions. Define classes with magnus::define_class.
  • Map Rust types to Ruby using TryConvert and IntoValue traits. Return Result<T, magnus::Error>.
  • Use magnus::function! macro for defining Ruby methods. Use magnus::method! for instance methods.
  • Map Rust errors to specific Ruby exceptions: magnus::Error::new(exception::runtime_error(), msg).
  • Build with rb_sys crate and magnus-build for compilation. Use rake-compiler for gem distribution.
  • Support Ruby 3.2+ with multiple ABI versions.
  • Test bindings from Ruby using RSpec or Minitest. Test error handling and edge cases.
  • Keep Ruby wrapper gem thin — business logic in Rust, Ruby provides idiomatic API.
  • Handle Ruby's GVL (Global VM Lock) — release for CPU-intensive Rust code.
  • Use TypedData for wrapping Rust structs as Ruby objects with proper GC integration.
  • Anti-patterns: panics in Ruby methods, unsafe without SAFETY comments, manual memory management.
Files (ai-rulez)
  • SKILL.md 1.3 KB
    ---
    name: magnus-bindings
    description: "Magnus conventions for building Ruby native extensions from a Rust core: define_class, TryConvert/IntoValue, exception mapping, GVL handling, TypedData GC integration, and rake-compiler distribution. Load when generating or reviewing Magnus Ruby bindings for a Rust library."
    ---
    
    - Use `magnus` crate for Ruby native extensions. Define classes with `magnus::define_class`.
    - Map Rust types to Ruby using `TryConvert` and `IntoValue` traits. Return `Result<T, magnus::Error>`.
    - Use `magnus::function!` macro for defining Ruby methods. Use `magnus::method!` for instance methods.
    - Map Rust errors to specific Ruby exceptions: `magnus::Error::new(exception::runtime_error(), msg)`.
    - Build with `rb_sys` crate and `magnus-build` for compilation. Use `rake-compiler` for gem distribution.
    - Support Ruby 3.2+ with multiple ABI versions.
    - Test bindings from Ruby using RSpec or Minitest. Test error handling and edge cases.
    - Keep Ruby wrapper gem thin — business logic in Rust, Ruby provides idiomatic API.
    - Handle Ruby's GVL (Global VM Lock) — release for CPU-intensive Rust code.
    - Use `TypedData` for wrapping Rust structs as Ruby objects with proper GC integration.
    - Anti-patterns: panics in Ruby methods, `unsafe` without `SAFETY` comments, manual memory management.
    

Comments (0)

Sign in to join the conversation.

No comments yet.

Reviews (0)

No reviews yet.

Related