Sign In
R

Rust Best Practices

@apollographql
Visit Skill
Share:

Apollo GraphQL's rust-best-practices skill: makes your agent write and review Rust by Apollo's handbook (ownership, errors, Clippy, tests, generics).

Security Reviewed

Markdown-only Rust guide with no scripts or API keys; the agent may run cargo (including cargo install) and edit your files.

Install Rust Best Practices in Google Antigravity

Antigravity loads skills from .agents/skills/ in your project or ~/.gemini/config/skills/ for all projects (official docs). Full guide

EasiestOption 1: paste this to your Antigravity agent
Install the "Rust Best Practices" skill for Google Antigravity.
Follow the steps at https://www.antigravityskills.org/install/rust-expert.md (source: https://github.com/apollographql/skills/tree/main/skills/rust-best-practices).
Before running anything, show me what you will download and whether it includes scripts, and wait for my OK.
Install it into this project (.agents/skills/) unless I say global. When done, check that Antigravity lists it as an installed skill.

The agent reads the install file, shows you what it will download and waits for your OK.

Option 2: install it yourself
  1. 1. Download the repository
    git clone --depth 1 https://github.com/apollographql/skills /tmp/apollo-skills && git -C /tmp/apollo-skills log -1 --format=%h -- skills/rust-best-practices

    The second command prints the last commit that changed this skill. We reviewed fd9e4ba; a different hash means the skill changed after our review.

  2. 2. Copy the skill into this project (workspace skill)
    mkdir -p .agents/skills && cp -r /tmp/apollo-skills/skills/rust-best-practices .agents/skills/

    Run from your project root. Antigravity then reads .agents/skills/rust-best-practices/SKILL.md plus its references/ folder (keep both; SKILL.md links to the chapters).

  3. 3. Or install it for all projects (global skill)
    mkdir -p ~/.gemini/config/skills && cp -r /tmp/apollo-skills/skills/rust-best-practices ~/.gemini/config/skills/

    Use this instead of the previous step. For the Antigravity CLI the global folder is ~/.gemini/antigravity-cli/skills/.

  4. 4. Check that Antigravity sees it

    Antigravity 2.0 app: start a new conversation and ask "What skills do you have?"; rust-best-practices should be listed. Antigravity CLI: run /skills (/skills reload in a session that was already open).

The apollographql/skills README documents the Skills CLI, the Claude Code plugin and gh skill, and does not mention Antigravity. These steps copy the plain SKILL.md folder into Antigravity's standard skill folders. No API keys; you need cargo, rustc and rustfmt on PATH for the agent's checks.

Using Claude Code, Cursor or Codex? See other assistants below.

What is Rust Best Practices?

rust-best-practices is a Rust style and review guide for coding agents, published by Apollo GraphQL in its official apollographql/skills repository and based on Apollo's public Rust Best Practices Handbook. It is for Rust developers who want the agent to borrow instead of clone, return Result instead of panicking, keep Clippy clean and name tests well, and to explain its review comments against a written rulebook. What we counted at commit fd9e4ba (2026-10-06; the folder is unchanged at the repository's latest commit aafc894 on 2026-10-14): 10 Markdown files, 2,533 lines / 103,288 bytes. SKILL.md is a 94-line quick reference (skill version 1.1.2); the nine chapters in references/ hold the depth, from Chapter 1 Coding Styles and Idioms (657 lines, the longest) to Chapter 9 Understanding Pointers, with 109 Rust code blocks between them. Chapter 2 has a table of 8 Clippy lints to respect. The skill tells the agent to read all relevant chapters in parallel before reviewing code.

How to use Rust Best Practices?

Copy the folder into Antigravity's skills folder (steps below) and work on Rust as usual: write a function, ask for a review of a file, or ask why a borrow fails. The skill is picked up for six triggers listed in its description: new Rust code, reviews and refactors, borrowing vs cloning decisions, Result-based error handling, performance work, and tests or docs. It can run cargo, rustc and rustfmt (its allowed-tools list) to check what it suggests, for example `cargo clippy --all-targets --all-features --locked -- -D warnings`.

Key features of Rust Best Practices

  • ✓Quick reference in SKILL.md: &T over .clone(), &str / &[T] parameters, small Copy types by value, Cow when ownership is unclear
  • ✓Error rules: Result over panic!, no unwrap()/expect() outside tests, thiserror for libraries, anyhow only for binaries, ? over match chains
  • ✓Clippy discipline: the -D warnings command, 8 lints in a table (redundant_clone, large_enum_variant, needless_collect ...), #[expect] with a reason instead of #[allow]
  • ✓Testing: sentence-style test names, one behaviour per test, doc tests, snapshot testing with cargo insta
  • ✓Generics vs dyn Trait, the type state pattern, comments vs rustdoc, Send/Sync and pointer types
  • ✓9 reference chapters, 2,533 lines in total (we counted)

When to use Rust Best Practices

  1. 1Review a Rust pull request against one consistent, written style guide
  2. 2Remove unnecessary clones and unwrap() calls from production paths
  3. 3Set up workspace-wide Clippy lints in Cargo.toml
  4. 4Design a library error enum with thiserror
  5. 5Add descriptive tests and rustdoc examples to a public API

Installation & Setup Guide

Agent Rules / Prompt Setup

