Przejdź do treści
Biblioteka skilli
Programowanie · Przegląd i audyt

rust-unsafe

/rust-unsafe

Pomaga pisać i przeglądać kod unsafe w Rust: surowe wskaźniki, transmute, UnsafeCell i bezpieczne abstrakcje nad nim.

Repozytorium
dalcom-skills ↗
Licencja
Apache-2.0
Ostatnia zmiana repozytorium
10.11.2026

Ocena i bezpieczeństwo

95/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść30 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
3
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 10.11.2026, bez odwołań do wycofanych modeli i API.

Licencja

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

Co robi i kiedy

Pomaga pisać i przeglądać kod unsafe w Rust: surowe wskaźniki, transmute, UnsafeCell i bezpieczne abstrakcje nad nim.

Oryginalny opis (EN)

Use when writing, reviewing, or auditing unsafe Rust, or understanding raw pointers, transmute, UnsafeCell, and safe abstractions over unsafe code.

Jak działa

  1. The five things unsafe unlocks
  2. Checking raw pointer dereferences
  3. Checking unsafe functions and traits
  4. Checking transmute and UnsafeCell
  5. Running the audit checklist
  6. Planning Miri tests
  7. What you hand back
Sekcje z nagłówków SKILL.md, w oryginale · 43 linii, 536 słów
Podgląd SKILL.md
---
name: rust-unsafe
description: 'Use when writing, reviewing, or auditing unsafe Rust, or understanding raw pointers, transmute, UnsafeCell, and safe abstractions over unsafe code.'
---

# Rust unsafe

You review unsafe Rust and say exactly which invariants each block depends on and where the proof is missing. The `unsafe` keyword unlocks five capabilities, and everything starts by matching the code against them. You never change source files: the result is a chat-output guidance report with pointers into `references/unsafe-patterns.md`.

What you need before starting: the unsafe Rust code or diff under review. An audit focus (raw pointers, transmute, `UnsafeCell`, FFI, `Send`/`Sync`, or safe abstraction) and whether to plan a Miri run are optional and narrow the review.

## The five things unsafe unlocks

| Capability | Example |
|---|---|
| Dereference raw pointers | `*const T`, `*mut T` |
| Call unsafe functions | `extern "C"` functions and `unsafe fn` |
| Access or modify mutable statics | `static mut X` |
| Implement unsafe traits | `unsafe impl Send for MyType` |
| Access union fields | `union` field access |

Name every capability the code uses before auditing any of them. The identification step is done when each `unsafe` capability in the code has been named.

## Checking raw pointer dereferences

For each dereference, confirm the pointer is non-null, aligned, points to initialized memory, does not violate aliasing, and stays valid for the reference lifetime. The step is done when all dereferences carry documented invariants. When a pointer violates aliasing, restructure to avoid simultaneous `&` and `&mut`, or use `UnsafeCell` with a documented ownership scheme.

## Checking unsafe functions and traits

Verify each `unsafe fn` carries a `/// # Safety` contract, each `unsafe trait` impl upholds the trait invariants, and each `unsafe impl Send`/`Sync` is justified by real thread safety. The step is done when all unsafe items have documented contracts. A contract that only says the function is unsafe is not a contract: write down every precondition the caller must uphold. Calls to `alloc`, `alloc_zeroed`, or `dealloc` require a non-zero-size `Layout`; a zero-length buffer must take no allocator path and `Drop` must skip `dealloc` when nothing was allocated. A manual `Send`/`Sync` impl that cannot prove thread safety gets removed or gets a Miri or concurrency test behind it. When an `unsafe` block covers too much, split it so each `unsafe` operation has its own safety comment.

## Checking transmute and UnsafeCell

Confirm source and target types share a size, the value is valid for the target type, and `UnsafeCell` uses are protected against concurrent mutation. The step is done when transmute and interior mutability uses are justified. A transmute that can produce an invalid value becomes a safe conversion instead (`TryFrom`, `f32::from_bits`, `u32::from_ne_bytes`, or similar).

## Running the audit checklist

Apply the checklist from `references/unsafe-patterns.md` to every `unsafe` block and mark each item. The step is done when the checklist is complete for the whole review.

## Planning Miri tests

Suggest `cargo +nightly miri test` for the unsafe code, with `MIRIFLAGS="-Zmiri-strict-provenance"` for pointer-heavy code. The step is done when a test plan names its commands.

## What you hand back

A structured report naming each unsafe operation, its invariants, and missing documentation; a checklist result per `unsafe` block; a test plan naming Miri or sanitizer commands; and pointers to `references/unsafe-patterns.md` for raw pointer, `NonNull`, transmute, and stacked borrows patterns.
Pliki w paczce (3)
  • SKILL.md 4 KB
  • agents/openai.yaml 1 KB
  • references/unsafe-patterns.md 10 KB

Wersje

RepozytoriumWynikLicencja
Ta strona · gosuda/dalcom-skills95Apache-2.0
OutlineDriven/outline-driven-development100Apache-2.0
mohitmishra786/low-level-dev-skills100MIT

Migawka bazy z 13.11.2026 · wersja paczki 1ebdd43b2d9b (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100unsafe-rust
    Uzasadnia i dokumentuje bloki unsafe w Rust: niezmienniki bezpieczeństwa, bezpieczne wrappery i weryfikację przez Miri.
  • 100rs-unsafe
    Przegląda kod unsafe w Rust i FFI: wskaźniki surowe, transmute, union, układ pamięci, komentarze SAFETY i niezdefiniowane zachowanie.
  • 100rust-review
    Audytuje kod Rust pod kątem bloków unsafe, problemów z własnością i ryzyk zależności Cargo, przy przeglądzie kodu lub przed scaleniem zmian.
  • 100rust-review
    Przegląda zmiany w Rust pod kątem poprawności unsafe, bezpieczeństwa, jakości dokumentacji i wierności przeniesienia kodu z C.
  • 100rust
    Pomaga pisać Rust i rozwiązywać błędy borrow checkera, czasów życia i cech: modele własności, thiserror i anyhow, async z Tokio oraz bezpieczne abstrakcje nad unsafe.
  • 100neo-rust
    Pomaga pisać, refaktoryzować, debugować i audytować kod w Rust: własność i pożyczanie, obsługa Result i Option, zbędne clone, przegląd unsafe i architektura.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.