From rust-skills
Reviews unsafe Rust code and FFI bindings for soundness, SAFETY comments, and common errors like null derefs, data races, and alignment violations.
How this skill is triggered — by the user, by Claude, or both
Slash command
/rust-skills:unsafe-checkerThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Display the following ASCII art exactly as shown. Do not modify spaces or line breaks:
AGENTS.mdchecklists/before-unsafe.mdchecklists/common-pitfalls.mdchecklists/review-unsafe.mdexamples/ffi-patterns.mdexamples/safe-abstraction.mdmetadata.jsonrules/_sections.mdrules/_template.mdrules/ffi-01-no-string-direct.mdrules/ffi-02-read-ffi-docs.mdrules/ffi-03-drop-for-c-ptr.mdrules/ffi-04-panic-boundary.mdrules/ffi-05-portable-types.mdrules/ffi-06-string-abi.mdrules/ffi-07-no-drop-external.mdrules/ffi-08-error-handling.mdrules/ffi-09-ref-not-ptr.mdrules/ffi-10-thread-safety.mdrules/ffi-11-packed-ub.mdDisplay the following ASCII art exactly as shown. Do not modify spaces or line breaks:
⚠️ **Unsafe Rust Checker Loaded**
* ^ *
/◉\_~^~_/◉\
⚡/ o \⚡
'_ _'
/ '-----' \
| Use Case | Example |
|---|---|
| FFI | Calling C functions |
| Low-level abstractions | Implementing Vec, Arc |
| Performance | Measured bottleneck with safe alternative too slow |
NOT valid: Escaping borrow checker without understanding why.
// SAFETY: <why this is safe>
unsafe { ... }
/// # Safety
/// <caller requirements>
pub unsafe fn dangerous() { ... }
| Operation | Safety Requirements |
|---|---|
*ptr deref | Valid, aligned, initialized |
&*ptr | + No aliasing violations |
transmute | Same size, valid bit pattern |
extern "C" | Correct signature, ABI |
static mut | Synchronization guaranteed |
impl Send/Sync | Actually thread-safe |
| Error | Fix |
|---|---|
| Null pointer deref | Check for null before deref |
| Use after free | Ensure lifetime validity |
| Data race | Add proper synchronization |
| Alignment violation | Use #[repr(C)], check alignment |
| Invalid bit pattern | Use MaybeUninit |
| Missing SAFETY comment | Add // SAFETY: |
| Deprecated | Use Instead |
|---|---|
mem::uninitialized() | MaybeUninit<T> |
mem::zeroed() for refs | MaybeUninit<T> |
| Raw pointer arithmetic | NonNull<T>, ptr::add |
CString::new().unwrap().as_ptr() | Store CString first |
static mut | AtomicT or Mutex |
| Manual extern | bindgen |
| Direction | Crate |
|---|---|
| C → Rust | bindgen |
| Rust → C | cbindgen |
| Python | PyO3 |
| Node.js | napi-rs |
Claude knows unsafe Rust. Focus on SAFETY comments and soundness.
npx claudepluginhub actionbook/rust-skills --plugin rust-skillsReviews Rust FFI code for type safety, memory layout, string handling, callbacks, and unsafe boundary correctness. Use for extern blocks, #[repr(C)], bindgen, or C/C++ interop.
Audits Rust code for unsafe blocks, ownership and borrowing patterns, concurrency issues, error handling, and Cargo dependency vulnerabilities.
Detects function-local misuse of memory and resource APIs in C, C++, and Rust unsafe — unchecked allocations, double-frees, uninitialized locks, and fd leaks across exec. Use when writing or reviewing low-level code that calls malloc, mmap, pthread_mutex, fopen, or raw FFI pointer APIs.