← ClaudeAtlas

port-from-cpplisted

Port C++ into Rust — RAII and smart pointers onto ownership, templates onto generics and traits, exceptions onto Result, the STL onto Rust collections, and the traps (move semantics, implicit conversions, undefined behaviour, iterator invalidation). Use when porting, rewriting, or migrating C++, a C++ library, or a C++ application into Rust, when replacing a C++ module with Rust behind the existing build, or when the user asks how a C++ construct such as unique_ptr, shared_ptr, a template, or an STL container translates to Rust.
rewrite-rs/skills · ★ 1 · AI & Automation · score 74
Install: claude install-skill rewrite-rs/skills
# Port from C++ ## A construct mapping and a boundary, nothing else This skill maps C++ to Rust and owns the C++ boundary. The parity contract, the five phases, and the anti-patterns are `/port-to-rust`, which runs first and stays running through the port. C is a separate skill — the mechanics overlap, the idioms do not — so a C codebase with a `.cpp` extension is still `/port-from-c` territory in everything but the build. ## The end state, and the C++ default `/port-to-rust` names three end states. In C++ terms: A, a standalone Rust binary or library replacing the C++ entirely; B, a Rust core with a permanent C++-callable surface, real when the deliverable is a library other C++ code links; and C, a bridge that carries the migration module by module and is deleted at cut-over. **C is the default for C++**, more than for any other language in this set: a large C++ codebase cannot be replaced in one step, and the seam — a Rust `staticlib` linked into the existing build — lets leaf modules move one at a time. The bridge is disposable scaffolding that must still be *sound*, and that tension is what this skill manages; the mechanics are in `BOUNDARY.md`. ## The traps that break parity silently The body carries these five because each one produces a port that passes a naive test suite and is wrong; the full table is `MAPPING.md`. | Trap | What actually differs | |---|---| | Undefined behaviour was doing something | Signed overflow, strict aliasing violations, reading uninit