Claude Cursor Skill

napi-rs-bindings

napi-rs conventions for exposing a Rust core to Node.js: #[napi] macros, napi::Error mapping, auto-generated .d.ts types, async Promises, and CommonJS/ESM output. Load when generating or reviewing napi-rs Node.js 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_napi-rs_skills_napi-rs-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/napi-rs/skills/napi-rs-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 #[napi] macro for Node.js-visible functions and classes. Use #[napi(constructor)] for constructors.
  • Map Rust errors to JavaScript Error objects via napi::Error. Return Result<T> from all fallible functions.
  • Use napi::bindgen_prelude::* for common type conversions. Use Buffer for binary data.
  • Support both CommonJS and ESM output. Generate .d.ts type definitions automatically.
  • Use #[napi(ts_return_type = "...")] for complex TypeScript types the macro can't infer.
  • Build with napi build --release. Test from TypeScript/JavaScript using a JS test runner (e.g., Vitest or Jest).
  • Async: use #[napi] on async fn for Promise-returning functions. Use AsyncTask for CPU-bound work.
  • Keep Node.js wrappers thin — business logic in Rust, JS provides idiomatic API.
  • Handle BigInt, Date, and other JS-specific types explicitly.
  • Anti-patterns: no panics in napi functions, no blocking the event loop, no manual JsValue manipulation.
Files (ai-rulez)
  • SKILL.md 1.2 KB
    ---
    name: napi-rs-bindings
    description: "napi-rs conventions for exposing a Rust core to Node.js: #[napi] macros, napi::Error mapping, auto-generated .d.ts types, async Promises, and CommonJS/ESM output. Load when generating or reviewing napi-rs Node.js bindings for a Rust library."
    ---
    
    - Use `#[napi]` macro for Node.js-visible functions and classes. Use `#[napi(constructor)]` for constructors.
    - Map Rust errors to JavaScript `Error` objects via `napi::Error`. Return `Result<T>` from all fallible functions.
    - Use `napi::bindgen_prelude::*` for common type conversions. Use `Buffer` for binary data.
    - Support both CommonJS and ESM output. Generate `.d.ts` type definitions automatically.
    - Use `#[napi(ts_return_type = "...")]` for complex TypeScript types the macro can't infer.
    - Build with `napi build --release`. Test from TypeScript/JavaScript using a JS test runner (e.g., Vitest or Jest).
    - Async: use `#[napi]` on `async fn` for Promise-returning functions. Use `AsyncTask` for CPU-bound work.
    - Keep Node.js wrappers thin — business logic in Rust, JS provides idiomatic API.
    - Handle `BigInt`, `Date`, and other JS-specific types explicitly.
    - Anti-patterns: no panics in napi functions, no blocking the event loop, no manual `JsValue` manipulation.
    

Comments (0)

Sign in to join the conversation.

No comments yet.

Reviews (0)

No reviews yet.

Related