unsafe-checker

unsafe-checker

Beliebt

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 绑定, 未定义行为

534Sterne
53Forks
Aktualisiert 1/24/2026
SKILL.md
readonlyread-only
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 绑定, 未定义行为"

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.

You Might Also Like

Related Skills

coding-agent

coding-agent

179Kdev-codegen

Run Codex CLI, Claude Code, OpenCode, or Pi Coding Agent via background process for programmatic control.

openclaw avataropenclaw
Holen
add-uint-support

add-uint-support

97Kdev-codegen

Add unsigned integer (uint) type support to PyTorch operators by updating AT_DISPATCH macros. Use when adding support for uint16, uint32, uint64 types to operators, kernels, or when user mentions enabling unsigned types, barebones unsigned types, or uint support.

pytorch avatarpytorch
Holen
at-dispatch-v2

at-dispatch-v2

97Kdev-codegen

Convert PyTorch AT_DISPATCH macros to AT_DISPATCH_V2 format in ATen C++ code. Use when porting AT_DISPATCH_ALL_TYPES_AND*, AT_DISPATCH_FLOATING_TYPES*, or other dispatch macros to the new v2 API. For ATen kernel files, CUDA kernels, and native operator implementations.

pytorch avatarpytorch
Holen
skill-writer

skill-writer

97Kdev-codegen

Guide users through creating Agent Skills for Claude Code. Use when the user wants to create, write, author, or design a new Skill, or needs help with SKILL.md files, frontmatter, or skill structure.

pytorch avatarpytorch
Holen

Implements JavaScript classes in C++ using JavaScriptCore. Use when creating new JS classes with C++ bindings, prototypes, or constructors.

oven-sh avataroven-sh
Holen

Creates JavaScript classes using Bun's Zig bindings generator (.classes.ts). Use when implementing new JS APIs in Zig with JSC integration.

oven-sh avataroven-sh
Holen