Rust FFI guide covering calling C with bindgen, exporting Rust with cbindgen, and safe wrappers.
- CCM score
- 68 of 100
- skills.sh installs
- 713
- GitHub stars
- 303
- last updated
- Aug 21, 2026
Own this skill? Claim it
What it does
- Covers calling C from Rust, generating bindings with bindgen, exporting Rust to C with cbindgen, and writing safe wrappers around unsafe FFI
- Includes manual
externdeclarations, abuild.rsbindgen setup, a sys crate layout, and a cbindgen export example - Shows
#[unsafe(no_mangle)]andunsafe externspellings required by edition 2024, with minimum bindgen and cbindgen versions - Designed for Rust developers linking system or vendor C libraries, with pkg-config detection and vendored-source fallback
Install
$ npx -y skills add mohitmishra786/low-level-dev-skills --skill rust-ffi -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
Files
Rust FFI
Purpose
Guide agents through Rust's Foreign Function Interface: calling C from Rust with bindgen, exporting Rust to C with cbindgen, writing safe wrappers, linking libraries via build.rs, and structuring sys crates.
Triggers
- "How do I call a C library from Rust?"
- "How do I use bindgen to generate Rust bindings?"
- "How do I export Rust functions to be called from C?"
- "How do I write a safe wrapper around an unsafe C API?"
- "How do I link a system library in Rust?"
- "What is a sys crate and how do I structure one?"
Workflow
1. Calling C without bindgen (manual declarations)
// Declare external C functions manually
use std::ffi::{c_int, c_char, c_void, CStr, CString};
// `unsafe extern` is required in edition 2024 (and accepted since Rust 1.82)
unsafe extern "C" {
fn strlen(s: *const c_char) -> usize;
fn malloc(size: usize) -> *mut c_void;
fn free(ptr: *mut c_void);
fn my_lib_init(config: *const c_char) -> c_int;
fn my_lib_process(handle: *mut c_void, data: *const u8, len: usize) -> c_int;
fn my_lib_cleanup(handle: *mut c_void);
}
Details
- Repository
- github.com/mohitmishra786/low-level-dev-skills
- Category
- Rust
- First seen
- Jun 3, 2026
Questions
What does the rust-ffi skill help an agent do?
The rust-ffi skill guides an agent through Rust's Foreign Function Interface, covering calls from Rust into C with bindgen, exports from Rust to C with cbindgen, and safe wrappers around unsafe FFI code. It also explains linking system and vendor libraries through build.rs and structuring sys crates.
How do I install the rust-ffi skill?
Run npx -y skills add mohitmishra786/low-level-dev-skills --skill rust-ffi -y in your project. Once installed, rust-ffi lets the agent answer questions about bindgen, cbindgen, extern "C" and sys crates.
Where does rust-ffi stand among Rust skills on Claude Marketplaces?
rust-ffi ranks in the top 100 on the Rust category page on Claude Marketplaces. It focuses on C interoperability, including bindgen and cbindgen configuration and writing safe wrappers around unsafe C APIs.
Can rust-ffi generate bindings to a C library with bindgen?
Yes, rust-ffi shows how to call bindgen from a build.rs script with allowlists, derive options and rerun triggers. It also covers the sys crate layout, where pkg-config is tried first and vendored C source is compiled as a fallback.
More from mohitmishra786/low-level-dev-skills
All 54- Rust Sanitizers Miri713
- Rust Unsafe705
- Pgo695
- Interpreters689
- Cargo Workflows686
- Meson685
- Rust Debugging676
- Cpp Modules669
- Hardware Counters666
- Debug Optimized Builds652
- Rustc Basics649
- Cpp Templates648
- Rust Cross642
- Wasm Emscripten628
- Zig Debugging617
- Zig Build System616
- Wasm Wasmtime599
- Zig Cross598
- Zig Cinterop586
- Cmake2K
- Static Analysis1.4K
- Gdb1.3K
- Llvm1K
- Sanitizers1K
Similar to Rust Ffi
More Rustrust-unsafemohitmishra786/low-level-dev-skills705 installsGuide to writing, reviewing, and auditing unsafe Rust, covering raw pointers, transmute, and sound abstractions.
zig-cinteropmohitmishra786/low-level-dev-skills586 installsZig-to-C interop guide that covers calling C via build-time translation, translate-c header inspection, and ABI-matching types.
m11-ecosystemactionbook/rust-skills3.8K installsStructured guide for choosing and integrating Rust crates, covering language interop, Cargo features, and common crate errors.
bun-ffisecondsky/claude-skills409 installsReference guide for calling C/C++ native libraries from Bun through the bun:ffi module.
memory-safety-patternswshobson/agents12.6K installsCross-language memory-safety patterns covering RAII, ownership, smart pointers, and resource management for Rust, C++, and C.