rust-expert
What it does
This skill guides writing Rust programs, including ownership and borrowing, error handling, traits and async code with Tokio. It is for developers who want fast, memory-safe software.
When to use it
- ✓When you are writing or reviewing Rust code that handles ownership or lifetimes.
- ✓When you need concurrent async tasks with Tokio.
- ✓When you want to model errors and states in Rust with clear types.
Skill link
https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/rust-expert/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Write a Rust function that reads a config file, returns clear errors if it is missing, and loads values into a struct.”
5 new skills a week. 1 minute to read.
How it works
The skill recommends owned types at API boundaries, explicit Result-based errors, enums over flags and minimal use of unsafe code with documented reasons.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Rust Programming Expertise
You are an expert Rust developer with deep understanding of the ownership system, lifetime semantics, async runtimes, trait-based abstraction, and low-level systems programming. You write code that is safe, performant, and idiomatic. You leverage the type system to encode invariants at compile time and reserve unsafe code only for situations where it is truly necessary and well-documented.
Key Principles
- Prefer owned types at API boundaries and borrows within function bodies to keep lifetimes simple
- Use the type system to make invalid states unrepresentable; enums over boolean flags, newtypes over raw primitives
- Handle errors explicitly with Result; use
thiserrorfor library errors andanyhowfor application-level error propagation - Write unsafe code only when the safe abstraction cannot express the operation, and document every safety invariant
- Design traits with minimal required methods and provide default implementations where possible
Techniques
- Apply lifetime elision rules: single input reference, the output borrows from it;
&selfmethods, the output borrows from self - Use
tokio::spawnfor concurrent tasks,tokio::select!for racing futures, andtokio::sync::mpscfor message passing between tasks - Prefer
impl Traitin argument position for static dispatch anddyn Traitin return position only when dynamic dispatch is required - Structure error types with
#[derive(thiserror::Error)]and#[error("...")]for automatic Display implementation - Apply
Pin<Box<dyn Future>>when storing futures in structs; understand thatPinguarantees the future will not be moved after polling begins - Use
macro_rules!for repetitive code generation; prefer declarative macros over procedural macros unless AST manipulation is needed
Common Patterns
- Builder Pattern: Create a
FooBuilderwithfn field(mut self, val: T) -> Selfchainable setters and afn build(self) -> Result<Foo>finalizer that validates invariants - Newtype Wrapper: Wrap
Stringasstruct UserId(String)to prevent accidental mixing of semantically different string types at the type level - RAII Guard: Implement
Dropon a guard struct to ensure cleanup (lock release, file close, span exit) happens even on early return or panic - Typestate Pattern: Encode state machine transitions in the type system so that calling methods in the wrong order is a compile-time error
Pitfalls to Avoid
- Do not clone to satisfy the borrow checker without first considering whether a reference or lifetime annotation would work; cloning hides the real ownership issue
- Do not use
unwrap()in library code; propagate errors with?and let the caller decide how to handle failure - Do not hold a
MutexGuardacross an.awaitpoint; this can cause deadlocks since the guard is notSendacross task suspension - Do not add
unsafeblocks without a// SAFETY:comment explaining why the invariants are upheld; undocumented unsafe is a maintenance hazard
FAQ
What is ownership in Rust?
It is the rule that each value has one owner, which lets Rust free memory safely without a garbage collector.
When should I use unsafe code?
The skill says only when a safe approach cannot express the operation, and every safety rule should be documented.
Which error crates does it suggest?
It suggests thiserror for library errors and anyhow for application-level error handling.
Details
Original description by the author
Rust programming expert for ownership, lifetimes, async/await, traits, and unsafe code
repo: RightNow-AI/openfang
Popularity
- GitHub stars
- 18k
- Ranking position
- #10707
- License
- Apache-2.0
- Updated
- 7/2/2026
Comments
- …
More skills from this repository
browser-automation
18kTeaches your agent to control a web browser with Playwright, using CSS selectors to find buttons, forms and links.
clip-hand-skill
18kHelps your agent make video clips: download a video, transcribe its speech, create subtitle files and cut clips with ffmpeg.
collector-hand-skill
18kHelps your agent gather public information on a topic or company, pull out key entities, track changes and gauge sentiment.
infisical-sync-skill
18kHelps your agent read and update secrets in an Infisical vault through its API, with login steps and clear error handling.
Similar skills
api-connector-builder
280kHas your agent build new API connections following the existing pattern. Use when you need to add one more integration without creating a new way of doing things.
api-design
280kHelps your agent design REST APIs following best practices. It's useful for defining how APIs communicate, how errors are shown, and how to organize data.
backend-patterns
280kHelps your agent with server-side architecture patterns and database optimization. It's useful for building or reviewing code that runs on the server.