/rust-skills:rust-uniffi-buildingfrom rust-skills
Builds and troubleshoots cross-platform Rust bindings with Mozilla UniFFI for Swift, Kotlin, Python, Ruby, JavaScript, and WASM targets.
Ships in rust-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Build a narrow, versioned foreign-language API around a shared Rust library. Recognize requests such as “write the core once in Rust for Swift and Android,” “call Rust from Kotlin and iOS,” or “reuse Rust business logic across mobile and browser clients” as UniFFI evaluation/building tasks even if the user does not name UniFFI. Treat generated bindings, the compiled native library, and host-language packaging as one contract: a successful Rust build alone does not prove that Kotlin, Swift, Python, Ruby, JavaScript, or WASM consumers work.
Use this skill for Mozilla UniFFI interface design, scaffolding, binding generation, language integration, lifecycle behavior, and end-to-end validation.
Route these adjacent tasks deliberately:
extern "C", raw pointers, allocator ownership, or manual headers → rust-unsafe-ffi.rust-macros.rust-cargo-build.rust-concurrency.rust-testing.Before editing, record:
rustc --version --verbose, target triples, MSRV, and host platforms;uniffi, backend, and language-tooling versions plus enabled features;Inspect Cargo.lock and the current official UniFFI guide. Do not copy syntax from a different UniFFI release line. The repository's golden example is evidence for its locked version, not a timeless dependency recommendation.
| Strategy | Prefer when | Required discipline |
|---|---|---|
| Procedural macros | Rust is the API source of truth and supported constructs cover the contract | Use library mode and uniffi::setup_scaffolding!() exactly once |
| UDL | An explicit language-neutral schema is desired or existing UDL must remain authoritative | Generate in build.rs and include the generated scaffolding |
| Mixed UDL + macros | Migration or a real unsupported construct requires both | Keep UDL valid alone; make crate name match the UDL namespace |
Never call both uniffi::setup_scaffolding!() and uniffi::include_scaffolding!() in one crate. Do not mix strategies merely for convenience; it increases duplicate-definition and drift risk.
Read Interface Model before designing public types or choosing UDL versus macros.
For a procedural-macro-only crate, start with the smallest viable pattern:
uniffi::setup_scaffolding!();
#[derive(uniffi::Record)]
pub struct Greeting {
pub message: String,
}
#[uniffi::export]
pub fn greet(name: String) -> Greeting {
Greeting {
message: format!("Hello, {name}!"),
}
}
Build an ordinary Rust library for Rust callers and the platform artifacts required by hosts:
[lib]
crate-type = ["lib", "cdylib", "staticlib"]
Do not enable every crate type or UniFFI feature automatically. Select artifacts from the host packaging contract, isolate bindgen/CLI dependencies when practical, and keep runtime-facing dependencies minimal.
For UDL build scripts, generated bindings, configuration precedence, and library-mode commands, read Scaffolding and Generation.
Arc<Self> from exported object constructors when required by the selected UniFFI version.Read Async, Lifetimes, and Callbacks before exporting futures, callbacks, traits, or stateful objects.
Generate bindings from the exact library/configuration combination that will ship. Keep generated sources and native artifacts version-aligned.
Validate language-specific integration rather than stopping at generated files:
Read Language Bindings only for the requested target languages.
Run the Rust gates first:
cargo fmt --all --check
cargo check --workspace --all-targets --all-features
cargo test --workspace --all-targets --all-features
cargo clippy --workspace --all-targets --all-features -- -D warnings
Then verify:
Rust tests, generated-source snapshots, and host compilation are different evidence levels. Do not claim a platform works without executing it.
Read Testing, Packaging, and Upgrades before release, CI design, or version migration.
Classify failures before changing code:
| Symptom | Inspect first |
|---|---|
| Missing exported symbol or metadata | scaffolding macro/include mode, crate features, final library artifact |
| Duplicate symbols or definitions | mixed UDL/macros, duplicate scaffolding setup, multiple generated sources |
| Bindgen cannot find crate/config | cargo-metadata, global [crate-roots], working directory, config precedence |
| Generated code compiles but library will not load | filename, architecture, ABI, search path, signing, package contents |
| Values corrupt or fail to decode | type model, custom converter, version skew, lowering/lifting contract |
| Object disappears, leaks, or races | reference counting, host lifetime, callback registration, thread policy |
| Async hangs or cancellation leaks work | runtime feature, foreign executor/poller, cancellation and completion contract |
| Only release builds fail | dead stripping, LTO, symbol retention, feature/profile differences |
Read Internals and Diagnostics only when surface-level checks cannot explain the failure.
latest documentation can move. Pin crate versions and record the guide snapshot used for a release decision.#[cfg] on separate exported impl blocks when needed; conditional items inside an exported block can still generate incompatible scaffolding.Do not activate this skill for:
wasm-bindgen, CXX, PyO3, JNI, cbindgen, Diplomat, or raw C bindings unless the task explicitly adopts or compares UniFFI;examples/golden-uniffi/: a compiled procedural-macro library with records, enums, objects, tests, and a version-locked local bindgen CLI.Do not upload proprietary UDL, generated bindings, native libraries, symbols, crash dumps, or host application logs to external services without authorization.
agents/openai.yaml (opens in a new tab)examples/examples.md (opens in a new tab)examples/golden-uniffi/Cargo.toml (opens in a new tab)examples/golden-uniffi/src/lib.rs (opens in a new tab)references/async-lifetimes-and-callbacks.md (opens in a new tab)references/interface-model.md (opens in a new tab)references/internals-and-diagnostics.md (opens in a new tab)references/language-bindings.md (opens in a new tab)references/official-doc-map.md (opens in a new tab)references/scaffolding-and-generation.md (opens in a new tab)references/testing-packaging-and-upgrades.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Generated from the plugin's indexed repository (full-stack-skills/rust-skills) — no native marketplace selected
npx claudepluginhub p/full-stack-skills-rust-skills29 skills in this plugin
/rust-api-designDesign Rust library APIs that follow the Rust API Guidelines — naming (C-CASE, C-CONV, C-GETTER), interop traits (C-COMMON-TRAITS, C-CONVERT, C-ITER, C-SERDE), predictability (C-INTUITIVE, C-CONST), flexibility (C-GENERIC, C-NEWTYPE, C-EXT), type safety (C-BOOL, C-NONZERO, C-WRAPPER, C-STR), dependability (C-PANIC, C-UNWRAP), debuggability (C-DEBUG), and future-proofing (C-SEALED, C-STRUCT-FIELD, C-NON-EXHAUSTIVE). Use when users design a public crate API, choose between generics/concrete/newtype, decide trait bounds, hide implementation, avoid breakage, or ask "what is idiomatic Rust API design"; hand semver and publish workflow to rust-semver, lint config to rust-style-clippy, and in-crate layout to rust-module-layout./rust-by-exampleShow Rust patterns through short compilable examples — type conversions (From/Into/TryFrom/as/Deref), flow control (if let/while let/match/loop), functions and closures (Fn/FnMut/FnOnce, captures), modules (mod/use/pub/super/self), generics and traits (bounds/associated types/trait objects), error handling (?/Result/thiserror/anyhow), attributes (derive/cfg/inline/allow), unsafe (raw pointers/unions/ABI), procedural macros (derive/attribute/function-like), and inline asm. Use when users ask "how do I write X in Rust", need a concrete pattern with copy-pasteable code, or are migrating from Java/Python/Go/C++ and want the Rust equivalent; hand architecture decisions to rust-api-design/rust-workspace, std API selection to rust-stdlib, and async runtime to rust-concurrency./rust-cargo-buildConfigure, operate, diagnose, and automate Cargo for Rust packages and workspaces. Cover manifests and targets, commands, dependency resolution and features, profiles, build scripts, configuration and environment variables, caches and build diagnostics, cross-compilation, registries, packaging, publishing, metadata, CI reproducibility, and stable-versus-nightly feature gates. Use for Cargo.toml, Cargo.lock, .cargo/config.toml, cargo build/check/run/tree/metadata/package/publish, resolver or feature problems, build output and performance, private registries, and beginner Cargo workflows. Route crate selection and supply-chain audits to rust-dependencies, workspace topology to rust-workspace, test design to rust-testing, documentation design to rust-documentation, lint policy to rust-style-clippy, and API compatibility decisions to rust-semver./rust-cliDesign, implement, test, and release production Rust command-line applications, including command contracts, subcommands, configuration precedence, stdin/stdout/stderr, exit codes, file safety, daemon IPC, terminal handling, packaging, and process-level tests. Use when users ask for a Rust CLI, command parser, clap integration, Unix-style pipelines, daemon clients, PTY/TUI behavior, shell completion, or CLI release engineering./rust-code-reviewReview Rust changes for correctness, memory and thread safety, error semantics, unnecessary allocation or cloning, lock scope, API compatibility, test gaps, documentation, and dependency risk, applying the Rust API Guidelines checklist (C-PANIC, C-UNWRAP, C-TRANSMUTE, C-BOOL, C-NEWTYPE, C-COMMON-TRAITS, C-CONVERT, C-SEALED, C-NON-EXHAUSTIVE). Use when reviewing Rust diffs, pull requests, libraries, unsafe boundaries, or production incidents; report actionable findings by severity before summaries, route automated formatting or lint policy to rust-style-clippy, and route API shape decisions (trait sealing, error taxonomy, newtype design, builder patterns) to rust-api-design./rust-concurrencyDesign, implement, diagnose, and test Rust concurrency and parallelism with threads, Send and Sync, locks, atomics, channels, Tokio, Rayon, Crossbeam, bounded backpressure, actor ownership, task supervision, graceful shutdown, runtime diagnostics, and Loom model tests. Use when users ask about shared state, deadlocks, async tasks, CPU parallelism, high concurrency, daemon resource budgets, slow consumers, worker pools, lock-free structures, or concurrent correctness.Other plugins' skills for the same job