analyze-rust-ffi-crate-surface
About analyze-rust-ffi-crate-surface
A skill for mapping the C-visible symbols exposed by a Rust FFI crate or file to their uses in a C codebase. It produces a report of each symbol's name, type, consuming modules, and whether use is limited to tests.
Key features
- 01Lists C-visible FFI symbols
- 02Finds symbol usage in C modules
- 03Identifies test-only usage
- 04Uses generated headers as a reference
Use cases
- 01Audit an FFI crate's exposed surface
- 02Trace Rust symbols into C modules
- 03Check whether symbols are only used in tests
Install
Copy the command and run it in a terminal.
npx skills add https:/ / github.com/ redisearch/ redisearch --skill analyze-rust-ffi-crate-surfaceAfter installing, type/analyze-rust-ffi-crate-surfacein Claude Code to confirm it loaded.
Details
From the project READMEAnalyze Rust FFI Crate Surface
Compile a list of all C-visible symbols defined in a given Rust FFI crate or file (e.g. an extern "C" fn annotated with #[unsafe(no_mangle)] or a type definition).
Then determine which parts of the C codebase use these symbols.
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
- Read the relevant Rust source files.
- Compile a list of all the FFI symbols defined they expose (e.g.
extern "C" fnannotated with#[unsafe(no_mangle)]or type definitions). You can use the corresponding auto-generated header file insrc/redisearch_rs/headers, if it helps. - For each symbol, determine which modules in the C codebase use it:
- For functions, look for calls to the function in the C codebase.
- For types, check out if they are used as function arguments, field types, or in type casts.
Emit a report that lists, for each symbol, the following information:
- The symbol name.
- The module(s) in the C codebase that use it.
- The type(s) of the symbol (function, type, etc.).
- If it's only used in C/C++ unit tests (i.e. under `tests/)
Auto-generated header files
Each *_ffi Rust crate has a corresponding auto-generated header file in src/redisearch_rs/headers, created by the build.rs script via cbindgen.
The auto-generated header file includes all the FFI symbols defined by the Rust crate, no matter the sub-module they are defined in.