AgentLint Verified 100/100211 Rust repos analyzed

    Rust CLAUDE.md & AGENTS.md Template

    Fast cargo check loops, clippy strictness, and zero-unwrap discipline from 211 Rust repos (including uv & ruff).

    # Rust Project — Rust Workspace Harness
    
    Rust workspace organized into focused crates with Clippy warnings denied in CI.
    
    ## Commands
    
    - Fast compile check: `cargo check -p <crate>`
    - Fast single test: `cargo test -p <crate> <test_name>`
    - Full workspace tests: `cargo test --workspace`
    - Lint & format: `cargo clippy --workspace --all-targets -- -D warnings && cargo fmt --check`
    
    ## Rules
    
    - Don't use `.unwrap()` or `.expect()` in library or production request paths. Instead propagate errors with `?` and structured `thiserror` variants. Because panics crash worker threads under unexpected input.
    - Don't run `cargo test --workspace` after every small edit. Instead run `cargo test -p <crate> <test_name>`. Because workspace builds add minutes to every iteration.
    - Don't suppress Clippy lints with `#[allow(...)]` without a one-line comment explaining the invariant.
    - When changing serialization formats or CLI flags, read `docs/compatibility.md`.
    
    ## Continuity & Safety
    
    - Never commit credentials, local `target/` artifacts, or `CLAUDE.local.md`.
    - Document crate-level design decisions in `HANDOFF.md`.

    Most Adopted Rust Rules Across Real Open-Source Repos

    Measured across 211 public Rust repositories in the 4,533-repo harness study:

    cargo-testtesting

    Use cargo test

    57.8%122 repos
    clippytooling

    Use clippy for linting

    56.4%119 repos
    cargo-fmttooling

    Use cargo fmt / rustfmt for formatting

    46.9%99 repos
    error-handlingpatterns

    Proper error handling with context

    45.0%95 repos
    unit-teststesting

    Write unit tests for all changes

    42.7%90 repos
    integration-teststesting

    Integration tests in tests/ directory

    34.6%73 repos
    tokiotooling

    Tokio async runtime

    34.1%72 repos
    error-handling-resultpatterns

    Use Result<T, E> for error handling

    33.6%71 repos
    Essential Commands (Checks W1 & W7)
    install
    cargo fetch
    fastTest
    cargo test -p <crate> <test_name> -- --nocapture
    fullTest
    cargo test --workspace
    lint
    cargo clippy --workspace --all-targets -- -D warnings && cargo fmt --check
    build
    cargo build --workspace
    Common Rust Agent Pitfalls
    • 01Agents reach for .unwrap() and clone() everywhere to satisfy the borrow checker.
    • 02Running cargo test --all-features on a huge workspace takes 10+ minutes; document targeted -p <crate> commands.

    More Verified Stack Templates