Rust quality
Rust code quality — linting, project structure, anti-patterns, and advanced testing tools. Use when configuring clippy lints, organizing modules and workspaces, reviewing code for common Rust anti-patterns like excessive cloning or unwrap abuse, or setting up proptest, mockall, or criterion. Also use when setting up a new Rust project's Cargo.toml with recommended lint and profile settings. For unit and integration test strategy, see rust-tests.From its SKILL.md
npx -y skills add dawidpereira/rust-skills --skill rust-qualityAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
7.2 KB, ~1.8k tokens by cl100k_base, as published. Nobody here has run it
Rust Quality
Core Question
Is this tested, linted, and organized for the next developer?
Quick Decisions
| Situation | Action |
|---|---|
| New project | Apply default Cargo.toml settings below |
| Adding a feature | Write tests first — see rust-tests for unit/integration strategy |
| Reviewing code | Check anti-patterns index |
| Setting up CI | cargo fmt --check && cargo clippy -- -D warnings && cargo test |
| Organizing modules | Feature-based, flat for small projects |
| Benchmarking | Use criterion, never Instant::now() |
| Mocking dependencies | Extract traits, use mockall |
| Property testing | Use proptest for roundtrip/invariant checks |
| Workspace setup | Inherit lints and deps from workspace root |
Default Cargo.toml Settings
Apply these settings to every new Rust project:
[package]
edition = "2024"
rust-version = "1.85"
[lints.clippy]
correctness = "deny"
suspicious = "warn"
style = "warn"
complexity = "warn"
perf = "warn"
[profile.release]
opt-level = 3
lto = "fat"
codegen-units = 1
panic = "abort"
strip = true
[profile.dev.package."*"]
opt-level = 3
For workspaces, define lints at the root and inherit:
# workspace Cargo.toml
[workspace.lints.clippy]
correctness = "deny"
suspicious = "warn"
style = "warn"
complexity = "warn"
perf = "warn"
# member Cargo.toml
[lints]
workspace = true
Clippy Lint Levels
Deny: correctness
Hard errors for code that is outright wrong. Catches infinite iterators, NaN comparisons, impossible conditions, and invalid regex. Never allow these.
[lints.clippy]
correctness = "deny"
Warn: suspicious, style, complexity, perf
Soft warnings for likely bugs, non-idiomatic patterns, unnecessary complexity, and performance anti-patterns.
[lints.clippy]
suspicious = "warn"
style = "warn"
complexity = "warn"
perf = "warn"
Selective: pedantic
Enable pedantic as a baseline, then disable noisy lints:
[lints.clippy]
pedantic = "warn"
missing_errors_doc = "allow"
missing_panics_doc = "allow"
module_name_repetitions = "allow"
must_use_candidate = "allow"
too_many_lines = "allow"
Additional recommended lints
[lints.clippy]
undocumented_unsafe_blocks = "warn"
[lints.rust]
missing_docs = "warn"
For published crates, add cargo = "warn" to catch missing metadata and wildcard
dependencies.
Project Structure Quick Reference
Small projects (< 10 files): flat
src/
├── main.rs
├── lib.rs
├── config.rs
├── database.rs
└── error.rs
Medium projects (10-20 files): feature-based modules
src/
├── main.rs # Thin entry point
├── lib.rs # Re-exports, module declarations
├── user/
│ ├── mod.rs
│ ├── model.rs
│ ├── repository.rs
│ └── service.rs
├── order/
│ ├── mod.rs
│ ├── model.rs
│ └── service.rs
└── shared/
├── mod.rs
├── error.rs
└── database.rs
Large projects: workspace
my-project/
├── Cargo.toml # [workspace] with shared lints/deps
├── crates/
│ ├── core/
│ ├── api/
│ └── cli/
└── tests/
Visibility rules
| Scope | Keyword | Use for |
|---|---|---|
| Public API | pub | Types and functions users need |
| Crate-internal | pub(crate) | Shared implementation details |
| Parent-only | pub(super) | Sibling submodule helpers |
| Private | (default) | Everything else |
Key patterns
- Keep
main.rsthin, logic inlib.rsfor testability. - Organize by feature (user/, order/), not by type (models/, services/).
- Use
pub usere-exports inmod.rsto create clean public APIs. - Create a
preludemodule for commonly used types in libraries. - Put multiple binaries in
src/bin/. - Use
mod.rsfor complex modules, adjacent files for simple ones.
Usage Scenarios
Scenario 1: Setting up a new Rust project
- Apply default Cargo.toml settings (edition, lints, profiles).
- Create
src/lib.rswith module declarations andsrc/main.rsas thin entry point. - Add
rustfmt.tomlwithedition = "2024"andmax_width = 100. - Set up CI:
cargo fmt --check && cargo clippy -- -D warnings && cargo test. - Structure tests:
#[cfg(test)] mod testsin each file,tests/for integration.
Scenario 2: Reviewing Rust code for quality
- Check the anti-patterns index for common issues.
- Verify all public items have documentation.
- Confirm tests follow arrange/act/assert with descriptive names.
- Look for
.unwrap()in non-test code (use?or.expect()with context). - Ensure dependencies are behind traits for testability.
- Run
cargo clippy -- -D warningsand fix all warnings.
Scenario 3: Adding tests to existing code
- Decide test boundaries: see rust-tests → Quick Decisions for unit vs integration.
- Property tests:
proptest!for roundtrip, idempotence, and invariant properties. - Mocking: extract dependencies into traits, use
mockallfor mock generation. - Benchmarks:
criterioninbenches/, withblack_boxto prevent optimization. - Async tests:
#[tokio::test]for async functions.
Reference Index
| Reference | Covers |
|---|---|
| references/testing.md | Proptest, mockall, criterion, tokio::test, RAII fixtures, doctests. For unit/integration test strategy and organization, see rust-tests |
| references/linting.md | Clippy lint levels, pedantic config, workspace lints, missing_docs, unsafe docs, cargo fmt in CI |
| references/project.md | lib/main split, feature modules, visibility, re-exports, prelude, workspaces, dependency inheritance |
| references/anti-patterns.md | 15 common anti-patterns with bad/good examples and "when acceptable" guidance |
Cross-References
- Error handling patterns: see the
rust-errorsskill forthiserror,anyhow,Result<T, E>, and error context chains. - API design and naming conventions: see the
rust-apiskill for builder pattern, newtype,From/Into, sealed traits,#[non_exhaustive], and naming (references/naming.md). - Unit & integration testing strategy: see the
rust-testsskill for test boundaries, module organization, test builders, error path testing, and integration test isolation. - Performance optimization: see the
rust-perfskill for profiling, memory layout, SIMD, and release profile tuning. - Async patterns: see the
rust-asyncskill for tokio runtime, channels, cancellation, and structured concurrency. - Logging and observability: see the
rust-tracingskill for tracing setup, structured logging,#[instrument], RUST_LOG, and OpenTelemetry integration.
What ships with it: 4 files
24.5 KB alongside SKILL.md
references/
- anti-patterns.md7.5 KB
- linting.md5.7 KB
- project.md6.1 KB
- testing.md5.1 KB