rust-unsafe

Analyze unsafe Rust blocks and document SAFETY invariants for soundness.

Updated Mar 22, 2026
One-click install
npx skills add https://github.com/cecon123/tg-remote-bot --skill rust-unsafe-cecon123
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-unsafe
Source: https://github.com/cecon123/tg-remote-bot/tree/main/.agents/skills/rust-unsafe
Command: npx skills add https://github.com/cecon123/tg-remote-bot --skill rust-unsafe-cecon123

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Unsafe Rust is powerful but risky; this skill guides engineers to review unsafe blocks, enforce predictable safety, and minimize the unsafe surface across FFI boundaries and low-level code.

Core Features & Use Cases

  • SAFETY commentary requirements for every unsafe block.
  • Encapsulation patterns to minimize unsafe surface and keep unsafely internal.
  • FFI safety guidance and safe wrappers with tests.
  • Use cases include review of high-risk crates, patch verification, and module boundaries during code reviews.

Quick Start

Summarize a risky unsafe block by writing a concise SAFETY rationale and encapsulate it behind a safe API.

Frequently Asked Questions about rust-unsafe

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

FAQPage Schema
How do I review unsafe Rust code blocks to prove soundness?

To review unsafe Rust for soundness, analyze each block to verify safety invariants, document a SAFETY rationale, and confirm safe Rust cannot express the operation. Encapsulate the validated code into private modules with safe wrappers and tests.

What is the best way to minimize unsafe surface area across FFI boundaries?

The best way to minimize unsafe surface across FFI boundaries is encapsulating unsafe code into private modules and exposing safe wrappers. This restricts unsafety to internal boundaries while providing tested, safe public APIs for consumers.

Why do I need to document SAFETY invariants for unsafe Rust operations?

Documenting SAFETY invariants for unsafe Rust is required to prove soundness and explain why safe Rust cannot express the operation. This commentary justifies the unsafe block during code reviews by making the safety contract explicit.

Can I use safe wrappers to encapsulate unsafe Rust in performance-critical libraries?

Yes, you can encapsulate unsafe Rust in performance-critical libraries by writing safe wrappers with tests. This pattern minimizes the unsafe surface, keeping unsafe code internal to ensure predictable safety without sacrificing low-level performance.

When should I encapsulate unsafe Rust into private modules during code reviews?

You should encapsulate unsafe Rust into private modules during code reviews of high-risk crates and FFI-heavy code. This minimizes the unsafe surface, confines unsafety to internal boundaries, and ensures safe public wrappers enforce predictable safety.