Skip to content

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.

  1. 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/files
    for f in rustfmt.toml clippy.toml deny.toml rust-toolchain.toml AGENTS.md; do
    if [ -e "$f" ]; then echo "skipped $f (already exists)"; else curl -fsSLO "$base/$f"; fi
    done
    • Directoryyour-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/
        • …
  2. 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.toml

    See exactly what gets added on the Cargo.toml lints page.

  3. Point your coding agent at it (10 seconds)

    Codex, Cursor, Gemini CLI, GitHub Copilot and most other agents read AGENTS.md automatically. Claude Code reads CLAUDE.md, so link it:

    Terminal
    ln -s AGENTS.md CLAUDE.md

    If step 1 skipped AGENTS.md because you already have one, paste the kit’s AGENTS.md into it as a “Rust style” section.

  4. 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 rustfmt
    cargo install --locked cargo-deny

    Then run the three checks:

    Terminal
    cargo +nightly fmt
    cargo clippy --workspace --all-targets -- -D warnings
    cargo deny check bans

    Expect a few errors on a brand-new project. -D warnings turns every lint warning into an error, which is the kit doing its job. A fresh cargo new --lib reports three:

    cargo clippy output
    error: this function could have a `#[must_use]` attribute
    error: missing documentation for the crate
    error: missing documentation for a function

    Fixing them takes three lines (a binary crate only needs the //! line in src/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.03s
    bans ok

Make warnings block merges by running the same checks in CI with -D warnings:

.github/workflows/style.yml
name: Style
on: [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 bans
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

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:

Terminal
base=https://daniakash.github.io/Google-Rust-Style-Guide/files
for 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)"; fi
done
if [ -L CLAUDE.md ] && [ "$(readlink CLAUDE.md)" = AGENTS.md ] && [ ! -e AGENTS.md ]; then rm CLAUDE.md; fi

Then finish by hand:

  • In Cargo.toml, delete everything from the # Google Rust Style Guide lints comment to the end of the file, and remove [lints] workspace = true from member crates if you added it.
  • If you pasted the kit’s rules into an existing AGENTS.md instead 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.

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.