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

rust-unsafe

/rust-unsafe

Pomaga pisać, przeglądać i audytować unsafe Rust oraz rozumieć surowe wskaźniki, transmute, UnsafeCell i bezpieczne abstrakcje nad kodem unsafe.

Licencja
Apache-2.0
Ostatnia zmiana repozytorium
28.09.2026

Ocena i bezpieczeństwo

100/ 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ść35 / 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 28.09.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ć, przeglądać i audytować unsafe Rust oraz rozumieć surowe wskaźniki, transmute, UnsafeCell i bezpieczne abstrakcje nad kodem unsafe.

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. Contract
  2. Inputs
  3. Procedure
  4. Failure and recovery
  5. Output
Sekcje z nagłówków SKILL.md, w oryginale · 55 linii, 574 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

## Contract

| Field | Bound contract |
|---|---|
| Trigger | Unsafe Rust code is being written, reviewed, or audited, or a user asks what requires `unsafe`, how to write safe wrappers, or how to use raw pointers, transmute, `UnsafeCell`, or `extern` functions. |
| Authority | Read-only. Chat output only. No remote mutation. |
| Side effect | Emits a structured guidance report and pointers to `references/unsafe-patterns.md`. |
| Done | A report is emitted that identifies the unsafe operations, invariants, audit checks, and recommended safe alternatives. |

## Inputs

1. **Code or diff** (required): the unsafe Rust to review.
2. **Audit focus** (optional): raw pointers, transmute, `UnsafeCell`, FFI, `Send`/`Sync`, or safe abstraction.
3. **Test plan** (optional): whether to run the code under Miri.

## Procedure

The `unsafe` keyword enables five capabilities. Match the code against the table before auditing each one.

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

1. **Identify the unsafe capabilities used.** List which capabilities from the table the code uses. Done when: every `unsafe` capability in the code is named.
2. **Check raw pointer invariants.** For each raw pointer dereference, confirm it is non-null, aligned, points to initialized memory, does not violate aliasing, and is valid for the reference lifetime. Done when: all dereferences have documented invariants.
3. **Check unsafe functions and traits.** Verify each `unsafe fn` has a `/// # Safety` contract, each `unsafe trait` impl upholds the trait invariants, and each `unsafe impl Send`/`Sync` is justified by thread safety. Done when: all unsafe items have documented contracts.
4. **Check transmute and `UnsafeCell`.** Confirm the source and target types have the same size, the value is valid for the target type, and `UnsafeCell` uses are protected against concurrent mutation. Done when: transmute and interior-mutability uses are justified.
5. **Apply the audit checklist.** Use the checklist from `references/unsafe-patterns.md` and mark each item. Done when: the checklist is complete for every `unsafe` block.
6. **Recommend Miri tests.** Suggest `cargo +nightly miri test` for the unsafe code and `MIRIFLAGS="-Zmiri-strict-provenance"` for pointer-heavy code. Done when: a test plan is documented.
7. **Emit the report.** List findings, the relevant invariant, and the fix. Done when: the report is complete.

## Failure and recovery

| Failure class | Behavior |
|---|---|
| Missing `// Safety:` comment | Add one that lists every precondition the caller or caller-side code must uphold. |
| Raw pointer violates aliasing | Restructure to avoid simultaneous `&` and `&mut`, or use `UnsafeCell` with a documented ownership scheme. |
| Transmute creates an invalid value | Use safe conversions such as `TryFrom`, `f32::from_bits`, or `u32::from_ne_bytes`. |
| Manual `Send`/`Sync` impl is unsound | Remove the impl or prove thread safety with a Miri or concurrency test. |
| `unsafe` block is too large | Split it so that each `unsafe` operation has its own safety comment. |

## Output

1. A structured report naming each unsafe operation, its invariants, and any missing documentation.
2. A checklist result for each `unsafe` block.
3. A test plan that names Miri or sanitizer commands.
4. 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 6 KB

Wersje

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

Migawka bazy z 13.11.2026 · wersja paczki 7e4986c5906e (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
    Przegląda zmiany w Rust pod kątem poprawności unsafe, bezpieczeństwa, jakości dokumentacji i wierności przeniesienia kodu z C.
  • 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.
  • 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.
  • 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.

Uwagi i zgłoszenia

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