Install
mkdir -p .claude/skills/port-c-module && curl -L -o skill.zip "https://mcp.directory/api/skills/download/2684" && unzip -o skill.zip -d .claude/skills/port-c-module && rm skill.zipInstalls to .claude/skills/port-c-module
About this skill
Port Module Skill
Guide for porting a C module to Rust.
Arguments
The module name to port should be provided as an argument (e.g., /port-module triemap).
Module to port: $ARGUMENTS
Usage
Use this skill when starting to port a C module to Rust.
Instructions
1. Analyze the C Code
First, understand the C module you're porting (look for $ARGUMENTS.c and $ARGUMENTS.h in src/):
- Read the
.cand.hfiles insrc/ - Identify what is exposed by the header file:
- Does the rest of the codebase have access to the inner fields of the data structures defined in this module?
- Are types always passed by value or by reference? A mix?
- Can the corresponding Rust types be passed over the FFI boundary?
- Understand data structures and their lifetimes
- Identify which types and functions this module imports from other modules:
- Determine if those types are implemented in Rust or C
- If those types are implemented in Rust, identify the relevant Rust crate
- If those types are implemented in C, understand if it makes sense to port them first to Rust or if it's preferable to invoke the C implementation from Rust via FFI
- Note any global state or Redis module interactions
- Identify which tests under
tests/are relevant to this module
2. Define A Porting Plan
Create a $ARGUMENTS_plan.md file to outline the steps and decisions for porting the module.
Determine if the C code should be modified, at this stage, to ease the porting process.
For example:
- Introduce getters and setters to avoid exposing inner fields of data structures defined in this module.
- Split the module into smaller, more manageable parts.
3. Create the Rust Crate
cd src/redisearch_rs
cargo new $ARGUMENTS --lib
4. Implement Pure Rust Logic
- Create idiomatic Rust code
- Add comprehensive tests
- Ensure that all C/C++ tests have equivalent Rust tests
- Document public APIs with doc comments
- For performance sensitive code, create microbenchmarks using
criterion - Use
proptestfor property-based testing where appropriate - Testing code should be written with the same care reserved to production code
5. Compare Rust API with C API
- Review the public API of the new Rust module against the C API in the header file
- Ensure that differences can be bridged by adding appropriate wrappers or adapters
- Go back to step 1 if discovered differences cannot be bridged without a re-design
6. Create FFI Wrapper
Create an FFI crate to expose the new Rust module to the C codebase:
cd src/redisearch_rs/c_entrypoint
cargo new ${ARGUMENTS}_ffi --lib
FFI crate should:
- Expose
#[unsafe(no_mangle)] pub extern "C" fnfunctions - Handle null pointers and error cases
- Convert between C and Rust types safely
- Document all unsafe blocks with
// SAFETY:comments
7. Wire Up C Code
- Delete the C header file and its implementation
- Update the rest of the C codebase to import the new Rust header wherever the old C header was used
C header files for Rust FFI crates are auto-generated. No need to use their full path in imports,
use just their name (e.g. #include $ARGUMENTS.h; for ${ARGUMENTS}_ffi)
8. Test The Integration
./build.sh RUN_UNIT_TESTS # C/C++ unit tests
./build.sh RUN_PYTEST # Integration tests
Example: Well-Ported Module
See src/redisearch_rs/trie_rs/ for a high-quality example:
- Pure Rust implementation with comprehensive docs
- Extensive test coverage
- Clean FFI boundary in
c_entrypoint/trie_ffi/
More by RediSearch
View all skills by RediSearch →You might also like
flutter-development
aj-geddes
Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.
drawio-diagrams-enhanced
jgtolentino
Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.
ui-ux-pro-max
nextlevelbuilder
"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."
godot
bfollington
This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.
nano-banana-pro
garg-aayush
Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.
fastapi-templates
wshobson
Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.
Related MCP Servers
Browse all serversGuide your software projects with structured prompts from requirements to code using the waterfall development model and
OpenRouter Image Analysis offers color analyze and image j compatibilities for advanced image analysis using vision mode
The Nuxt SEO MCP server gives AI assistants access to module documentation, configuration examples, and quick reference
Shutter Network enables secure, time-locked message encryption and decryption for trustless communication.
Access HMR Docs for Python: guides, examples, and source code on hot module replacement, hot reloading, and reactive pro
Extend your developer tools with GitHub MCP Server for advanced automation, supporting GitHub Student and student packag
Stay ahead of the MCP ecosystem
Get weekly updates on new skills and servers.