/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,
$ npx -y skills add zhanghandong/rust-skills --skill unsafe-checker --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/unsafe-checker
Context preview
The summary Claude sees to decide when to auto-load this skill.
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,
SKILL.md
unsafe-checker.SKILL.mdname: 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 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.
Read more
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 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.
AI-powered Rust development assistant with meta-cognition framework
Other skills on rust-skills.
- /coding-guidelines
Use when asking about Rust code style or best practices. Keywords: naming, formatting, comment, clippy, rustfmt, lint, code style, best practice, P.NAM, G.FMT, code review, naming convention, variable naming, function naming, type naming, 命名规范, 代码风格, 格式化, 最佳实践, 代码审查, 怎么命名
Open skill - /core-actionbook
Internal support skill for actionbook MCP selectors used by Rust documentation research workflows. Use only when another rust-skills workflow explicitly requests actionbook-backed selectors.
Open skill - /core-agent-browser
Internal support skill for agent-browser CLI workflows used by rust-learner, docs-researcher, and crate-researcher. Use only when browser automation is explicitly required.
Open skill - /core-dynamic-skills
Internal command support for dynamic Rust crate skill management. Use only when explicitly invoked by /sync-crate-skills, /clean-crate-skills, or /update-crate-skill.
Open skill - /core-fix-skill-docs
Internal maintenance support for checking and fixing generated Rust skill documentation references. Use only when explicitly invoked by /fix-skill-docs.
Open skill - /domain-cli
Use when building CLI tools. Keywords: CLI, command line, terminal, clap, structopt, argument parsing, subcommand, interactive, TUI, ratatui, crossterm, indicatif, progress bar, colored output, shell completion, config file, environment variable, 命令行, 终端应用, 参数解析
Open skill

