Skip to content

■ SKILLS // SKILL SPECS

rust-lint

Automatically format Rust files with rustfmt and provide on-demand clippy linting

■ [!] ON THIS PAGE ▼
■ INSTALL // npx @self.md/cli install rust-lint
AuthorCheolwan Park
Namespace@cheolwanpark/personal-curation
Category#general
Version1.0.0
Stars★ 2
Downloads↓ 7
Verification[ ✓ ] self.md verified

Automatically format Rust files with rustfmt and provide on-demand clippy linting

Installation

npx claude-plugins install @cheolwanpark/personal-curation/rust-lint

Contents

Folders: commands, hooks, scripts, tests

Files: README.md

Documentation

Automatically format Rust files with rustfmt and provide on-demand comprehensive linting with clippy.

Features

  • ✅ Auto-formatting: Automatically formats .rs files on every edit/write using rustfmt
  • 🚀 Fast hook execution: Hook completes in <2s (formatting only, no compilation)
  • 🔍 Comprehensive linting: On-demand project-wide clippy analysis via slash command
  • 🗂️ Workspace support: Automatically detects and handles Cargo workspaces
  • 🧹 Isolated builds: Build artifacts stored in /tmp to avoid project pollution
  • 🛡️ Graceful degradation: Clear error messages when tools are missing
  • 📊 Detailed reports: Markdown-formatted reports with file:line:column references

Why This Architecture?

Unlike ESLint or Ruff, clippy requires full cargo compilation and can take 5-30+ seconds even on small projects. Running clippy on every file save would make the editor unresponsive.

Our solution:

  • Hook (PostToolUse): Fast rustfmt-only formatting (<2s)
  • Command (/rust-lint:lint-project): Comprehensive clippy analysis (user-initiated, acceptable wait time)

This design provides immediate formatting feedback while preserving comprehensive linting when you need it.

Requirements

  • Rust toolchain (rustc, cargo): Install from rustup.rs
  • rustfmt: rustup component add rustfmt
  • clippy: rustup component add clippy
  • jq: JSON processor
    • macOS: brew install jq
    • Ubuntu/Debian: apt-get install jq
    • Other: See jq download page

Installation

1. Install the plugin

Place this plugin in your Claude Code plugins directory:

# If you haven't cloned the repository
cd ~/.claude/plugins  # or your plugins directory
git clone https://github.com/cheolwanpark/useful-claude-plugins
cd useful-claude-plugins/plugins/rust-lint

# Or if you already have the repository
cd /path/to/useful-claude-plugins/plugins/rust-lint

2. Install Rust components

rustup component add rustfmt clippy

3. Verify installation

rustfmt --version
cargo clippy --version
jq --version

4. Enable the plugin in Claude Code

The plugin will be automatically detected by Claude Code. You can verify it’s loaded by checking for the /rust-lint:lint-project command.

How It Works

Hook Behavior (Automatic)

Triggered on: Every Edit or Write operation on .rs files

What it does:

  1. Validates file is .rs and <1MB
  2. Checks if rustfmt is installed
  3. Runs rustfmt --check to see if formatting is needed
  4. If needed, runs rustfmt to auto-format
  5. Returns allow decision (never blocks)

Performance:

  • Typical execution time: <1 second
  • No compilation required
  • No clippy analysis (too slow for hooks)

File size limit: Files larger than 1MB are skipped to avoid timeouts. Use cargo fmt manually for large files.

Slash Command (On-Demand)

Command: /rust-lint:lint-project [directory]

What it does:

  1. Finds the Cargo workspace/project root
  2. Checks formatting with cargo fmt --check
  3. Runs cargo clippy --workspace --all-targets --no-deps
  4. Generates a markdown report with:
    • Summary (error count, warning count)
    • Formatting issues (if any)
    • Clippy errors (up to 20 shown)
    • Clippy warnings (up to 10 shown)
  5. Exits with code 1 if errors found, 0 otherwise

Performance:

  • First run: 10-30 seconds (requires compilation)
  • Subsequent runs: 2-10 seconds (incremental compilation)

Build artifacts: Isolated to /tmp/claude-rust-lint-cache-<project-hash> to avoid polluting your project directory.

Configuration

rustfmt Configuration

Create a rustfmt.toml or .rustfmt.toml in your project root:

# Edition must match Cargo.toml
edition = "2021"

# Line width
max_width = 100

# Indentation
hard_tabs = false
tab_spaces = 4

# Imports
imports_granularity = "Crate"
group_imports = "StdExternalCrate"

# Trailing commas
trailing_comma = "Vertical"

# Use field init shorthand
use_field_init_shorthand = true

Generate default config:

rustfmt --print-config default > rustfmt.toml

clippy Configuration

Option 1: Cargo.toml [lints] (Recommended for Rust 1.74+)

[lints.clippy]
# Enable groups
all = "warn"
pedantic = "warn"

# Deny specific lints
unwrap_used = "deny"
expect_used = "warn"

# Allow noisy pedantic lints
missing_errors_doc = "allow"
missing_panics_doc = "allow"
module_name_repetitions = "allow"

Option 2: clippy.toml or .clippy.toml

# Cognitive complexity threshold
cognitive-complexity-threshold = 30

# Maximum allowed type complexity
type-complexity-threshold = 250

# Maximum allowed function parameters
too-many-arguments-threshold = 7

# Allowed variable names
allowed-names = ["i", "j", "k", "x", "y", "z"]

Option 3: Source code attributes

#![warn(clippy::all)]
#![warn(clippy::pedantic)]
#![deny(clip



## Source

[View on GitHub](https://github.com/cheolwanpark/claude-plugins)