unsafe-checker

Analyze unsafe Rust code for memory safety and FFI issues.

51|6|Updated Mar 28, 2019
One-click install
npx skills add https://github.com/Mte90/dotfiles --skill unsafe-checker-mte90
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: unsafe-checker
Source: https://github.com/Mte90/dotfiles/tree/main/.config/opencode/skills/unsafe-checker
Command: npx skills add https://github.com/Mte90/dotfiles --skill unsafe-checker-mte90

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) and rules (resource) components.

What problem does it solve?

This Skill provides a comprehensive guide and checklist for writing, reviewing, and understanding unsafe Rust code, ensuring memory safety and preventing undefined behavior.

Core Features & Use Cases

  • Unsafe Code Review: Identify common pitfalls and best practices for unsafe blocks and functions.
  • FFI Safety: Detailed rules for safe interaction with C code, including pointer handling, string conversions, and panic safety.
  • Use Case: A developer is implementing a low-level data structure that requires unsafe for performance. They use this Skill to ensure their implementation adheres to Rust's safety invariants and avoids common FFI errors.

Quick Start

Use the unsafe-checker skill to review the provided Rust code snippet for potential memory safety issues.

Frequently Asked Questions about unsafe-checker

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

FAQPage Schema
How do I review unsafe Rust code for memory safety issues?

To review unsafe Rust code, analyze pointer manipulation, data layout, and panic safety. Focus on ensuring adherence to safety invariants and preventing undefined behavior in unsafe blocks and functions.

What are the best practices for FFI safety in Rust?

Best practices for FFI safety involve enforcing strict rules for pointer handling, string conversions, and panic safety at C code boundaries. This prevents undefined behavior when interacting with external functions.

When do I need to use unsafe blocks in Rust?

You need unsafe blocks in Rust when performing operations the compiler cannot verify, such as dereferencing raw pointers or implementing low-level data structures requiring unsafe for performance.

Can this skill check Rust code for undefined behavior?

Yes, it analyzes Rust code to identify potential undefined behavior by enforcing rules for pointer manipulation, data layout, and FFI boundaries, ensuring critical safety invariants are maintained.

What common pitfalls exist when writing unsafe Rust code?

Common pitfalls in unsafe Rust code include improper pointer manipulation, incorrect data layout assumptions, and lacking panic safety. Adhering to safety invariants helps avoid these critical errors during code reviews.