Quick start
You’ll end up with Google’s Rust style guide enforced by your formatter, linter and dependency checker, plus instructions your coding agent reads automatically. It takes about five minutes.
-
Add the config files (30 seconds)
Run this from your project root. Files you already have are skipped, never overwritten.
Terminal base=https://daniakash.github.io/Google-Rust-Style-Guide/filesfor f in rustfmt.toml clippy.toml deny.toml rust-toolchain.toml AGENTS.md; doif [ -e "$f" ]; then echo "skipped $f (already exists)"; else curl -fsSLO "$base/$f"; fidoneDirectoryyour-project/
- AGENTS.md instructions for coding agents
- clippy.toml lint thresholds and banned APIs
- deny.toml bans crates that run code before main()
- rust-toolchain.toml pins the stable channel
- rustfmt.toml the guide’s formatting options
- Cargo.toml
Directorysrc/
- …
-
Turn on the lints (1 minute)
Pick your project shape. Your choice is remembered on every page.
Single crate: append the lint tables to your
Cargo.toml.Terminal curl -fsSL https://daniakash.github.io/Google-Rust-Style-Guide/files/crate-lints.toml >> Cargo.tomlSee exactly what gets added on the Cargo.toml lints page.
Workspace: append the lint tables to your workspace root
Cargo.toml.Terminal curl -fsSL https://daniakash.github.io/Google-Rust-Style-Guide/files/workspace-lints.toml >> Cargo.tomlThen opt every member crate in by adding these two lines to its
Cargo.toml:crates/<member>/Cargo.toml [lints]workspace = trueOr do all members at once:
Terminal # Run from the workspace root. Adjust crates/* to where your members live.for member in crates/*/Cargo.toml; doprintf '\n[lints]\nworkspace = true\n' >> "$member"doneSee exactly what gets added on the Cargo.toml lints page.
-
Point your coding agent at it (10 seconds)
Codex, Cursor, Gemini CLI, GitHub Copilot and most other agents read
AGENTS.mdautomatically. Claude Code readsCLAUDE.md, so link it:Terminal ln -s AGENTS.md CLAUDE.mdIf step 1 skipped
AGENTS.mdbecause you already have one, paste the kit’s AGENTS.md into it as a “Rust style” section. -
Verify (2 minutes)
Install nightly rustfmt (for three of the guide’s formatting options) and cargo-deny once:
Terminal (one time) rustup toolchain install nightly --profile minimal --component rustfmtcargo install --locked cargo-denyThen run the three checks:
Terminal cargo +nightly fmtcargo clippy --workspace --all-targets -- -D warningscargo deny check bansExpect a few errors on a brand-new project.
-D warningsturns every lint warning into an error, which is the kit doing its job. A freshcargo new --libreports three:cargo clippy output error: this function could have a `#[must_use]` attributeerror: missing documentation for the crateerror: missing documentation for a functionFixing them takes three lines (a binary crate only needs the
//!line insrc/main.rs):src/lib.rs //! Adds numbers./// Returns the sum of `left` and `right`.#[must_use]pub fn add(left: u64, right: u64) -> u64 {left + right}When everything is green you’ll see:
Terminal Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.03sbans ok
Paste this into Claude Code, Codex, Cursor or any coding agent that can run commands:
Apply the Google Rust Style Guide kit to this repository.Follow the instructions athttps://daniakash.github.io/Google-Rust-Style-Guide/_llms-txt/for-coding-agents.txtThen run cargo +nightly fmt, cargo clippy --workspace --all-targets -- -D warnings,and cargo deny check bans, and fix what they report without editing the lint configuration.The linked file bundles this quick start, the kit’s AGENTS.md, the adoption guide and an explanation of each config file, so the agent learns the whole setup in one request and then downloads the files themselves.
Add it to CI
Section titled “Add it to CI”Make warnings block merges by running the same checks in CI with -D warnings:
name: Styleon: [push, pull_request]
jobs: lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: cargo clippy --workspace --all-targets -- -D warnings
format: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: rustup toolchain install nightly --profile minimal --component rustfmt - run: cargo +nightly fmt --check
deny: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: taiki-e/install-action@v2 with: tool: cargo-deny - run: cargo deny check bansTroubleshooting
Section titled “Troubleshooting”| You see | Why | Do this |
|---|---|---|
Warning: can't set `hex_literal_case = Lower`, unstable features are only available in nightly channel. |
Three of the guide’s rustfmt options only exist on nightly rustfmt | Run cargo +nightly fmt. On stable the warning is harmless and the other options still apply. |
unknown lint: `clippy::...` |
Your toolchain is older than the kit’s tested Rust 1.95 | rustup update stable |
cannot override `workspace.lints` in `lints` |
A member crate has both [lints] workspace = true and its own [lints.*] tables |
Keep workspace = true and relax a lint at the crate root instead: #![expect(clippy::lint_name, reason = "...")] |
duplicate key in Cargo.toml |
Your Cargo.toml already had lint tables |
Merge the appended tables into the existing ones by hand |
error: no such command: `deny` |
cargo-deny is a separate tool | cargo install --locked cargo-deny (or brew install cargo-deny) |
use of a disallowed type `std::sync::Arc` |
The guide asks you to justify shared ownership | Restructure to a single owner, or add #[expect(clippy::disallowed_types, reason = "...")] with the reason |
| Hundreds of warnings | Your codebase predates the kit | Follow the phased rollout for existing codebases |
Remove the kit
Section titled “Remove the kit”Changed your mind? If you added the kit in its own commit, reverting that commit is the cleanest way out. Otherwise, run this from your project root. It only deletes files that are still identical to the kit’s versions, so your own config files and any you edited are kept:
base=https://daniakash.github.io/Google-Rust-Style-Guide/filesfor f in rustfmt.toml clippy.toml deny.toml rust-toolchain.toml AGENTS.md; do if [ -f "$f" ] && curl -fsSL "$base/$f" | cmp -s - "$f"; then rm "$f"; echo "removed $f" elif [ -e "$f" ]; then echo "kept $f (not the kit's version)"; fidoneif [ -L CLAUDE.md ] && [ "$(readlink CLAUDE.md)" = AGENTS.md ] && [ ! -e AGENTS.md ]; then rm CLAUDE.md; fiThen finish by hand:
- In
Cargo.toml, delete everything from the# Google Rust Style Guide lintscomment to the end of the file, and remove[lints] workspace = truefrom member crates if you added it. - If you pasted the kit’s rules into an existing
AGENTS.mdinstead of downloading it, delete that section. - Files reported as “kept” are either yours or edited since you downloaded them. Remove them only if you are sure.
Next steps
Section titled “Next steps”Unofficial community project, not affiliated with or endorsed by Google. TheGoogle Rust Style Guide is published by Google under CC-BY 3.0. This kit is Apache-2.0.