rust-unsafe-ffi
Skill4 starsChanged 2 months agoApache-2.0View on GitHub
Audit Rust unsafe blocks, raw pointers, FFI, layout, and synchronization soundness. Use when a boundary exists or is proposed; never bypass a repository ban on unsafe code.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- full-stack-skills/rust-skillstheir own version, first seen Oct 15, 2026
- botirkhaltaev/botir-skillstheir own version, first seen Jul 24, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- full-stack-skills/rust-skills★ 8same name
- botirkhaltaev/botir-skills★ 4same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository81 other files it gives its agents.
- agent-cli-designSkill
- agent-tool-boundariesSkill
- behavior-first-implementationSkill
- bounded-prototypeSkill
- bounded-pr-sliceSkill
- building-fdd-validationSkill
- context-efficiencySkill
- cross-language-contractsSkill
- cross-platform-agent-instructionsSkill
- design-interviewSkill
- diagnosis-loopSkill
- domain-languageSkill
- edge-cloud-syncSkill
- handoff-continuitySkill
- immutable-pr-reviewSkill
- memory-context-hygieneSkill
- module-designSkill
- orchestrateSkill
- owner-decision-gateSkill
- parallel-portfolioSkill
- pr-gate-loopSkill
- pyo3-async-lifecycleSkill
- pyo3-buffer-performanceSkill
- pyo3-free-threadingSkill
- pyo3-ownership-errorsSkill
- pyo3-wheel-releaseSkill
- python-api-typingSkill
- python-async-concurrencySkill
- python-ci-releaseSkill
- python-data-boundariesSkill
- python-packaging-environmentsSkill
- python-performanceSkill
- python-pytestSkill
- python-reviewSkill
- python-test-designSkill
- python-threading-workersSkill
- python-workflowSkill
- react-components-stateSkill
- react-performanceSkill
- repository-groundingSkill
- rust-api-designSkill
- rust-async-concurrencySkill
- rust-build-diagnosticsSkill
- rust-ci-releaseSkill
- rust-memory-layoutSkill
- rust-nextestSkill
- rust-numerics-simdSkill
- rust-performanceSkill
- rust-protocol-codecsSkill
- rust-python-bindingsSkill
- rust-reviewSkill
- rust-storage-durabilitySkill
- rust-test-designSkill
- rust-workflowSkill
- rust-workspace-dependenciesSkill
- shadcn-react-componentsSkill
- shadcn-svelte-componentsSkill
- simplify-existing-codeSkill
- source-verificationSkill
- svelte-components-runesSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 29
Prefer small unsafe islands behind clear safe abstractions.
- Distinctive: line 41
Read tool limits when choosing evidence.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Rust Unsafe and FFI Review
Begin with the repository's unsafe policy. Where unsafe code is forbidden, preserve that policy and pursue safe APIs or an approved dependency boundary. This skill is an audit workflow, not permission to add unsafe code, relax lints, or assert thread safety.
Find the actual unsafe boundary
Inspect unsafe blocks/functions/impls, FFI declarations, generated code, dependency wrappers, allocation owners, callbacks, and the safe entry points exposing them. Distinguish project-authored unsafe code from generated/dependency internals without assuming either is sound merely because it compiles.
For each operation, identify the caller obligations, invariants established before entry, and invariants the implementation must maintain. A safe wrapper must uphold its guarantees for all inputs reachable through its safe API, including error paths, panic/unwind behavior, reentrancy, and concurrent calls.
Review memory and representation
Check provenance, bounds, allocation lifetime, alignment, initialization, aliasing/exclusivity, valid values, and drop ownership. A non-null pointer is not automatically valid to dereference. A buffer's capacity is not its initialized length. A zeroed byte pattern is not a valid instance of every Rust type. Do not infer stable FFI layout from ordinary Rust struct layout.
Review raw slice construction and pointer arithmetic at zero-length and overflow boundaries. Verify that pointer/length pairs describe the same live allocation. Preserve the distinction between an unaligned read and creating an invalid aligned reference. Check that owning pointers are released exactly once by the matching allocator/foreign API.
For concurrent code, inspect Send/Sync assumptions, atomics, interior mutability, and foreign thread affinity. An unsafe impl is a semantic promise, not a way to satisfy a compiler error. Keep publication/visibility and object lifetime reasoning separate.
Review control flow across FFI
Define how panics and foreign exceptions interact with the chosen ABI. Do not assume catch_unwind catches aborts or arbitrary foreign exceptions. Keep callbacks' lifetimes, user-data ownership, thread constraints, and reentrancy explicit. Do not hold a Rust lock across a callback that can re-enter the protected API unless the design handles it.
Prefer small unsafe islands behind clear safe abstractions. Put a useful safety explanation next to the operation, stating the established invariant rather than repeating that it is safe. Do not expand an unsafe block to cover unrelated work or perform speculative unsafe optimization.
Build complementary evidence
Use targeted Miri tests for supported pure-Rust paths when the toolchain is available and permitted. Use sanitizers or native FFI tests for relevant unsupported/external paths, and a bounded concurrency model when appropriate. These tools find classes of failures on exercised paths; passing them is not a proof of soundness. Do not disable isolation or widen permissions merely to force a test through.
Exercise malformed inputs, zero/large sizes, failed construction, early drop, callback reentry, and concurrent teardown. Keep the safe alternative as a differential baseline when useful.
Return
List the safety invariant, evidence, concrete unsound path if found, and the smallest repair. State tooling/platform gaps explicitly. A speculative concern without a reachable violation should be labeled as such, not promoted to a confirmed defect.
Read tool limits when choosing evidence.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

