首页/后端开发/unsafe-checker
U

unsafe-checker

by @zhanghandongv1.0.0
3.7(0)

"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, 安全抽象,

RustStatic AnalysisCode QualityMemory SafetyCompiler WarningsGitHub
安装方式
npx skills add zhanghandong/rust-skills --skill unsafe-checker
compare_arrows

Before / After 效果对比

1
使用前

在Rust项目中处理不安全代码块(unsafe)和FFI时,容易引入内存安全漏洞。手动审查耗时且容易遗漏关键问题,存在潜在风险。

使用后

自动检测并审查Rust不安全代码,识别潜在内存安全问题和FFI风险。大幅提升代码安全性,确保系统稳定可靠,避免严重漏洞。

description SKILL.md


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.

forum用户评价 (0)

发表评价

效果
易用性
文档
兼容性

暂无评价,来写第一条吧

统计数据

安装量518
评分3.7 / 5.0
版本1.0.0
更新日期2026年3月16日
对比案例1 组

用户评分

3.7(0)
5
0%
4
0%
3
0%
2
0%
1
0%

为此 Skill 评分

0.0

兼容平台

🔧Claude Code

时间线

创建2026年3月16日
最后更新2026年3月16日