# 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.

**Before you start:** You need Rust 1.95 or newer on the stable channel (`rustup update stable`) and an existing Cargo project. Nothing here changes your code; it only adds config files.

1. **Add the config files** (30 seconds)

   Run this from your project root. Files you already have are skipped, never overwritten.

   ```sh title="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
   ```

   - your-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
     - src/
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`.

   ```sh title="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](/Google-Rust-Style-Guide/config/cargo-lints/) page.

   **Workspace:** append the lint tables to your workspace root `Cargo.toml`.

   ```sh title="Terminal"
   curl -fsSL https://daniakash.github.io/Google-Rust-Style-Guide/files/workspace-lints.toml >> Cargo.toml
   ```

   Then opt every member crate in by adding these two lines to its `Cargo.toml`:

   ```toml title="crates/<member>/Cargo.toml"
   [lints]
   workspace = true
   ```

   Or do all members at once:

   ```sh title="Terminal"
   # Run from the workspace root. Adjust crates/* to where your members live.
   for member in crates/*/Cargo.toml; do
     printf '\n[lints]\nworkspace = true\n' >> "$member"
   done
   ```

   See exactly what gets added on the [Cargo.toml lints](/Google-Rust-Style-Guide/config/cargo-lints/) page.

**Caution:** If your `Cargo.toml` already has a `[lints]` or `[workspace.lints]` table, Cargo will report a duplicate key. Merge the tables by hand instead of appending.

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:

   ```sh title="Terminal"
   ln -s AGENTS.md CLAUDE.md
   ```

   If step 1 skipped `AGENTS.md` because you already have one, paste the [kit's AGENTS.md](/Google-Rust-Style-Guide/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:

   ```sh title="Terminal (one time)"
   rustup toolchain install nightly --profile minimal --component rustfmt
   cargo install --locked cargo-deny
   ```

   Then run the three checks:

   ```sh title="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:

   ```text title="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`):

   ```diff lang="rust" title="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:

   ```text title="Terminal"
       Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.03s
   bans ok
   ```

Paste this into Claude Code, Codex, Cursor or any coding agent that can run commands:

```text title="Prompt" wrap
Apply the Google Rust Style Guide kit to this repository.
Follow the instructions at
https://daniakash.github.io/Google-Rust-Style-Guide/_llms-txt/for-coding-agents.txt
Then 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.

**Review the diff:** Agents sometimes silence a warning by editing the lint configuration. The kit's `AGENTS.md` forbids that, but check that `Cargo.toml` lint tables, `clippy.toml`, `rustfmt.toml` and `deny.toml` match the downloaded versions.

## Add it to CI

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

```yaml title=".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
```

## 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](/Google-Rust-Style-Guide/adopting/#existing-codebases) |

## 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:

```sh title="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.

## Next steps

<LinkCard title="How it works" description="The three enforcement layers and how exceptions are recorded." href={`${BASE}/how-it-works/`} />
  <LinkCard title="Human review guide" description="What reviewers still need to check once CI is green." href={`${BASE}/human-review/`} />
  <LinkCard title="Coverage" description="Every guide rule and the check that enforces it." href={`${BASE}/coverage/`} />
  <LinkCard title="Adopting in depth" description="Existing codebases, published libraries and application crates." href={`${BASE}/adopting/`} />