rust-unsafelisted
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