Follow these steps (taken from the project's own docs) to configure Rust Best Practices in your development environment.

Step 1: Skills CLI (README)multi
npx skills add apollographql/skills@rust-best-practices

The README's per-skill install line. The interactive installer lets you pick target agents; the README lists Claude Code, Codex, Cursor, Gemini CLI, Goose and OpenCode.

Step 2: Claude Code plugin (README)claude
/plugin marketplace add apollographql/skills
/plugin install apollo-skills@apollo-marketplace

Installs the whole apollo-skills plugin (version 1.3.1 at our commit; 14 skill folders), then use /apollo-skills:rust-best-practices.

Step 3: GitHub CLI, also for Cursor (README)cursor
gh skill install apollographql/skills rust-best-practices --agent cursor

The README shows --agent claude-code and says --agent also supports Cursor and other hosts; add --pin vX.Y.Z to pin a release.

Usage Example & Verification

Prompt / Request Example
1) README example (Claude Code plugin): /apollo-skills:rust-best-practices
-> What happens: the namespaced slash command loads the skill; in Antigravity there is no namespace, so just mention Rust best practices or the skill name in your request.

2) Our example: "Review src/parser.rs with the Rust best practices skill and fix unnecessary clones and unwrap() calls."
-> What happens: the agent reads chapters 1, 3 and 4 (borrowing, performance, error handling), lists findings with the rule each one breaks, edits the file, and can run cargo clippy to confirm no new warnings. It writes to your file, so review the diff.

3) Our example: "Set up workspace lints for this Cargo workspace following the skill."
-> What happens: the agent follows Chapter 2 (section 2.5, workspace/package lints) and adds [workspace.lints.rust] and [workspace.lints.clippy] sections to Cargo.toml, then runs cargo clippy to see what fails.
Installation Confirmation Method

Ask "What skills do you have?" in a new Antigravity conversation (CLI: /skills) and look for rust-best-practices. Then ask "Which chapter of the Rust best practices skill covers thiserror vs anyhow?"; the answer should be Chapter 4 (Error Handling).

Security Review

Static review
Reviewed Date
2026-10-14
Audited Ref / Commit
fd9e4ba985d241c6ea6d4637892539968a6358a7
Reviewer
antigravityskills.org (static code review)

Markdown-only Rust guide with no scripts or API keys; the agent may run cargo (including cargo install) and edit your files.

Full review: scope, findings, risks
Audit Scope:Static review of apollographql/skills at commit fd9e4ba (2026-10-06; skills/rust-best-practices unchanged at HEAD aafc894 on 2026-10-14): skills/rust-best-practices/SKILL.md and all 9 references/chapter_*.md (commands, links, allowed-tools), README.md, .claude-plugin/plugin.json and marketplace.json, LICENSE.
Key Findings:Instruction-only skill: 10 Markdown files, no scripts. allowed-tools: Bash(cargo:*), Bash(rustc:*), Bash(rustfmt:*), Bash(clippy:*), Read, Write, Edit, Glob, Grep. Commands in the chapters: cargo clippy, cargo test, cargo insta, cargo install flamegraph, cargo install cargo-insta. Links go to docs (rust-lang.org, crates.io, insta.rs, docs.rs) and Apollo's handbook examples. No environment variables or API keys.
Identified Operational Risks & Permissions:Low. The agent edits files when you ask for fixes; cargo builds run dependency build scripts; cargo install fetches crates from crates.io.

Static review at commit fd9e4ba. skills/rust-best-practices holds SKILL.md and 9 Markdown chapters; there are no executable files. The frontmatter limits shell use to cargo, rustc, rustfmt and clippy plus the Read/Write/Edit/Glob/Grep file tools. A grep for curl, wget, subprocess, eval and exec found only Rust documentation text. The only install commands are cargo install flamegraph (Chapter 3, profiling) and cargo install cargo-insta (Chapter 5, snapshot review); both are allowed by Bash(cargo:*). URLs point to documentation sites (doc.rust-lang.org, rust-lang.github.io/rust-clippy, crates.io, insta.rs, docs.rs) and to examples in github.com/apollographql/rust-best-practices. The skill needs no environment variables or credentials. Building or testing your project with cargo compiles your dependencies, including their build.rs scripts, as any Rust build does.

Operational Notes & Known Limitations

Known Limitations

  • •Needs a Rust toolchain with Cargo; SKILL.md frontmatter states compatibility Rust 1.70+, Cargo
  • •Our note: the skill recommends #[expect(clippy::lint)] over #[allow], but the expect attribute only became stable in Rust 1.81, so on 1.70-1.80 that advice does not compile
  • •allowed-tools Bash(cargo:*) also covers cargo install; Chapter 3 shows cargo install flamegraph and Chapter 5 suggests cargo install cargo-insta, so the agent may install crates from crates.io if it follows those sections
  • •It is a style and review guide for existing code, not a Rust tutorial or a project generator
  • •Apollo's own conventions (one assertion per test, anyhow only in binaries) may differ from your team's rules
  • •The README does not mention Antigravity (we searched); the steps below copy the plain folder into Antigravity's skills folder. Difference from the clean-code page on our site: clean-code is language-agnostic; this skill is Rust-only and ships 9 chapters of Rust-specific rules

Frequently Asked Questions

Is the Rust best practices skill safe?

In our static review of commit fd9e4ba it is Markdown only, with no scripts. The agent may run cargo, rustc and rustfmt and edit files. A cargo build compiles your dependencies' build scripts, and cargo install (allowed by the same rule) downloads crates. No API keys.

How do I install it in Antigravity?

Clone apollographql/skills, copy skills/rust-best-practices (with its references/ folder) into .agents/skills/ or ~/.gemini/config/skills/, then ask "What skills do you have?" (CLI: /skills). The README does not mention Antigravity.

Is there a skill literally called "Rust Expert"?

Not in Apollo's repo. rust-pro in sickn33/antigravity-awesome-skills starts with "You are a Rust expert". We cover Apollo's skill because it is vendor-maintained, versioned and backed by 9 reference chapters.

Which Rust version does it need?

SKILL.md says Rust 1.70+. The #[expect] lint attribute it recommends needs Rust 1.81 or newer.

Supported Platforms

antigravityclaudecodexcursorgemini