Learn-skills.dev 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 绑定, 未定义行为
install
source · Clone the upstream repo
git clone https://github.com/NeverSight/learn-skills.dev
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/NeverSight/learn-skills.dev "$T" && mkdir -p ~/.claude/skills && cp -r "$T/data/skills-md/actionbook/rust-skills/unsafe-checker" ~/.claude/skills/neversight-learn-skills-dev-unsafe-checker && rm -rf "$T"
manifest:
data/skills-md/actionbook/rust-skills/unsafe-checker/SKILL.mdsource content
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 , |
| 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 |
|---|---|
deref | Valid, aligned, initialized |
| + No aliasing violations |
| Same size, valid bit pattern |
| Correct signature, ABI |
| Synchronization guaranteed |
| 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 , check alignment |
| Invalid bit pattern | Use |
| Missing SAFETY comment | Add |
Deprecated → Better
| Deprecated | Use Instead |
|---|---|
| |
for refs | |
| Raw pointer arithmetic | , |
| Store first |
| or |
| Manual extern | |
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.