rust-skills

作者 leonardomso已验证

A collection of 265 rules across 26 categories that AI coding agents can use to write idiomatic, fast, and safe Rust.

437
Stars
54
Forks
Python
语言
2026/8/23
添加时间

⚠️ 第三方软件声明

本 Skill 为第三方开源软件,独立托管于 GitHub。SkillTip 仅为信息目录,不控制或维护底层仓库。所显示的安全检查为自动化且范围有限,安装前请自行审查源码。

阅读服务条款

安装

添加到你的 Claude Code skills 目录:

# Add to your Claude Code skills
git clone https://github.com/leonardomso/rust-skills

快速入门

使用 rust-skills 等 Skills 的指南。

安全报告

已验证

上次扫描:—

{
  "status": "PASSED",
  "issues": []
}

README.md

Rust Skills

rules categories Rust license

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<dyn Trait> 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<&str> {
    s.split_whitespace().next()
}

What's in here

265 rules split into 26 categories:

CategoryRulesWhat it covers
Ownership & Borrowing12When to borrow vs clone, Arc/Rc, lifetimes
Error Handling12thiserror for libs, anyhow for apps, the ? operator
Memory17SmallVec, arenas, avoiding allocations, mem::take, drop order
Unsafe Code7SAFETY: comments, Miri, MaybeUninit, 2024-edition unsafe
API Design17Builder pattern, newtypes, sealed traits, FromIterator
Async18Tokio patterns, channels, async fn in traits, cancel safety
Concurrency4rayon, scoped threads, atomic ordering, thread-locals
Optimization12LTO, inlining, PGO, SIMD
Numeric & Arithmetic5Overflow handling, as vs TryFrom, float compare, NonZero
Type Safety13Newtypes, parse don't validate, Deref, Display/Debug
Trait & Generics Design6dyn vs generic, associated types, blanket impls, object safety, orphan rule
Conversions3TryFrom, FromStr, AsMut
Const & Compile-Time4const fn, const vs static, const generics, const {} blocks
Serde8rename_all, default, flatten, enum tagging, validate-on-deserialize
Pattern Matching5let-else, matches!, if-let chains, exhaustive matches
Macros8macro_rules! hygiene, fragment specifiers, proc-macros with syn/quote
Closures5Fn/FnMut/FnOnce bounds, returning impl Fn, move & disjoint capture
Collections4HashMap/BTreeMap/IndexMap, Vec/VecDeque, sets, BinaryHeap
Naming16Following Rust API Guidelines
Testing15Proptest, mockall, criterion, loom, snapshot tests
Docs12Doc examples, intra-doc links, README/crate-doc unification
Observability7tracing over log, spans, structured fields, redacting secrets
Performance13Iterators, entry API, faster hashers, I/O buffering
Project Structure14Workspaces, module layout, features, MSRV
Linting13Clippy config, CI setup, unexpected_cfgs
Anti-patterns15Common mistakes and how to fix them

Each rule has:

  • Why it matters
  • A bad code example
  • A good code example
  • Links to related rules and sources

How it works

The design is built for low token cost and easy auditing:

  • SKILL.md is a lightweight index — every rule listed as a one-line summary, grouped by category, with a link to its file. The agent reads this first.
  • rules/ holds one Markdown file per rule (<prefix>-<name>.md). The agent opens only the handful relevant to your code instead of loading all 218 — progressive disclosure keeps context small.
  • Prefixes (own-, err-, unsafe-, async-, …) map directly to categories, so an agent reviewing async code can pull just async-, conc-, and own- rules.

CLAUDE.md and AGENTS.md are symlinks to SKILL.md, so the same content works across agent conventions.

Manual install

If add-skill doesn't work for your setup, here's how to install manually:

Claude Code

Global (applies to all projects):

git clone https://github.com/leonardomso/rust-skills.git ~/.claude/skills/rust-skills

Or just for one project:

git clone https://github.com/leonardomso/rust-skills.git .claude/skills/rust-skills
OpenCode
git clone https://github.com/leonardomso/rust-skills.git .opencode/skills/rust-skills
Cursor
git clone https://github.com/leonardomso/rust-skills.git .cursor/skills/rust-skills

Or just grab the skill file:

curl -o .cursorrules https://raw.githubusercontent.com/leonardomso/rust-skills/master/SKILL.md
Windsurf
mkdir -p .windsurf/rules
curl -o .windsurf/rules/rust-skills.md https://raw.githubusercontent.com/leonardomso/rust-skills/master/SKILL.md
OpenAI Codex
git clone https://github.com/leonardomso/rust-skills.git .codex/skills/rust-skills

Or use the AGENTS.md standard:

