- name
SKILL.md
Le fichier du skill reste dans le dépôt de l'éditeur.
Collez la commande copiée dans un terminal. Elle installe ce SKILL.md dans cet agent.
npx skills add morganlinton/BeautifulRust --skill rust-port -a cursor -yCollez la commande copiée dans un terminal. Elle installe ce SKILL.md dans cet agent.
npx skills add morganlinton/BeautifulRust --skill rust-port -a claude-code -yCollez la commande copiée dans un terminal. Elle installe ce SKILL.md dans cet agent.
npx skills add morganlinton/BeautifulRust --skill rust-port -a codex -yCollez la commande copiée dans un terminal. Elle installe ce SKILL.md dans cet agent.
npx skills add morganlinton/BeautifulRust --skill rust-port -a grok -yEnvoyez le message copié dans un chat Grok Bot. Le Bot récupère ce SKILL.md sur GitHub et l'ajoute aux skills que partagent tous vos Bots.
Install this skill: https://github.com/morganlinton/BeautifulRust/tree/HEAD/skills/rust-portDe l'éditeur
The goal is the Rust a Rust developer would have written to solve the same problem, with
the same observable behavior. A line-by-line transliteration (C written in Rust syntax,
or Python with Box<dyn Any>) compiles but keeps every problem the original had and adds
the borrow checker on top. Port the behavior, not the structure.
NULL returns, global state,
fixed-size buffers, a class that exists only to group functions, or isinstance
checks. These don't carry over.Translate the original tests into Rust tests before porting the implementation. Keep one Rust test per original test, with a name that maps back to it, so a reader can check coverage. The tests are the definition of "same behavior". If the original has no tests, write characterization tests from the behavior list in step 1.
Decide the public types and signatures from the behavior list, not from the original's shape. Then implement against the ported tests.
Don't write unsafe or use raw pointers unless the port must talk to C through FFI, and
then confine it as the rust-best-practices skill describes.
(value, error) returns become Result; nil becomes Option; interfaces become
traits; goroutines and channels become threads with std::sync::mpsc or async tasks,
depending on what the original needs.null and undefined become Option; thrown errors become Result; plain
objects become structs; numbers become a sized integer or f64, chosen on purpose.A port that matches the original on every possible input is usually the wrong goal. Match it on the inputs it actually receives, and use Rust's standard library for the rest.
str::lines, str::trim,
str::parse, and char methods, not hand-written copies of Python's splitlines,
strip, int(), or repr(), or of C's locale-dependent isspace and strtol. Where
Rust's behavior differs only on exotic input, such as Unicode digits, non-ASCII
whitespace, or unbounded integers, list the difference in the porting notes instead of
coding around it. Write a compatibility shim only when the user says those inputs occur.Debug, Clone, Display, Error, FromStr,
Default, and IntoIterator for collections). Skip builders, Index impls,
FromIterator, Extend, and custom iterator types unless the original's callers need
them.Differential testing against the original is worth doing, but a few dozen realistic and edge-case inputs answer the question. A fuzzing harness over millions of inputs usually just finds exotic divergences that belong in the notes.
Run these if a Rust toolchain is available, and fix everything before reporting:
cargo build
cargo test
cargo clippy --all-targets -- -D warnings
Every ported test must pass. If the original's tests can be run too, run them and compare results on the same inputs.
Alongside the code, write a short PORTING.md that a reviewer can check in a few
minutes:
For the style of the Rust itself, follow the rust-best-practices skill if it is
installed.
>-
---name: rust-portdescription: >----# skills/rust-port/SKILL.mdFAQ
Téléchargez skills/rust-port/SKILL.md auprès de l'éditeur, ou copiez le chemin et ouvrez le dépôt. PlugMCP répertorie le skill et n'héberge pas le fichier.
L'éditeur le maintient sur https://github.com/morganlinton/BeautifulRust.
Claude, Cursor, Codex et Grok Build peuvent lire un SKILL.md que vous ajoutez depuis le dépôt de l'éditeur. Grok Bot l'installe lorsque vous envoyez dans un chat le lien du dossier GitHub du skill.