← ClaudeAtlas

rust-unsafelisted

Use when you add or review any unsafe Rust block, FFI boundary (JNI, UniFFI, or hand-rolled extern "C"), raw-pointer arithmetic, transmute, ManuallyDrop, mem::zeroed, ioctl or syscall wrapper, union access, manual unsafe impl Send/Sync, Box::leak, zero-copy buffer or mmap handoff, or any change that removes the crate-level forbid(unsafe_code) attribute from a previously safe crate. Covers the lint floor for unsafe crates, SAFETY comment discipline, panic safety at FFI boundaries, unaligned reads from untrusted bytes, Drop and double-panic hazards, symbol collision in cdylib crates, Miri and Tree Borrows verification, and a review checklist. Triggers on "unsafe", "FFI", "extern", "raw pointer", "transmute", "*mut/*const", "SAFETY comment", "undefined behavior", "no_mangle", "zero-copy", "mmap", "repr(packed)", "alignment", "E0793", "improper_ctypes", "opaque handle", "OwnedFd", or any soundness question.
po4yka/rust-skills · ★ 2 · AI & Automation · score 76
Install: claude install-skill po4yka/rust-skills
# Rust unsafe ## Purpose Use this skill to write, review, and audit `unsafe` Rust. The rules below apply to any workspace. Derive the current unsafe inventory from the source tree before you change it. Do not trust a memory of where unsafe lives. Start every unsafe task with these four commands: ```bash # Which crates promise to contain no unsafe in their own source. rg -l '#!\[forbid\(unsafe_code\)\]' --type rust # Which unsafe a dependency macro injects, which the attribute never sees. cargo +nightly rustc -p <crate> --profile=check -- -Zunpretty=expanded | rg 'unsafe' # Where unsafe actually lives. rg -n 'unsafe\s*\{|unsafe fn|unsafe impl|unsafe extern' --type rust # Which symbols leave the crate unmangled. rg -n '#\[unsafe\(no_mangle\)\]|#\[no_mangle\]|#\[unsafe\(export_name|#\[export_name' --type rust ``` ## Governance: `#![forbid(unsafe_code)]` Every crate that holds pure logic carries `#![forbid(unsafe_code)]` at the crate root. Add the attribute when you create a crate that has no FFI and no OS-level calls. It is cheap, it is checked by the compiler, and an `#[allow]` further down cannot suppress it. A local `#[allow(unsafe_code)]` under the attribute is `error[E0453]: allow(unsafe_code) incompatible with previous forbid`. ### What the attribute covers, and what it does not The lint is checked per lexical span. It governs the crate's own source text. It does not govern the code the crate compiles to. | Where the `unsafe` comes from | Result under `#![forbi