rust-unsafe

Enforce SAFETY comments and minimal unsafe scopes in Rust code.

Updated May 26, 2026
One-click install
npx skills add https://github.com/adelabdelgawad/rust-fullstack-agents --skill rust-unsafe-adelabdelgawad
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-unsafe
Source: https://github.com/adelabdelgawad/rust-fullstack-agents/tree/main/plugins/rusty/skills/rust-unsafe
Command: npx skills add https://github.com/adelabdelgawad/rust-fullstack-agents --skill rust-unsafe-adelabdelgawad

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Unsafe Rust enables powerful optimizations but introduces undefined behavior risks. This skill provides a disciplined approach to using unsafe code, ensuring safety invariants are explicit and maintained.

Core Features & Use Cases

  • SAFETY comment discipline: enforce precise safety contracts for every unsafe operation.
  • Minimal unsafe scope: wrap the smallest possible block to reduce blast radius.
  • Safe wrappers: design safe public APIs that encapsulate unsafe internals behind safe abstractions.
  • FFI and union awareness: audit extern boundaries and union usage to prevent UB across language boundaries.

Quick Start

Identify every unsafe block, add precise SAFETY comments, and wrap unsafe sections behind safe public APIs.

Frequently Asked Questions about rust-unsafe

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a SAFETY comment for an unsafe Rust block?

To write a SAFETY comment for unsafe Rust, document the precise safety invariants and contracts that must hold true for every unsafe operation to prevent undefined behavior. Specify exact preconditions required by the compiler.

What is the best way to minimize the scope of unsafe Rust code?

The best way to minimize unsafe Rust scope is wrapping the smallest possible block inside safe public APIs. This reduces the blast radius by encapsulating unsafe internals behind safe abstractions.

How do I create safe wrappers around raw pointers in Rust?

Create safe wrappers around raw pointers in Rust by designing safe public APIs that encapsulate unsafe internals. Ensure all unsafe operations maintain explicit safety invariants behind these safe abstractions.

How do I prevent undefined behavior when accessing union fields in Rust?

Prevent undefined behavior accessing union fields in Rust by auditing union usage and enforcing explicit safety invariants. Wrap all unsafe union accesses behind safe abstractions with precise SAFETY comments.

Can I use safe Rust abstractions across FFI boundaries?

Yes, you can use safe Rust abstractions across FFI boundaries by auditing extern boundaries and designing safe wrappers. This prevents undefined behavior across language boundaries by encapsulating unsafe FFI internals.