unsafe-checker

zhanghandong/rust-skills · updated Apr 8, 2026

$npx skills add https://github.com/zhanghandong/rust-skills --skill unsafe-checker
0 commentsdiscussion
summary

Unsafe Rust code review and FFI soundness checker for identifying memory safety violations.

  • Triggers on 30+ unsafe patterns including raw pointers, transmute, FFI declarations, uninitialized memory, and missing SAFETY documentation
  • Provides reference tables for valid unsafe use cases (FFI, low-level abstractions, performance bottlenecks) and common errors with fixes
  • Covers FFI tooling recommendations (bindgen, cbindgen, PyO3, napi-rs) and deprecated patterns with modern alternatives
skill.md

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 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.

Required Documentation

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

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

Quick Reference

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

Common Errors

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 → Better

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

FFI Crates

Direction Crate
C → Rust bindgen
Rust → C cbindgen
Python PyO3
Node.js napi-rs

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

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.539 reviews
  • Lucas Torres· Dec 20, 2024

    Useful defaults in unsafe-checker — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Ama Nasser· Dec 8, 2024

    I recommend unsafe-checker for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Benjamin Mehta· Nov 27, 2024

    Useful defaults in unsafe-checker — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Ava Chen· Nov 11, 2024

    I recommend unsafe-checker for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Benjamin Diallo· Oct 18, 2024

    Registry listing for unsafe-checker matched our evaluation — installs cleanly and behaves as described in the markdown.

  • Advait Yang· Oct 2, 2024

    Solid pick for teams standardizing on skills: unsafe-checker is focused, and the summary matches what you get after install.

  • Piyush G· Sep 21, 2024

    Keeps context tight: unsafe-checker is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Mia Taylor· Sep 21, 2024

    unsafe-checker is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Chinedu Park· Sep 17, 2024

    unsafe-checker has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Aanya Chawla· Sep 1, 2024

    unsafe-checker fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

showing 1-10 of 39

1 / 4