0xmassi/google-rust-style-skill/google-rust-style
- community
Checking that the SKILL.md file is still in the repository.
Google's Rust style guide for coding agents: paste-ready rustfmt.toml, clippy.toml and [lints], the judgement rules no tool checks (module layout, imports, API shape, panics, naming), and where Google overrides common Rust advice. Use when writing or reviewing Rust to Google style, or setting up a Rust crate's lint config.
Install
npx vskill@latest install 0xmassi/google-rust-style-skill/google-rust-styleSKILL.md
Google Rust style
Source: Google Rust Style Guide, read 2026-10-22 at gh-pages 2ac1584. Section links below use G#anchor, short for https://google.github.io/styleguide/rustguide.html#anchor.
This skill holds only what Google adds on top of common Rust advice (borrow before you clone, thiserror for library errors, cargo clippy clean). Pair it with a general Rust skill for the basics. Where common advice disagrees with Google, Google wins (see Overrides).
Out of scope: rules tagged Chrome, Fuchsia or Android (small crates, flat rust_library layout, chromium::import!, no async, no std::thread, fuchsia_sync::Mutex, per-codebase test frameworks).
Library or application
First decide which kind of crate you are in (G#api-design-context):
- Library: used by other projects and solves a general problem. Every API rule here binds.
- Application: one app and one specific problem. API rules are strong recommendations, and simplicity and directness win over reuse.
Rules below marked library follow this split. Every other rule binds both kinds: an application with no outside users still takes the full rustfmt and clippy config except the library block, and every layout, import, error, naming and unsafe rule.
1. Tool config
Run cargo clippy --all-targets --all-features -- -D warnings in CI so every warn below fails the build.
rustfmt.toml. All three options need nightly rustfmt. Stable 1.98 prints "unstable features are only available in nightly" and ignores them, and the guide lets a stable-only codebase skip them. max_width = 100 is already rustfmt's default, so it is not set.
clippy.toml. avoid-breaking-exported-api = false is load-bearing. Without it, wrong_self_convention and ref_option skip pub items, which are exactly the items Google's rules target.
Cargo.toml, every crate. Drop unsafe_code = "forbid" only in the one crate that isolates unsafe code.
Library crates merge these keys into the same two tables.
To take a guide-sanctioned exception, write #[expect(<lint>, reason = "...")] on the item. The reason carries the why, so the item needs no comment.
| Setting | Google rule | Section | |
|---|---|---|---|
imports_granularity = "Module" | A use imports from one module; no :: inside {} | G#use-statement | |
hex_literal_case, format_macro_matchers | Lowercase hex literals; formatted macro matchers | G#formatting-other | |
wildcard_imports | No glob imports. It already exempts Google's allowed cases: use super::* in tests, use Enum::* inside a function, pub use sub::* | G#glob-imports | |
ref_option, plus default borrowed_box and ptr_arg | Take &T, &[T], &str, Option<&T>, not &Box<T>, &Vec<T>, &String, &Option<T> | G#flexible-references | |
default should_implement_trait | impl FromStr rather than an inherent from_str | G#known-traits | |
default derivable_impls | Derive when a derive can express it | G#derive | |
default new_without_default | A type with new() implements Default | G#important-traits | |
derive_partial_eq_without_eq = "allow" | Prefer PartialEq over Eq unless you mean reflexivity. The nursery lint pushes the other way | G#important-traits | |
default wrong_self_convention | as_, to_, into_ take the matching self | G#naming-methods | |
default len_without_is_empty | len() comes with is_empty() | G#expected-api-sets | |
disallowed-methods catch_unwind | catch_unwind is prohibited. The defense-in-depth entry-point wrapper takes an #[expect] | G#catch-unwind | |
disallowed-methods PoisonError | Never reach inside a poisoned mutex | G#poison | |
exhaustive_enums, exhaustive_structs | Public enums and all-pub-field structs used by other teams are #[non_exhaustive] | G#non-exhaustive-enums, G#non-exhaustive-structs | |
must_use_candidate, return_self_not_must_use | #[must_use] on pure functions and on types whose value must be consumed | G#must-use-on-functions, G#must-use-on-types | |
default unnecessary_unwrap | Pattern-match instead of check-then-unwrap | G#dont-check-then-unwrap | |
unwrap_used, allow-unwrap-in-tests | expect over unwrap; tests may panic | G#expect-over-unwrap | |
needless_for_each | A for loop over Iterator::for_each | G#combinator-chains | |
unsafe_code, undocumented_unsafe_blocks, default missing_safety_doc | Unsafe code is isolated in one crate, each block carries // SAFETY:, and unsafe fns document their invariants | G#unsafe, G#writing-doc | |
missing_docs, missing_panics_doc | Document public APIs and every panic on malformed input | G#writing-doc | |
unstable_features | No #![feature]. On stable it is already a hard error; the lint covers nightly builds | G#unstable-features | |
missing_const_for_fn = "allow" | A public fn is const only if it will stay const. The nursery lint pushes the other way | G#const-functions |
2. Judgement rules
No tool can check these. non_exhaustive_omitted_patterns is the lint the guide names for the matching rule, but it is unknown on stable 1.98 and needs a nightly feature, which would break the no-unstable-features rule. That rule stays here as prose.
Modules and imports
- A leaf module with one primary item
Fooismod fooinfoo.rs. G#userdefined-item - Non-leaf modules hold only
moddeclarations and re-exports, plus at most a little glue code. Amod testsor#[cxx::bridge]child still counts as a leaf module. G#non-leaf-modules - Define no preludes. Using a third-party prelude is the reviewer's call. G#glob-imports
- Import a trait inside the function body that uses it, unless the whole file uses it. G#prefer-local-trait-imports
- Call free functions through their module:
use std::mem;thenmem::swap(..). Calling a name directly is fine when the name is already unambiguous (C++ interop) or the module name collides. G#toplevel-functions - Name types unqualified:
use regex::Regex;thenRegex. Use the module path (io::Error) or a rename (IoError) for an ambiguous name, a large type family (rustc'shir), macros and generated code, and huge import lists. G#type-names
Formatting
#[rustfmt::skip]is for hand alignment (matrices, rows of similar lines) and generated code only. Personal taste is not a reason. G#formatting-optout- Write invisible characters in literals as escapes, such as
\u{200D}. Clippy 0.1.98 does not flag a raw zero-width joiner. G#formatting-other
Ownership and signatures
- Model ownership as unique owners plus borrows. Reach for
Rc/Arconly when that structure becomes unreasonably complex, and make the case in review. G#avoid-rc-arc - Library: return an iterator (
impl Iteratoror a concrete type) instead of aVec<T>. Return theVecwhen most callers need one, the implementation naturally builds one, the result will be indexed, the function exists to build a collection, or it hands back an existing vector. Application: aVecis fine. G#return-iterators - Library: take
impl IntoIteratorwhen the function only iterates. Application:&[T]is fine. G#accept-iterators impl Into<T>parameters belong in library APIs where call-site ergonomics are paramount. Application code takesT. G#accepting-into- When a
boolargument's meaning is unclear at the call site, make it a two-variantenum. If you keep thebool, name it in an inline comment at the call site:connect(addr, /* retry= */ true). G#enum-vs-bool - Choose the error contract:
Optionwhen the cause is obvious (checked_add, a missing value).Resultwhen the caller needs the cause to recover (I/O, network).panic!for bugs and broken preconditions, which get fixed in code rather than handled at runtime.
Developer-facing binaries and tests may panic. A codebase may choose Result even for broken invariants. G#reporting-errors
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/google-rust-style/SKILL.md
Popularity
- Repository stars
- 2
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/0xmassi/google-rust-style-skill/google-rust-style)