curl -o AGENTS.md https://raw.githubusercontent.com/leonardomso/rust-skills/master/SKILL.md
GitHub Copilot
mkdir -p .github
curl -o .github/copilot-instructions.md https://raw.githubusercontent.com/leonardomso/rust-skills/master/SKILL.md
Aider

Add to .aider.conf.yml:

read: path/to/rust-skills/SKILL.md

Or pass it directly:

aider --read path/to/rust-skills/SKILL.md
Zed
curl -o AGENTS.md https://raw.githubusercontent.com/leonardomso/rust-skills/master/SKILL.md
Amp
git clone https://github.com/leonardomso/rust-skills.git .agents/skills/rust-skills
Cline / Roo Code
mkdir -p .clinerules
curl -o .clinerules/rust-skills.md https://raw.githubusercontent.com/leonardomso/rust-skills/master/SKILL.md
Other agents (AGENTS.md)

If your agent supports the AGENTS.md standard:

curl -o AGENTS.md https://raw.githubusercontent.com/leonardomso/rust-skills/master/SKILL.md

All rules

See SKILL.md for the full list with links to each rule file.

Sources & attribution

These rules are an independent synthesis of official Rust guidance, well-known books, and patterns drawn from widely-used open-source crates. They are not affiliated with or endorsed by the Rust project or any crate author. The text and code examples are original summaries — no substantial content is copied from the sources below.

Official Rust documentation

Books & guides

Tooling

Real-world codebases studied for idioms

  • ripgrep, tokio, serde, clap, polars, axum, cargo, hyper, bevy, rayon, and dtolnay's crates (thiserror, anyhow, syn)

This project is MIT-licensed. Referenced upstream materials remain under their own licenses — the official Rust documentation and API Guidelines are dual MIT / Apache-2.0.

Contributing

PRs welcome. To add or change a rule:

  1. Create rules/<prefix>-<name>.md using a kebab-case id with an existing category prefix (own-, err-, mem-, …).
  2. Follow the format of existing rules: a > one-line summary, then ## Why It Matters, ## Bad, ## Good, and ## See Also (with links that resolve).
  3. Make sure code examples compile on current stable Rust.
  4. Add the rule to the index in SKILL.md (Quick Reference list + the category count) so it stays in sync.
# prefix-rule-name

> One-line imperative summary.

## Why It Matters

Two to four sentences.

## Bad

```rust
// the anti-pattern
```

## Good

```rust
// the recommended pattern
```

## See Also

- [other-rule](https://github.com/leonardomso/rust-skills/blob/main/other-rule.md) - why it's related

License

MIT

常见问题

What is rust-skills?

rust-skills is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by leonardomso. A collection of 265 rules across 26 categories that AI coding agents can use to write idiomatic, fast, and safe Rust. It has 437 GitHub stars.

Is rust-skills safe to use?

Yes. rust-skills passed SkillsLLM's automated security scan — a dependency vulnerability audit plus prompt-injection heuristics — with no high-severity issues. You can read the full report in the Security Report section on this page.

How do I install rust-skills?

Clone the repository with "git clone https://github.com/leonardomso/rust-skills" and add it to your Claude Code skills directory (see the Installation section above). rust-skills ships a SKILL.md manifest, so compatible agents can discover and load it automatically.

What programming language is rust-skills written in?

rust-skills is primarily written in Python. It is open-source under leonardomso on GitHub, so you can review or fork the full source.

Are there alternatives to rust-skills?

Yes. SkillsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh rust-skills against similar tools.

评论 (0)

暂无评论,成为第一个分享想法的人!

ECC

by affaan-m

10

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

242,21936,702JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情
15

An agentic skills framework & software development methodology that works.

234,96620,863Shell
AI 智能体ai-agentsbrainstorming
查看详情

hermes-agent

by NousResearch

10

The agent that grows with you

234,43747,175Python
AI 智能体ai-agentsagent-orchestration
查看详情

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

185,94028,768JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情

cc-switch

by farion1231

3

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

128,8688,826Rust
AI 智能体claude-codeai-tools
查看详情

claude-code

by anthropics

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

120,03119,897Shell
AI 智能体
查看详情

开发者还喜欢

基于喜欢此 Skill 的开发者投票和收藏

ECC

by affaan-m

10

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

242,21936,702JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情
15

An agentic skills framework & software development methodology that works.

234,96620,863Shell
AI 智能体ai-agentsbrainstorming
查看详情

hermes-agent

by NousResearch

10

The agent that grows with you

234,43747,175Python
AI 智能体ai-agentsagent-orchestration
查看详情

n8n

by n8n-io

12

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

201,88160,308TypeScript
MCP 服务器apisai-tools
查看详情

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

185,94028,768JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情

cc-switch

by farion1231

3

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

128,8688,826Rust
AI 智能体claude-codeai-tools
查看详情