PluginBench
Skill
Pass
Audit score 90

unsafe-checker

actionbook/rust-skills

Detects and reviews unsafe Rust code patterns, FFI calls, and memory safety issues.

What is unsafe-checker?

A code review skill that identifies unsafe Rust blocks, raw pointers, FFI declarations, and related memory-safety concerns. Use it when auditing Rust code for soundness, validating unsafe abstractions, or checking FFI bindings for correctness.

  • Triggers on unsafe blocks, raw pointers (*mut, *const), and FFI declarations (extern, transmute)
  • Identifies missing or incomplete SAFETY comments and documentation
  • Checks for common unsafe patterns: null dereferences, use-after-free, data races, alignment violations
  • References FFI binding tools (bindgen, cbindgen) and modern safe alternatives (MaybeUninit, NonNull, AtomicT)
  • Provides quick reference tables for safety requirements and deprecated patterns

How to install unsafe-checker

npx skills add https://github.com/actionbook/rust-skills --skill unsafe-checker
Claude Code
Cursor
Windsurf
Cline

How to use unsafe-checker

  1. 1.Install the skill using the provided npm command
  2. 2.Run the skill on Rust files (.rs) in your codebase
  3. 3.Review flagged unsafe blocks and check for SAFETY comments
  4. 4.Consult the quick reference tables for safety requirements by operation type
  5. 5.Replace deprecated patterns with recommended modern alternatives

Use cases

Good for
  • Reviewing FFI bindings to C libraries before merging
  • Auditing low-level abstractions (Vec, Arc implementations) for soundness
  • Validating that unsafe blocks have proper SAFETY comments explaining why they are safe
  • Checking for deprecated unsafe patterns and suggesting modern alternatives
  • Ensuring thread-safety of static mut and custom Send/Sync implementations
Who it's for
  • Rust developers writing or reviewing unsafe code
  • Library maintainers implementing FFI bindings
  • Security auditors checking memory safety
  • Teams enforcing unsafe code standards

unsafe-checker FAQ

When is unsafe Rust actually valid?

Valid uses include FFI (calling C functions), implementing low-level abstractions (Vec, Arc), and performance-critical code where a safe alternative is too slow. Escaping the borrow checker without understanding why is not valid.

What documentation is required for unsafe code?

Unsafe blocks must have a `// SAFETY:` comment explaining why the code is safe. Unsafe functions must have a `/// # Safety` doc comment describing caller requirements.

What are the most common unsafe errors?

Null pointer dereference, use-after-free, data races, alignment violations, invalid bit patterns, and missing SAFETY comments. The skill provides fixes for each.

What should I use instead of deprecated unsafe patterns?

Replace `mem::uninitialized()` with `MaybeUninit<T>`, `static mut` with `AtomicT` or `Mutex`, and manual extern declarations with `bindgen` or `cbindgen`.

Does this skill check FFI correctness?

Yes. It identifies FFI declarations and references bindgen/cbindgen for automatic binding generation, plus checks for correct signatures and ABI compatibility.

Full instructions (SKILL.md)

Source of truth, from actionbook/rust-skills.


name: unsafe-checker description: "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 绑定, 未定义行为" globs: ["**/.rs"] allowed-tools: ["Read", "Grep", "Glob"]

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.

Related skills

More from actionbook/rust-skills and the wider catalog.

COcoding-guidelines logo

coding-guidelines

actionbook/rust-skills

Reference for Rust code style, naming conventions, and best practices from 50 core rules.

3.6k installsAudited
COcore-actionbook logo

core-actionbook

actionbook/rust-skills

Internal support skill for actionbook MCP selectors in Rust documentation research workflows.

1.5k installsAudited
COcore-agent-browser logo

core-agent-browser

actionbook/rust-skills

Internal browser automation CLI for agent workflows requiring interactive page testing and form filling.

1.6k installs
COcore-dynamic-skills logo

core-dynamic-skills

actionbook/rust-skills

Internal orchestrator for generating and managing Rust crate-specific skills from project dependencies.

1.5k installs
ESesp32-firmware-engineer logo

esp32-firmware-engineer

adamlipecz/esp32-firmware-engineer-skill

ESP32 firmware engineering for ESP-IDF projects. Write, review, and debug embedded C/C++ code involving FreeRTOS tasks/queues/timers, GPIO/I2C/SPI/UART/ADC/PWM peripherals, TWAI/CAN, Wi-Fi/BLE networking, OTA updates, Secure Boot and flash encryption, LVGL display integration, build/flash/monitor workflows, logging, crash analysis, memory/code-size optimization, low-power sleep/wakeup design, on-device USB/serial service terminals, and board bring-up. Use when an agent is asked to implement ESP-IDF firmware features, review embedded changes for correctness or race conditions, investigate boot/runtime failures or Guru Meditation panics, interpret serial logs, fix build/link/flash problems, optimize RAM/flash usage, tune deep sleep/light sleep behavior, harden firmware for production, add a service console/CLI, integrate a display with LVGL, or diagnose hardware-software integration issues on ESP32-class devices.

722 installs
APapi-and-interface-design logo

api-and-interface-design

addyosmani/agent-skills

Design stable, hard-to-misuse APIs and interfaces with proven principles and patterns.

43k installs