mcpField
M
minimize-rust-ffi-crate-surface

minimize-rust-ffi-crate-surface

github.com/redisearchDevelopment6.2k54 installsUpdated 1d ago
Repository

About minimize-rust-ffi-crate-surface

A skill for reducing the exposed C symbol surface of Rust FFI crates or files. It analyzes symbol usage, removes unused definitions, and proposes options for symbols used only by C/C++ unit tests.

Key features

  1. 01Analyzes exposed FFI symbol usage
  2. 02Removes unused Rust definitions
  3. 03Identifies symbols used only in C/C++ tests
  4. 04Outlines options for test-only symbols

Use cases

  1. 01Trim unused symbols from an FFI crate
  2. 02Review a Rust FFI file's exposed symbols
  3. 03Plan handling of symbols used by C/C++ tests

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/redisearch/redisearch --skill minimize-rust-ffi-crate-surface

After installing, type/minimize-rust-ffi-crate-surfacein Claude Code to confirm it loaded.

Details

From the project README

Minimize Rust FFI Crate Surface

Remove C symbols defined in a Rust FFI crate or file that are either unused or only used in C/C++ unit tests.

Arguments

  • <path>: Path to the Rust crate or file.
  • <path 1> <path 2>: Multiple Rust crates/files.

If the path doesn't start with src/, assume it to be in the src/redisearch_rs/c_entrypoint directory. E.g. numeric_range_tree_ffi becomes src/redisearch_rs/numeric_range_tree_ffi. If the path points to a directory, review the documentation of all Rust files in that directory.

Instructions

  • Use analyze-rust-ffi-crate-surface to enumerate and analyze the usage of all the FFI symbols exposed by the Rust crate or file (e.g. extern "C" fn annotated with #[unsafe(no_mangle)] or type definitions).
  • For each unused symbol:
    • Delete its Rust definition.
    • Run C/C++ unit tests to ensure the symbol was indeed unused (via ./build.sh RUN_UNIT_TESTS)
  • For each symbol that is only used in C/C++ unit tests, elaborate a plan to either:
    • Refactor the C/C++ unit tests not to use it.
    • Remove the C/C++ unit tests (or assertions) that rely on it, since they are prying into the implementation details of the Rust crate.
    • Keep the symbol, but mark it as "test only" in the Rust documentation.

Comments

Markdown supported