| created | "2025-12-16T00:00:00.000Z" |
| modified | "2026-05-09T00:00:00.000Z" |
| reviewed | "2025-12-16T00:00:00.000Z" |
| name | clippy-advanced |
| description | Advanced Clippy configuration for Rust — custom rules, pedantic/nursery lints, clippy.toml, IDE and CI integration. Use when configuring or enforcing lint standards. |
| user-invocable | false |
| allowed-tools | Bash, Read, Grep, Glob |
clippy-advanced - Advanced Clippy Configuration
Advanced Clippy configuration for comprehensive Rust linting, including custom rules, lint categories, disallowed methods, and IDE integration.
When to Use This Skill
| Use this skill when... | Use another tool instead when... |
|---|
| Configuring Clippy lint rules | Formatting code (use rustfmt) |
| Setting up CI linting for Rust | Building/compiling (use cargo build) |
| Customizing clippy.toml | Running tests (use cargo test) |
| Enforcing code standards | Managing dependencies (use cargo add) |
Installation
rustup component add clippy
cargo clippy --version
rustup update
Basic Usage
cargo clippy
cargo clippy --all-targets
cargo clippy --all-features
cargo clippy --workspace --all-targets --all-features
cargo clippy -- -W clippy::all -A clippy::pedantic
cargo clippy -- -D warnings
Lint Categories
| Category | Purpose | Default |
|---|
clippy::correctness | Likely bugs | Deny |
clippy::complexity | Overly complex code | Warn |
clippy::perf | Performance issues | Warn |
clippy::style | Code style | Warn |
clippy::suspicious | Code that looks wrong | Warn |
clippy::pedantic | Opinionated style | Off |
clippy::restriction | Opt-in constraints | Off |
clippy::nursery | Experimental | Off |
clippy::cargo | Cargo.toml issues | Off |
Recommended Cargo.toml Configuration
[workspace.lints.clippy]
correctness = "deny"
complexity = "warn"
perf = "warn"
style = "warn"
suspicious = "warn"
pedantic = "warn"
must_use_candidate = "allow"
missing_errors_doc = "allow"
clone_on_ref_ptr = "warn"
dbg_macro = "warn"
print_stdout = "warn"
todo = "warn"
unimplemented = "warn"
unwrap_used = "warn"
use_self = "warn"
clippy.toml Essential Settings
Create clippy.toml in project root for thresholds and disallowed items:
cognitive-complexity-threshold = 15
too-many-lines-threshold = 100
too-many-arguments-threshold = 5
disallowed-methods = [
{ path = "std::env::var", reason = "Use std::env::var_os for better Unicode handling" },
{ path = "std::process::exit", reason = "Use Result propagation instead" },
]
disallowed-names = ["foo", "bar", "baz"]
Lint Suppression
#[allow(clippy::too_many_arguments)]
fn complex_function(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32) {}
#![warn(clippy::all)]
#![warn(clippy::pedantic)]
#![deny(clippy::unwrap_used)]
#![allow(clippy::module_name_repetitions)]
#[allow(clippy::cast_possible_truncation)]
let x = value as u8;
Agentic Optimizations
| Context | Command |
|---|
| CI strict | cargo clippy --workspace --all-targets -- -D warnings |
| JSON output | cargo clippy --message-format=json |
| Compact errors | cargo clippy --message-format=short |
| Quick check | cargo clippy --message-format=short -- -D warnings |
| Pedantic check | cargo clippy -- -W clippy::pedantic -D clippy::correctness |
Quick Reference
Command-Line Flags
| Flag | Description |
|---|
--all-targets | Check lib, bins, tests, examples, benches |
--all-features | Enable all features |
--workspace | Check entire workspace |
--message-format=json | JSON output for tooling |
--message-format=short | Compact error format |
-- -D warnings | Treat warnings as errors |
-- -W clippy::pedantic | Enable pedantic lints |
-- -A clippy::lint_name | Allow specific lint |
Lint Levels
| Level | Attribute | Effect |
|---|
| Allow | #[allow(...)] | Suppress lint |
| Warn | #[warn(...)] | Show warning |
| Deny | #[deny(...)] | Compile error |
References
For detailed configuration examples, CI integration, IDE setup, and best practices, see REFERENCE.md.