rust-expert
하는 일
이 스킬은 소유권과 빌림, 오류 처리, 트레이트, Tokio를 쓴 비동기 코드를 포함해 Rust 프로그램을 작성하는 방법을 안내합니다. 빠르고 메모리 안전한 소프트웨어를 원하는 개발자를 위한 스킬입니다.
사용하는 경우
- ✓소유권이나 수명을 다루는 Rust 코드를 작성하거나 검토할 때.
- ✓Tokio로 동시에 실행되는 비동기 작업이 필요할 때.
- ✓명확한 타입으로 Rust에서 오류와 상태를 모델링하고 싶을 때.
스킬 링크
https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/rust-expert/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“설정 파일을 읽고, 파일이 없으면 명확한 오류를 반환하며, 값을 구조체에 불러오는 Rust 함수를 작성해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
스킬은 API 경계에서 소유 타입을 쓰고, 명시적인 Result 기반 오류를 쓰며, 플래그보다 열거형을 쓰고, 이유를 문서화한 채 unsafe 코드를 최소한으로 쓰라고 권장합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 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
자주 묻는 질문
Rust에서 소유권이란 무엇인가요?
각 값에는 하나의 소유자가 있다는 규칙이며, 이 규칙으로 Rust는 가비지 컬렉터 없이도 메모리를 안전하게 해제합니다.
unsafe 코드는 언제 쓰나요?
안전한 방법으로 작업을 표현할 수 없을 때만 쓰며, 모든 안전 규칙을 문서화해야 한다고 스킬은 말합니다.
어떤 오류 크레이트를 제안하나요?
라이브러리 오류에는 thiserror, 애플리케이션 수준 오류 처리에는 anyhow를 제안합니다.
상세 정보
작성자의 원본 설명
Rust programming expert for ownership, lifetimes, async/await, traits, and unsafe code
repo: RightNow-AI/openfang
인기도
- GitHub 스타
- 18k
- 순위
- #10707
- 라이선스
- Apache-2.0
- 업데이트
- 2026. 7. 2.
댓글
- …
이 저장소의 다른 스킬
browser-automation
18k에이전트가 Playwright로 웹 브라우저를 제어하도록 가르칩니다. CSS 선택자로 버튼, 양식, 링크를 찾습니다.
clip-hand-skill
18k에이전트가 영상 클립을 만들도록 돕습니다. 영상을 내려받고, 음성을 텍스트로 옮기고, 자막 파일을 만들고, ffmpeg로 클립을 자릅니다.
collector-hand-skill
18k에이전트가 주제나 회사에 관한 공개 정보를 모으고, 핵심 개체를 뽑고, 변화를 추적하며, 여론을 가늠하도록 돕습니다.
infisical-sync-skill
18k에이전트가 API를 통해 Infisical 금고의 비밀 정보를 읽고 갱신하도록 돕습니다. 로그인 단계와 명확한 오류 처리를 포함합니다.
비슷한 스킬
api-connector-builder
280k에이전트가 기존 패턴을 따라 새로운 API 연결을 만들도록 합니다. 새로운 방식을 도입하지 않고 연동을 하나 더 추가할 때 씁니다.
api-design
280k에이전트가 모범 사례에 따라 REST API를 설계하도록 돕습니다. API가 통신하는 방식, 오류를 보여 주는 방식, 데이터를 정리하는 방식을 정하는 데 유용합니다.
backend-patterns
280k에이전트가 서버 쪽 아키텍처 패턴과 데이터베이스 최적화를 다루도록 돕습니다. 서버에서 실행되는 코드를 만들거나 검토할 때 유용합니다.