
Rust Unsafe
Covers the five unsafe superpowers (raw pointer derefs, unsafe functions, mutable statics, unsafe trait impls, union access) and the patterns you need to write sound unsafe abstractions. Shows raw pointer arithmetic, transmute gotchas, UnsafeCell for interior mutability, and includes an audit checklist that covers alignment, initialization, aliasing, and lifetime validity. The golden rule here is isolating unsafe blocks behind safe APIs that maintain invariants, with Safety comments documenting why each block is sound. Pairs well with Miri for runtime validation. Useful when you're implementing custom allocators, FFI bindings, or performance-critical data structures where the standard library won't cut it.
- skills.sh installs
- 611
- GitHub stars
- 279
- last updated
- Aug 21, 2026
Install
$ npx -y skills add mohitmishra786/low-level-dev-skills --skill rust-unsafe --agent claude-codeInstalls into .claude/skills of the current project.
Files
Rust unsafe
Purpose
Guide agents through writing, reviewing, and reasoning about unsafe Rust: what operations require unsafe, how to write safe abstractions, audit patterns, common pitfalls, and when to reach for unsafe.
Triggers
- "When do I need to use unsafe in Rust?"
- "How do I write a safe abstraction over unsafe code?"
- "How do I audit an unsafe block?"
- "What are the rules for raw pointers in Rust?"
- "What does transmute do and when is it safe?"
- "How do I implement UnsafeCell correctly?"
Workflow
1. The five unsafe superpowers
unsafe grants exactly five capabilities not available in safe Rust:
- Dereference raw pointers (
*const T,*mut T) - Call unsafe functions (including
extern "C"functions) - Access or modify mutable static variables
- Implement unsafe traits (
Send,Sync) - Access fields of unions
Everything else in Rust — including memory allocation, borrowing, closures — follows safe rules even inside unsafe blocks.
2. Raw pointers
// Creating raw pointers (safe — no dereference yet)
let x = 42u32;
let ptr: *const u32 = &x;
let mut_ptr: *mut u32 = &mut some_val as *mut u32;
Sponsors
Details
- Repository
- github.com/mohitmishra786/low-level-dev-skills
- Categories
- Documentation, Rust
- First seen
- Jun 3, 2026
More from mohitmishra786/low-level-dev-skills
All 54- Pgo610
- Interpreters609
- Cargo Workflows608
- Rust Sanitizers Miri604
- Meson603
- Cpp Modules597
- Rust Debugging597
- Hardware Counters590
- Debug Optimized Builds579
- Cpp Templates574
- Rustc Basics567
- Rust Cross565
- Wasm Emscripten559
- Zig Debugging555
- Zig Build System552
- Zig Cross536
- Wasm Wasmtime532
- Zig Cinterop524
- Cmake1.8K
- Static Analysis1.2K
- Gdb1K
- Llvm948
- Sanitizers895
- Core Dumps828