Skip to content
Back to skills

Magnus Bindings

ASecurity

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.

  • 146 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added October 5, 2026
ai-agentsrustrubyapi

Works with

  • api

Security analysis

A100/100

Scanned October 5, 2026

npx -y skills add Goldziher/ai-rulez --skill magnus-bindings --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Magnus Bindings?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Magnus Bindings
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/goldziher-magnus-bindings/badge)](https://www.skillsdirectory.com/skills/goldziher-magnus-bindings)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
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.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.