AGENT SKILL

rust-unsafe-ffi

Design and review unsafe Rust, safe wrappers, manual Send or Sync, ABI boundaries, foreign ownership, callbacks, and FFI build integration. Use whenever unsafe code or a foreign interface is introduced, changed, or relied upon. Do not use unsafe merely to bypass borrow checking or for unmeasured optimization.

License 许可
Apache-2.0
所属仓库
RawSocketLabs/rsl
最近更新
2026-11-15
Stars
★ 2
Forks
0

01 前言 Front Matter

name
rust-unsafe-ffi
description
Design and review unsafe Rust, safe wrappers, manual Send or Sync, ABI boundaries, foreign ownership, callbacks, and FFI build integration. Use whenever unsafe code or a foreign interface is introduced, changed, or relied upon. Do not use unsafe merely to bypass borrow checking or for unmeasured optimization.

02 资源文件 2

03 SKILL.md 正文

Review Unsafe Rust and FFI

Establish permission and necessity

  1. Read $rust-core, repository unsafe policy, target ABIs, panic strategy, foreign headers and versions, build scripts, ownership conventions, and existing safety documentation.
  2. Confirm unsafe or FFI is allowed and that a safe or established crate cannot satisfy the requirement adequately.
  3. Read unsafe and FFI review.

Write the safety argument first

State the invariant, who establishes it, who preserves it, and how lifetime, aliasing, initialization, alignment, provenance, concurrency, panic/unwind, drop, and safe-caller interaction uphold it. For FFI also state ABI, layout, calling convention, nullability, lengths, ownership transfer, thread affinity, callback lifetime, error mapping, and foreign reentrancy.

Contain unsafe in the smallest auditable module and expose a safe API whose invariant callers cannot violate without unsafe code. Make every unsafe block justify the local obligation it discharges. Treat manual Send or Sync as a whole-type proof.

Verify

Route tests to $rust-testing, concurrency to $rust-async-concurrency, performance motivation to $rust-performance, embedded ABI work to $rust-embedded, and dependency/build surfaces to $rust-dependencies-security. Use Miri, sanitizers, target ABI tests, compile-fail tests, foreign integration tests, and fuzzing where feasible.

Output

Provide the written safety case, exposed safe contract, ABI and ownership analysis, validation actually run, unavailable evidence, and residual risk.

04 同仓库更多 Skills

RawSocketLabs
RawSocketLabs/rsl

rust-unsafe-ffi

Design and review unsafe Rust, safe wrappers, manual Send or Sync, ABI boundaries, foreign ownership, callbacks, and FFI build integration. Use whenever unsafe code or a foreign interface is introduced, changed, or relied upon. Do not use unsafe merely to bypass borrow checking or for unmeasured optimization.

★ 2
RawSocketLabs
RawSocketLabs/rsl

rust-testing

Select, implement, and assess Rust unit, integration, documentation, property, fuzz, snapshot, concurrency, unsafe, protocol, benchmark, and verification evidence. Use whenever behavior changes or claims need proof. Do not run every tool mechanically when the repository or risk makes it inapplicable.

★ 2
RawSocketLabs
RawSocketLabs/rsl

rust-skill-maintenance

Maintain this modular Rust skills system, including canonical content, manifests, references, profiles, generated adapters, migrations, examples, evaluations, releases, and compatibility. Use when changing the skills repository itself. Do not hand-edit generated adapters.

★ 2
RawSocketLabs
RawSocketLabs/rsl

rust-review

Review Rust diffs, commits, branches, and designs for actionable correctness, soundness, security, compatibility, concurrency, protocol, performance, testing, and maintainability risks. Use for review or pre-merge assessment. Do not modify code unless separately requested.

★ 2
RawSocketLabs
RawSocketLabs/rsl

rust-repository-onboarding

Inspect, interview, profile, configure, and install the modular Rust engineering skills into a repository. Use when adopting or refreshing these skills, generating repository-specific Rust rules, or creating validation workflows. Never finalize policy before repository inspection and user approval.

★ 2
RawSocketLabs
RawSocketLabs/rsl

rust-protocol

Engineer and review binary protocols, wire formats, builders, encoders, parsers, framing, stateful messages, bit ordering, integrity, correction, malformed input, and conformance. Use for protocol or serializer code. Do not apply protocol rules to unrelated in-memory models.

★ 2