Skip to content
crustify-rsPublic

About

AI agent that automates C-to-safe-Rust translations and correctness audits at scale, autonomously or with you in the loop

Resources

Stars

6 stars

Watchers

1 watching

Forks

Latest commit

 

History

879 Commits

Folders and files

Repository files navigation

Crustify's logo: a crab that is also a robot

Crustify

Your AI co-translator for automating C-to-Rust work.

Paper on arXiv: 2611.10394 Claude Code plugin Codex supported C to safe Rust 64-bit Linux Python 3.13

Why · Install · Usage · How it works · Results · Paper


Crustify is a plugin for Claude Code and Codex that turns LLMs into specialized C-to-safe-Rust translators. It automates:

  • Migrations. Port whole codebases or a few components that keep working with the remaining C, and offer an API compatible with both Rust and C consumers.
  • Wrappers. A safe, ergonomic Rust API over C you keep.
  • Audits. Undefined behavior, unsound contracts, divergences from the C and other bug classes in Rust that meets C, each with a reproducer.

Why Crustify

  • ✅ Verified empirically in an agentic feedback loop: independent reviewers, tests that pass Miri and the sanitizers, lints and formatters. Every fix comes with a regression test.
  • ⚡ Fast Rust code, never at the cost of safety or correctness.
  • 🎯 Equivalent to the C, without its defects.
  • 🔍 Correctness gaps found against whatever spec is available: documentation, headers, tests, reference implementations.
  • 🧩 Customizable with further objectives in the prompt, such as matching the C's style or maximizing coverage-guided testing.
  • 📈 Improves as it goes: recurring defect classes become checks that run on every later component and stay with your code.
  • 🕹️ Autonomous or supervised: let it run end to end, or step in at any point.

Installation

Crustify runs on 64-bit Linux. It needs Claude Code or Codex, and Python 3.13. Clone the components side by side and install the tools, each on its devel branch; ffibox is a crate the port depends on, so it is only cloned.

git clone https://github.com/crustify-rs/crustify.git
git clone --branch devel https://github.com/crustify-rs/ffibox.git
git clone --branch devel https://github.com/crustify-rs/ffimap.git

python -m pip install -e ffimap

Tip

To skip the setup, templates/docker/ builds an image with everything a port needs: both agent CLIs, CodeQL, bindgen, Miri and the sanitizer toolchains.

Usage

Open Crustify in the checkout of the C codebase, and name the task in your first message: the components to port, the build configuration, and anything else the port must respect.

Claude Code
claude --plugin-dir /path/to/crustify --agent crustify:crustify
Codex

Install the profile once, then open it:

python3 /path/to/crustify/providers/codex/install.py    # add --model-proxy openrouter --model <model> for OpenRouter
codex --profile crustify

Rerun the installer after the checkout changes. It warns when Codex's sandbox cannot start on the host; --sandbox full is for a container.

Other agent harnesses

providers/generic/compose.py prints the whole prompt, with an index of the skills, for any harness that can run shell commands, edit files and spawn sub-agents:

python3 /path/to/crustify/providers/generic/compose.py

How it works

One agent runs the port. It builds the C, decides the scope and the order, spawns subagents to port independent components in parallel and others to review them, and merges their work. The system prompt, agents/crustify.md, gives the requirements of the ported code, functional and non-functional, and the process: work in parallel, review every component against every requirement, learn from earlier findings, and keep STATUS.md current. Everything else is a skill:

group skills
conventions/ the port's files under .crustify/, the anchors that name the C item each Rust item stands in for, the lints, and the language of its texts
tools/ bindgen, ffibox, ffimap

The port ends with .crustify/REPORT.md: the configuration, the boundary between Rust and C, the defects found in the C, the performance numbers and what was verified how.

Results

Crustify's earlier, multi-agent version generated safe bindings for two libraries, with little guidance from one developer overseeing it, as our paper details. Binder and reviewer agents mainly ran Claude Opus 5.5; GPT-6.1 Sol and GPT-6 Astra wrapped a few modules, and Claude Fable 5.1 ran the early reviews.

1,053

public API items wrapped

≥ 98.9%

Rust line coverage

≤ 1.6%

unsafe public API

21

UB defects fixed in review
libgit2 FFmpeg
Public API wrapped 480 of 1,146 items (41.9%) 573 of 1,338 items (42.8%)
Wall-clock time 51.9 h 58.9 h
Cost $2,308 $2,120
unsafe public API (consumer-facing) 42 of 2,663 functions (1.6%) 11 of 2,637 functions (0.4%)
Raw pointers in public API (consumer-facing) 2 functions (0.1%) 16 functions (0.6%)
Tests: unit / equivalence / UB 787 / 489 / 788 968 / 723 / 1,003
Line coverage, Rust / C 98.9% / 46.0% 99.1% / 67.2% (libavutil)
UB defects the reviewers fixed 8 13
Rust LoC ~18K ~19K

Each repository holds the code, the campaign's plan, its review reports and its dashboard.

Repository

Maintainers

  • Marius Momeu, University of California, Berkeley

Citation

@misc{momeu2026crustify,
  title         = {Crustify: Repository-Level Generation of Safe Rust Bindings with {LLM} Agents and Coverage-Guided Testing},
  author        = {Momeu, Marius and Arvinte, Marius and Cornelius, Cory and Sen, Koushik},
  year          = {2026},
  eprint        = {2611.10394},
  archivePrefix = {arXiv},
  primaryClass  = {cs.PL},
  url           = {https://arxiv.org/abs/2611.10394}
}

About

AI agent that automates C-to-safe-Rust translations and correctness audits at scale, autonomously or with you in the loop

Resources

Stars

6 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages