rmc-unsafe-audit

Audit Rust unsafe blocks for missing SAFETY comments across a workspace.

29|5|Updated Nov 24, 2025
One-click install
npx skills add https://github.com/molaco/rust-code-mcp --skill rmc-unsafe-audit
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rmc-unsafe-audit
Source: https://github.com/molaco/rust-code-mcp/tree/main/skills/rmc-unsafe-audit
Command: npx skills add https://github.com/molaco/rust-code-mcp --skill rmc-unsafe-audit

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It helps you locate Rust unsafe { ... } blocks that lack a SAFETY comment so you can focus review effort on potentially undocumented invariants.

Core Features & Use Cases

  • Workspace-wide unsafe inventory: Surfaces every unsafe { ... } block with its file span, line count, and enclosing function identity.
  • Safety-comment compliance heuristic: Flags blocks where SAFETY is not found within the five source lines preceding the unsafe keyword.
  • Blast-radius prioritization: Weighs risk by computing how many transitive callers touch the enclosing function via recursive_callers_count.
  • Context rendering for review: Pulls surrounding source context with read_file_content to validate whether the comment matches the actual invariant.

Quick Start

Run the workflow by building the workspace hypergraph, then invoke the unsafe audit to list undocumented unsafe blocks for focused code review.

Frequently Asked Questions about rmc-unsafe-audit

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

FAQPage Schema
How do I find undocumented unsafe blocks in a Rust workspace?

Rust unsafe audit tools check for a `SAFETY` comment within the five source lines preceding the `unsafe` keyword. If the heuristic finds no `SAFETY` text in that window, the block is flagged as undocumented for review.

What is the best way to prioritize unsafe code review in Rust?

The best way to prioritize unsafe code review is calculating a blast radius using `recursive_callers_count`. This ranks undocumented `unsafe { ... }` blocks by how many transitive callers touch the enclosing function, weighing risk by exposure.

How does a call graph help audit Rust unsafe blocks?

A call graph helps audit Rust unsafe blocks by building a workspace hypergraph to compute transitive caller counts. This identifies the enclosing function identity for each `unsafe { ... }` span and ranks review priority by blast radius.

Can I audit safety comments across an entire Rust workspace?

Yes, you can audit safety comments across an entire Rust workspace by enumerating every `unsafe { ... }` span. The audit extracts file spans, line counts, and enclosing function identities to return structured findings for review.

What context is needed to review undocumented Rust unsafe blocks?

Reviewing undocumented Rust unsafe blocks requires surrounding source context extracted using `read_file_content`. This pulls the code around the `unsafe` keyword to validate whether an existing `SAFETY` comment matches the actual invariant.