Rust Unsafe Boundaries
SkillDev toolsIsolate and review unsafe Rust behind small, documented, testable boundaries with explicit invariants. Use when writing, refactoring, or reviewing unsafe code, raw pointers, unsafe functions, unsafe traits, MaybeUninit, pointer aliasing, panic safety, Miri checks, or safe abstractions over unsafe internals.
Use Rust Unsafe Boundaries in Claude, ChatGPT or Ahel Desktop
Free. Sign in, add Rust Unsafe Boundaries and connect your AI. About a minute.
Also: Claude Code · Cursor · Codex
Then ask your AI: use the Rust Unsafe Boundaries skill
Details
Instructions available. Your AI can read the instructions. Execution depends on the setup they require.
Account requirements not reviewed. Check the skill instructions before use; Ahel provides instructions and does not run this skill.
No other account needed.
Add Ahel to your AI once: Claude, ChatGPT, Cursor, Claude Code or Codex. Then ask it to use this.
What this skill tells your AI
The instructions your AI receives, as published by hashgraph-online/awesome-codex-plugins in plugins/LVTD-LLC/skills/skills/rust-unsafe-boundaries/SKILL.md and read by Ahel’s review.
Use this skill to isolate unsafe Rust behind small, documented, testable boundaries. Unsafe code is acceptable only when a safe API cannot express the needed operation with acceptable correctness and performance.
Core Workflow
- Try the safe design first. Check standard APIs, ownership restructuring, iterators, synchronization primitives, and existing crates.
- State the invariant that safe Rust cannot prove. If the invariant cannot be written down, do not write unsafe code yet.
- Keep unsafe blocks tiny. Put runtime checks and setup in safe code before the block.
- Add a
// SAFETY:comment immediately before each unsafe block explaining why every unsafe operation inside is valid. - Mark a function
unsafe fnonly when callers must uphold extra conditions. Document those conditions in a# Safetysection. - Enable or respect
unsafe_op_in_unsafe_fn; unsafe operations inside unsafe functions should still be wrapped in explicit unsafe blocks. - Test normal behavior, boundary cases, panic paths, and drop behavior. Run Miri when the project supports it.
Boundary Rules
Read references/safety-invariants.md before adding or approving unsafe code.
- Prefer private unsafe internals plus a safe public wrapper.
- Prefer
MaybeUninit<T>over deprecated or ad hoc uninitialized memory patterns. - Never create references from raw pointers unless validity, alignment, initialization, aliasing, and lifetime are all proven.
- Do not use
set_len, pointer arithmetic, orfrom_raw_partswithout proving capacity, initialization, and ownership. - Make panic safety explicit when partially initialized values, manual drops, or length changes are involved.
- Avoid
static mut; preferOnceLock,LazyLock, atomics, or locked state.
Documentation Pattern
/// # Safety
///
/// `ptr` must be non-null, aligned for `T`, initialized, and valid for reads
/// for the returned lifetime. No mutable reference may alias the same value.
pub unsafe fn read_ref<'a, T>(ptr: *const T) -> &'a T {
// SAFETY: The caller guarantees `ptr` satisfies the documented contract.
unsafe { &*ptr }
}
Review Checklist
- Every unsafe block has a local
SAFETYexplanation. - Every
unsafe fnor unsafe trait has a# Safetycontract. - Public safe APIs cannot be used to violate internal invariants.
- Drop, panic, and early-return paths preserve initialization and ownership.
- Tests or Miri cover the dangerous edge, not only the happy path.
Signals
- GitHub stars
- 1k
- Forks
- 316
- Last commit
- Oct 2026
Advanced
- Item type
- skill
- Key
rust-unsafe-boundaries- Source
- github.com/hashgraph-online/awesome-codex-plugins
github.com/hashgraph-online/awesome-codex-plugins