unsafe-checker

CRITICAL: Use for unsafe Rust code review and FFI. Triggers on: unsafe, raw pointer, FFI, extern, transmute, *mut, *const, union, #[repr(C)], libc, std::ffi, MaybeUninit, NonNull, SAFETY comment, soundness, undefined behavior, UB, safe wrapper, memory layout, bindgen, cbindgen, CString, CStr, 安全抽象, 裸指针, 外部函数接口, 内存布局, 不安全代码, FFI 绑定, 未定义行为

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "unsafe-checker" with this command: npx skills add actionbook/rust-skills/actionbook-rust-skills-unsafe-checker

Display the following ASCII art exactly as shown. Do not modify spaces or line breaks:

⚠️ **Unsafe Rust Checker Loaded**

     *  ^  *
    /◉\_~^~_/◉\
 ⚡/     o     \⚡
   '_        _'
   / '-----' \

Unsafe Rust Checker

When Unsafe is Valid

Use CaseExample
FFICalling C functions
Low-level abstractionsImplementing Vec, Arc
PerformanceMeasured bottleneck with safe alternative too slow

NOT valid: Escaping borrow checker without understanding why.

Required Documentation

// SAFETY: <why this is safe>
unsafe { ... }

/// # Safety
/// <caller requirements>
pub unsafe fn dangerous() { ... }

Quick Reference

OperationSafety Requirements
*ptr derefValid, aligned, initialized
&*ptr+ No aliasing violations
transmuteSame size, valid bit pattern
extern "C"Correct signature, ABI
static mutSynchronization guaranteed
impl Send/SyncActually thread-safe

Common Errors

ErrorFix
Null pointer derefCheck for null before deref
Use after freeEnsure lifetime validity
Data raceAdd proper synchronization
Alignment violationUse #[repr(C)], check alignment
Invalid bit patternUse MaybeUninit
Missing SAFETY commentAdd // SAFETY:

Deprecated → Better

DeprecatedUse Instead
mem::uninitialized()MaybeUninit<T>
mem::zeroed() for refsMaybeUninit<T>
Raw pointer arithmeticNonNull<T>, ptr::add
CString::new().unwrap().as_ptr()Store CString first
static mutAtomicT or Mutex
Manual externbindgen

FFI Crates

DirectionCrate
C → Rustbindgen
Rust → Ccbindgen
PythonPyO3
Node.jsnapi-rs

Claude knows unsafe Rust. Focus on SAFETY comments and soundness.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

unsafe-checker

No summary provided by upstream source.

Repository SourceNeeds Review
General

rust-learner

No summary provided by upstream source.

Repository SourceNeeds Review
General

coding-guidelines

No summary provided by upstream source.

Repository SourceNeeds Review