unsafe-checker

Audit unsafe Rust code for safety invariant violations and FFI pitfalls.

3|Updated Mar 22, 2026
One-click install
npx skills add https://github.com/0xharryriddle/codex-field-kit --skill unsafe-checker-0xharryriddle
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: unsafe-checker
Source: https://github.com/0xharryriddle/codex-field-kit/tree/main/archive/upstream/chasebuild-agent-skills/rust/skills/unsafe-checker
Command: npx skills add https://github.com/0xharryriddle/codex-field-kit --skill unsafe-checker-0xharryriddle

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Audits unsafe Rust code to identify safety invariant violations, unsafe aliasing, and risky FFI patterns, helping teams prevent undefined behavior.

Core Features & Use Cases

  • Detects missing SAFETY comments and safety documentation in unsafe blocks and unsafe fns, and flags risky patterns.
  • Verifies invariants around pointers, lifetimes, aliasing, and memory initialization, with guidance for remediation.
  • Scans for common FFI pitfalls, correct data layout, and thread-safety concerns in exported interfaces.
  • Provides structured remediation suggestions and safe wrappers where possible.

Quick Start

Run the Unsafe Checker against your Rust codebase to surface safety gaps and actionable remediation guidance.

Frequently Asked Questions about unsafe-checker

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I audit unsafe Rust code for safety invariant violations?

You can audit unsafe Rust by scanning unsafe blocks and fns to verify pointer alignment, check memory initialization, and enforce explicit SAFETY comments. This surfaces safety invariant violations and risky aliasing patterns, providing structured remediation suggestions to prevent undefined behavior.

What are common FFI pitfalls in Rust unsafe blocks?

Common unsafe Rust FFI pitfalls include incorrect data layout, unsafe aliasing across boundaries, and thread-safety issues in exported interfaces. Scanning for these FFI pitfalls verifies correct data layout and flags risky patterns in FFI bindings for remediation.

Do I need SAFETY comments for all unsafe Rust blocks and functions?

Yes, explicit SAFETY comments are required for unsafe Rust blocks and functions. Auditing unsafe code detects missing safety documentation and requires explicit SAFETY comments to verify non-null pointers, aligned pointers, and lifetime invariants before clearing the code.

How do I verify pointer alignment and lifetimes in unsafe Rust?

To verify pointer alignment and lifetimes in unsafe Rust, you analyze unsafe blocks to check non-null and aligned pointers, validate memory initialization, and enforce lifetime invariants. This identifies unsafe aliasing and provides safe wrappers where possible.

Can this tool check memory initialization invariants in Rust low-level abstractions?

Yes, it checks memory initialization invariants in Rust low-level abstractions. By analyzing unsafe code across libraries and binaries, it verifies initialization invariants and flags risky patterns that could lead to undefined behavior.

What is the best way to prevent undefined behavior in Rust FFI bindings?

The best way to prevent undefined behavior in Rust FFI bindings is to enforce safety invariants, verify non-null and aligned pointers, and scan for common FFI pitfalls. This ensures correct data layout and thread-safety in exported interfaces.