Rustler bindings is an AI agent skill from the GitHub repository Goldziher/ai-rulez. Rustler NIFs for Elixir: rustler::nif, tagged tuples, dirty schedulers for long work, ResourceArc state, NifStruct types, no panics. Use when writing or reviewing Rustler bindings.
Claude Code: save it as .claude/skills/rustler-bindings/SKILL.md
Cursor: save it as .cursor/rules/rustler-bindings.md
Codex: save it as .agents/skills/rustler-bindings/SKILL.md
ChatGPT, Gemini and other assistants: paste it into custom or project instructions
Skill file
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.
Use this skill with your AI agent:Open on Skill Issue to copy, download, or add to your library.
Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.