Tooluck logoTooluck
SKILL.md

rust-port

Agent skill frommorganlinton/BeautifulRust

Port code from C, C++, Python, Go, JavaScript, or TypeScript into idiomatic Rust that keeps the original behavior: ownership instead of manual memory, Result instead of error codes and exceptions, enums instead of flag ints and magic strings, and tests that prove the port matches. Use this whenever the user asks to port, translate, convert, migrate, or rewrite code in Rust ("rewrite this in Rust", "what would this look like in Rust", "move this module to Rust"), even if they don't say "port". Pairs with the rust-best-practices skill, which covers the target code's style.

How to install rust-port

install rust-port
# install the BeautifulRust pack with the skills CLI
npx skills add morganlinton/BeautifulRust

# or add only this skill to Claude Code: copy the folder

skills/rust-port/

# into

~/.claude/skills/rust-port/ (all projects)

.claude/skills/rust-port/ (one project)

skills/rust-port/SKILL.md

MITFull file
1# Rust port
2
3The goal is the Rust a Rust developer would have written to solve the same problem, with
4the same observable behavior. A line-by-line transliteration (C written in Rust syntax,
5or Python with `Box<dyn Any>`) compiles but keeps every problem the original had and adds
6the borrow checker on top. Port the behavior, not the structure.
7
8## 1. Understand the original before writing anything
9
101. **Read the code and its tests**, and anything that calls it, if you have it.
112. **List the observable behavior**: every public function, its inputs, its outputs, and
12 every way it can fail. Include the quiet parts, which are where ports go wrong:
13 ordering of results, how ties break, what happens on empty input, whitespace and case
14 handling, integer limits, and what counts as an error versus a valid edge case.
153. **Note what is incidental**, meaning things the original only does because of its
16 language: manual memory management, out-parameters, `NULL` returns, global state,
17 fixed-size buffers, a class that exists only to group functions, or `isinstance`
18 checks. These don't carry over.
194. If the original has a bug or an ambiguity, keep its behavior, flag it in the porting
20 notes, and let the user decide. A port is not the place to silently fix things.
21
22## 2. Port the tests first
23
24Translate the original tests into Rust tests before porting the implementation. Keep one
25Rust test per original test, with a name that maps back to it, so a reader can check
26…

Excerpt shown under the repository's MIT license.

More skills in BeautifulRust

Keep exploring

Similar skill repositories

Newsletter

Join the Community

Subscribe to our newsletter for the latest news and updates