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-code

Installs 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:

  1. Dereference raw pointers (*const T, *mut T)
  2. Call unsafe functions (including extern "C" functions)
  3. Access or modify mutable static variables
  4. Implement unsafe traits (Send, Sync)
  5. 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
1yangsonhung avatarnovel-writeryangsonhung/awesome-agent-skillsUse when writing, continuing, revising, or planning novels, characters, and fictional worlds.610skills.sh installs
2spatie avatarlivewire-developmentspatie/freek.devDevelops reactive Livewire 4 components. Activates when creating, updating, or modifying Livewire components; working with wire:model, wire:click, wire:loading,608skills.sh installs
3boshu2 avatarpr-retroboshu2/agentopsLearn from PR outcomes.607skills.sh installs
4marswaveai avatarlistenhub-climarswaveai/skillsListenHub CLI skills router. Routes to the correct skill based on user intent. Triggers on: "make a podcast", "explainer video", "read aloud", "TTS", "generate 602skills.sh installs
5yoanbernabeu avatargrepai-installationyoanbernabeu/grepai-skillsMulti-platform installation guide for GrepAI. Use this skill when installing GrepAI on macOS, Linux, or Windows.598skills.sh installs
6rhavekost avatarnarrative-nonfictionrhavekost/author-toolkitUse when writing self-help books, memoirs, or prescriptive guides with story elements. Trigger on: 'self-help book', 'transformation arc', 'metaphor consistency597skills.sh installs