Claude Cursor Skill

rustler-bindings

Rustler conventions for building Elixir NIFs from a Rust core: nif macros, tagged {:ok,_}/{:error,_} tuples, dirty schedulers, ResourceArc state, NifStruct derives, and mix compile. Load when generating or reviewing Rustler Elixir NIF 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_rustler_skills_rustler-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/rustler/skills/rustler-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 #[rustler::nif] for Elixir NIF functions. Use #[module = "Elixir.ModuleName"] for module naming.
  • Return tagged tuples: {:ok, value} / {:error, reason}. Use Rustler encoders/decoders for type mapping.
  • Use rustler::Error for NIF error handling. Map Rust errors to descriptive Elixir error tuples.
  • Keep NIF functions fast (<1ms) to avoid scheduler issues. Use #[rustler::nif(schedule = "DirtyCpu")] for long operations.
  • Build with mix compile (Rustler compiler). Test from Elixir using ExUnit.
  • Use ResourceArc<T> for sharing Rust state across NIF calls. Implement Drop for cleanup.
  • Use #[derive(NifStruct)] and #[derive(NifUnitEnum)] for Elixir-compatible types.
  • Keep Elixir NIF wrapper thin — business logic in Rust, Elixir provides functional API.
  • Handle binary data with Binary and OwnedBinary types.
  • Anti-patterns: no panics in NIFs (crashes the BEAM VM), no blocking the scheduler, no I/O in NIFs.
Files (ai-rulez)
  • SKILL.md 1.2 KB
    ---
    name: rustler-bindings
    description: "Rustler conventions for building Elixir NIFs from a Rust core: nif macros, tagged {:ok,_}/{:error,_} tuples, dirty schedulers, ResourceArc state, NifStruct derives, and mix compile. Load when generating or reviewing Rustler Elixir NIF bindings for a Rust library."
    ---
    
    - Use `#[rustler::nif]` for Elixir NIF functions. Use `#[module = "Elixir.ModuleName"]` for module naming.
    - Return tagged tuples: `{:ok, value}` / `{:error, reason}`. Use Rustler encoders/decoders for type mapping.
    - Use `rustler::Error` for NIF error handling. Map Rust errors to descriptive Elixir error tuples.
    - Keep NIF functions fast (<1ms) to avoid scheduler issues. Use `#[rustler::nif(schedule = "DirtyCpu")]` for long operations.
    - Build with `mix compile` (Rustler compiler). Test from Elixir using ExUnit.
    - Use `ResourceArc<T>` for sharing Rust state across NIF calls. Implement `Drop` for cleanup.
    - Use `#[derive(NifStruct)]` and `#[derive(NifUnitEnum)]` for Elixir-compatible types.
    - Keep Elixir NIF wrapper thin — business logic in Rust, Elixir provides functional API.
    - Handle binary data with `Binary` and `OwnedBinary` types.
    - Anti-patterns: no panics in NIFs (crashes the BEAM VM), no blocking the scheduler, no I/O in NIFs.
    

Comments (0)

Sign in to join the conversation.

No comments yet.

Reviews (0)

No reviews yet.

Related