rust-plugins
Skill1 starsChanged 40 days agoMITView on GitHub
Plugin and extensibility systems in Rust — compile-time trait objects, embedded scripting, out-of-process RPC, WebAssembly, and dynamic C-ABI libraries, driven by the trust boundary. Use when designing extensibility, loading third-party code at runtime, supporting user-defined functions, or picking a plugin mechanism. Triggers: cdylib, dlopen, abi_stable, wasm plugin, wasmtime, extism, rhai, UDF.
In this repository42 other files it gives its agents.
- AGENTS.mdAGENTS.md
- addressing-findingsSkill
- auditSkill
- codebase-onboardingSkill
- codex-reviewSkill
- compatibilitySkill
- debuggingSkill
- developSkill
- distributed-racesSkill
- memorySkill
- nix-dev-envSkill
- nix-flakesSkill
- nixosSkill
- nix-packagingSkill
- nix-reviewSkill
- refactoringSkill
- retroSkill
- review-initSkill
- review-rulesSkill
- rust-architecture-reviewSkill
- rust-architectureSkill
- rust-cliSkill
- rust-cloud-nativeSkill
- rust-concurrencySkill
- rust-ecosystemSkill
- rust-embeddedSkill
- rust-errorsSkill
- rust-fintechSkill
- rust-idiomsSkill
- rust-macrosSkill
- rust-mlSkill
- rust-navigationSkill
- rust-ownershipSkill
- rust-performanceSkill
- rust-reviewSkill
- rust-securitySkill
- rust-testingSkill
- rust-traitsSkill
- rust-unsafeSkill
- rust-webSkill
- specsSkill
- sql-reviewSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 52
If "plugins" are a known, first-party set shipped with the host, you don't need dynamic loading at all — a trait + Vec<Box<dyn Plugin>> (or …
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Rust Plugin Systems
How do you let code be added without recompiling the host? Five approaches with very different tradeoffs. Choose by the trust boundary first, performance second — that's the axis people get wrong. Mechanics for the two hard paths are in the sub-files.
When to Use
- Designing an extensibility / plugin mechanism
- Running user- or third-party-supplied code at runtime
- Supporting user-defined functions (UDFs)
- Picking between WASM, dynamic libs, scripting, RPC
Decision: trust first
The first question isn't "how fast" — it's do you trust the plugin code?
Is the plugin code trusted (first-party, vendored, audited)?
├─ NO → you need isolation: WASM (in-process sandbox) or a separate process (RPC).
│ Never load untrusted native code into your address space.
└─ YES → optimize for fit:
├─ compiled together? → trait objects / enum dispatch (no "plugin system" at all)
├─ need native speed + crates → cdylib + C-ABI
├─ end-user-authored logic → embedded scripting (rhai/lua)
└─ multi-language, portable → WASM (even when trusted, for portability)The five approaches
| Approach | Trust needed | Perf | Isolation | Languages | Complexity |
| Trait objects / enum dispatch (compiled in) | n/a (same binary) | native | none | Rust | lowest — not really a plugin system |
| Embedded scripting (rhai, mlua) | medium | slow | partial | the script lang | low |
| Out-of-process + RPC | low | slow (IPC+serde) | strong (crash/resource) | any | high (deploy) |
| WebAssembly (wasmtime, extism) | low | 1.5–3× native | strong (sandbox) | many → wasm | medium |
| cdylib + C-ABI (dlopen) | high | ~native | none (shared address space) | any (C ABI) | medium, unsafe-heavy |
Key truth: cdylib gives zero isolation — a buggy or malicious plugin can segfault or corrupt the host. It's the right pick only for trusted, performance-critical, Rust-ecosystem code (e.g. first-party UDFs). For untrusted plugins, WASM or a separate process is the default even at a perf cost.
If you compile the plugins in: don't build a plugin system
If "plugins" are a known, first-party set shipped with the host, you don't need dynamic loading
at all — a trait + Vec<Box<dyn Plugin>> (or enum dispatch) is simpler, faster, and safe
(→ rust-traits dispatch). Reach for the dynamic mechanisms below only when code must load
without recompiling the host.
The two hard paths
- cdylib + C-ABI — near-native, full crate access, trusted code only. The discipline
(
#[repr(C)], FFI-safe types, panic/allocator/ABI rules) and the saferabi_stable/stabbyalternatives are in ffi-plugins.md. - WebAssembly — sandboxed, portable, untrusted-safe, with a perf and capability cost.
wasmtime(low-level) andextism(batteries-included) in wasm-plugins.md.
Boundaries
- The unsafe FFI mechanics under a cdylib plugin →
rust-unsafe(this skill is the architecture decision; ffi-plugins.md is the plugin-specific layer on top). - A plugin interface is a dynamic port — the same dependency-inversion idea as
rust-architecture, resolved at runtime instead of compile time. - Compile-time polymorphism (the "trait objects" row) →
rust-traits.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

