LR

leonardomso/rust-skills

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

653 stars 质量 68 趋势 33MIT

leonardomso/rust-skills 是从 https://github.com/leonardomso/rust-skills. 导入的特工技能候选人

概览

leonardomso/rust-skills 是从 https://github.com/leonardomso/rust-skills. 导入的特工技能候选人

概述(AI 翻译)

265条Rust规则,你的AI编码代理可以用来编写更好的代码。当前版本为Rust 1.96(2024版)。

可与Claude Code、Cursor、Windsurf、Copilot、Codex、Aider、Zed、Amp、Cline以及几乎所有支持技能的代理合作。

为什么

开箱即用,编码代理会写出平均Rust——他们克隆以躲避借用检查器、.unwrap(),而当impl Trait时,他们会用Box ]。这些规则编码了专家Rust的真实样貌:习语、快速且安全。每条规则都小而聚焦,代理只获取与当前代码相关的内容。

安装

就这些。CLI会识别你拥有哪些代理,并将技能安装到正确的位置。

如何使用它

安装后,只需询问你的代理人:

代理会加载相关规则并应用到你的代码中。

看它实际行动

请代理审查类似这样的函数:

加载这些规则后,它知道要取&str代替&String,并删除 无需clone()和分配,并返回Option代替慌乱:

这里面有什么

265条规则,分为26个类别:

分类 规则 涵盖内容

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

Rust Skills

265 Rust rules your AI coding agent can use to write better code. Current for Rust 1.96 (2024 edition).

Works with Claude Code, Cursor, Windsurf, Copilot, Codex, Aider, Zed, Amp, Cline, and pretty much any other agent that supports skills.

Why

Out of the box, coding agents write average Rust — they clone to dodge the borrow checker, .unwrap() everything, and reach for Box when impl Trait would do. These rules encode what expert Rust actually looks like: idiomatic, fast, and safe. Each rule is small and focused, so the agent pulls in only what’s relevant to the code in front of it.

Install

npx add-skill leonardomso/rust-skills

That’s it. The CLI figures out which agents you have and installs the skill to the right place.

How to use it

After installing, just ask your agent:

/rust-skills review this function
/rust-skills is my error handling idiomatic?
/rust-skills check for memory issues
/rust-skills is this unsafe block sound?

The agent loads the relevant rules and applies them to your code.

See it in action

Ask the agent to review a function like this:

// before
fn first_word(s: &String) -> String {
    s.clone().split_whitespace().next().unwrap().to_string()
}

With these rules loaded, it knows to take &str instead of &String, drop the needless clone() and allocation, and return an Option instead of panicking:

// after — applies own-slice-over-vec, own-borrow-over-clone, anti-unwrap-abuse
fn first_word(s: &str) -> Option {
    s.split_whitespace().next()
}

What’s in here

265 rules split into 26 categories:

Category Rules What it covers
Ownership & Borrowing 12 When to borrow vs clone, Arc/Rc, lifetimes
Error Handling 12 thiserror for libs, anyhow for apps, the ? operator
Memory 17 SmallVec, arenas, avoiding allocations, mem::take, drop order
Unsafe Code 7 SAFETY: comments, Miri, MaybeUninit, 2024-edition unsafe
API Design 17 Builder pattern, newtypes, sealed traits, FromIterator
Async 18 Tokio patterns, channels, async fn in traits, cancel safety
Concurrency 4 rayon, scoped threads, atomic ordering, thread-locals
Optimization 12 LTO, inlining, PGO, SIMD
Numeric & Arithmetic 5 Overflow handling, as vs TryFrom, float compare, NonZero
Type Safety 13 Newtypes, parse don’t validate, Deref, Display/Debug
Trait & Generics Design 6 dyn vs generic, associated types, blanket impls, object safety, orphan rule
在 GitHub 查看完整 README

推荐工具

换一个关键词,或者移除筛选条件。

安装

npx skillfish add leonardomso/rust-skills
新手?先看 mcpskill.org 教程 →