rust-magic-linter
Add strict Clippy lint configurations to Rust projects for AI-assisted development. Use when the user wants to add Clippy lints, AI guardrails, or rust-magic-linter to a Rust project. Supports three presets (minimal, standard, maximum) that enforce best practices and prevent common AI coding mistakes like using unwrap(), silencing warnings with
Installation
Follow the repository instructions for this skill and your agent. Review the files and dependencies before adding it to your workflow.
View source ↗GuidesSkill instructions
Rust Magic Linter
Add strict Clippy lint configurations to Rust projects. These "guardrails" help AI agents write better Rust code by turning best practices into compiler errors.
Workflow
- Verify this is a Rust project (check for
Cargo.toml) - Ask which preset the user wants (if not specified)
- Check if
[lints.*]sections already exist in Cargo.toml - Detect workspace vs single project (use
[workspace.lints.*]for workspaces) - Apply the configuration from assets
- Create
clippy.tomlfrom assets - Optionally offer
.cargo/deny.tomlandCONSTITUTION.md - Run
cargo clippyto verify
Presets
-
minimal - Just panic guards:
unwrap,expect,panic,allow_attributes,dbg_macro,todo. Use for quick safety net with minimal code changes. - standard - Pedantic + async safety + output control. Recommended for most projects.
- maximum - All lint groups at deny level, minimal relaxations. Very strict, may require significant code changes.
Assets
All configuration files are in assets/:
-
assets/minimal.toml- Minimal preset -
assets/standard.toml- Standard preset (recommended) -
assets/maximum.toml- Maximum preset (strictest) -
assets/clippy.toml- Complexity thresholds for project root -
assets/deny.toml- cargo-deny config for.cargo/deny.toml -
assets/CONSTITUTION.md- Project rules template
Applying Configurations
- Read the appropriate preset from
assets/ - For workspaces: replace
[lints.with[workspace.lints. - Append to
Cargo.tomlwith a header comment - Copy
assets/clippy.tomlto project root - If user wants supply chain security: copy
assets/deny.tomlto.cargo/deny.toml - If user wants project rules: copy
assets/CONSTITUTION.mdto project root
Key Lints Explained
The most important lint is allow_attributes = "deny" - this prevents AI from bypassing errors by adding #[allow(clippy::...)]. The AI must actually fix the code.
Other critical lints:
-
unwrap_used,expect_used,panic- Force proper error handling -
dbg_macro,todo- No debug leftovers or incomplete code -
print_stdout,print_stderr- Usetracingfor structured logging -
await_holding_lock- Prevent async deadlocks
Repository
Examples
Read the usage examples in the source repository.
View source ↗Source history
- Indexed on
- 2026-03-11
- Index updated
- 2026-03-11
- Branch
- main
Index and sync dates describe this directory. View the source repository for code history.
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!