A unified code health tool for Rust — scan, score, and fix your codebase.
rust-doctor scans Rust projects for security, performance, correctness, architecture, and dependency issues, producing a 0–100 health score with actionable diagnostics.
demo.mp4
- 700+ clippy lints with severity overrides and category mapping
- 19 custom AST rules via syn: error handling, performance, security, async, architecture, framework anti-patterns
- Async anti-pattern detection: blocking calls in async, block_on in async context
- Framework-specific rules: tokio, axum, actix-web
- Dependency auditing: CVE detection via cargo-audit, unused deps via cargo-machete
- Health score: 0–100 with ASCII doctor face output
- MCP server: integrate with Claude Code, Cursor, or any MCP-compatible AI tool
- Diff mode: scan only changed files for fast CI feedback
- Workspace support: scan all crates or select specific members
- Inline suppression:
// rust-doctor-disable-next-line <rule> - Multiple output modes: terminal,
--json,--score,--sarif - Setup wizard:
rust-doctor setup— auto-detects Claude Code, Cursor, Windsurf and configures MCP or installs skills in one command - Claude Code skill:
/rust-doctorslash command — no MCP setup needed - Library crate: use rust-doctor programmatically via
lib.rs - NO_COLOR support: respects the NO_COLOR environment variable
npx rust-doctor --mcpOr install globally:
npm install -g rust-doctorThis downloads a pre-built native binary for your platform — no Rust toolchain required.
cargo install rust-doctorcargo binstall rust-doctorcurl -fsSL https://github.com/ArthurDEV44/rust-doctor/releases/latest/download/install.sh | bashirm https://github.com/ArthurDEV44/rust-doctor/releases/latest/download/install.ps1 | iexDownload pre-built binaries from GitHub Releases.
Available platforms:
x86_64-unknown-linux-gnuaarch64-unknown-linux-gnux86_64-apple-darwinaarch64-apple-darwinx86_64-pc-windows-msvc
# Scan current directory
rust-doctor
# Scan a specific directory
rust-doctor /path/to/project
# Get bare score for CI
rust-doctor --score
# JSON output
rust-doctor --json
# Scan only changed files
rust-doctor --diff
# Scan against a specific branch
rust-doctor --diff main
# Fail CI on errors
rust-doctor --fail-on error
# Scan specific workspace members
rust-doctor --project core,api
# Verbose output with file:line details
rust-doctor --verbose
# Install missing external tools (cargo-deny, cargo-audit, etc.)
rust-doctor --install-deps
# Run as MCP server
rust-doctor --mcp
# Setup wizard — configure AI agents automatically
rust-doctor setupThe fastest way to integrate rust-doctor with your AI coding agent:
npx rust-doctor@latest setupThe wizard auto-detects installed agents (Claude Code, Cursor, Windsurf) and lets you choose:
- CLI + Skills (default) — installs a
SKILL.mdthat teaches your agent to use the rust-doctor CLI with deep analysis capabilities - MCP Server — configures the
rust-doctor --mcpstdio server in your agent's config file
The wizard handles detection, configuration, and verification in one command. For manual setup, see the sections below.
rust-doctor includes a built-in Model Context Protocol server, allowing AI coding assistants to scan and analyze Rust projects directly.
| Tool | Description |
|---|---|
scan |
Scan a Rust project for code health issues. Returns diagnostics with a 0–100 health score. |
score |
Get the health score (0–100) of a Rust project as a single integer. |
explain_rule |
Get a detailed explanation of a rule: what it checks, why it matters, and how to fix violations. |
list_rules |
List all available rules with their categories and severities. |
All tools are read-only (readOnlyHint: true).
| Prompt | Description |
|---|---|
deep-audit |
Comprehensive 6-phase expert audit: codebase exploration, static analysis, deep code review (51-item checklist), best practices research, synthesis report, and remediation choices (implement all / generate PRD / manual). |
health-check |
Quick scan + prioritized remediation plan (P0–P3) + fix workflow. |
Automatic setup (recommended):
rust-doctor setup # detects Claude Code and configures MCP or installs skillOr one-command MCP install:
claude mcp add --transport stdio rust-doctor -- npx -y rust-doctor --mcpOr via Claude Code plugin:
/plugin install rust-doctor@ArthurDEV44/rust-doctor
Or add manually to your ~/.claude/settings.json:
{
"mcpServers": {
"rust-doctor": {
"command": "rust-doctor",
"args": ["--mcp"]
}
}
}Or share with your team via .mcp.json in your project root (committed to git):
{
"mcpServers": {
"rust-doctor": {
"command": "npx",
"args": ["-y", "rust-doctor", "--mcp"]
}
}
}Add to your .cursor/mcp.json:
{
"mcpServers": {
"rust-doctor": {
"command": "npx",
"args": ["-y", "rust-doctor", "--mcp"]
}
}
}Add to your .vscode/settings.json:
{
"mcp": {
"servers": {
"rust-doctor": {
"type": "stdio",
"command": "npx",
"args": ["-y", "rust-doctor", "--mcp"]
}
}
}
}Add to your ~/.codeium/windsurf/mcp_config.json:
{
"mcpServers": {
"rust-doctor": {
"command": "npx",
"args": ["-y", "rust-doctor", "--mcp"]
}
}
}rust-doctor uses stdio transport. Any MCP client that supports stdio can connect by running rust-doctor --mcp.
Built with rmcp v1.x (official Rust MCP SDK).
If you prefer slash commands over MCP servers, rust-doctor ships a Claude Code skill.
Automatic install (recommended):
rust-doctor setup # choose "CLI + Skills", select Claude CodeOr via npx:
npx skills add https://github.com/ArthurDEV44/rust-doctor --skill rust-doctorOr copy manually:
cp -r skills/rust-doctor/ ~/.claude/skills/rust-doctor/Usage:
/rust-doctor # scan current project
/rust-doctor --diff # scan changed files only
/rust-doctor --fix # scan + apply fixes
/rust-doctor --plan # scan + remediation plan
/rust-doctor src/ # scan a specific directory
The skill runs the rust-doctor CLI under the hood, parses the output, categorizes findings by priority, and provides actionable fix guidance with before/after code.
- uses: ArthurDEV44/rust-doctor@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
fail-on: warningThe action posts a PR comment with the health score, error/warning counts, and top diagnostics.
Create a rust-doctor.toml in your project root, or add [package.metadata.rust-doctor] to your Cargo.toml:
# rust-doctor.toml
verbose = false
fail_on = "none"
[ignore]
rules = ["excessive-clone", "string-from-literal"]
files = ["**/generated/**", "tests/**"]CLI flags override config file values.
// rust-doctor-disable-next-line unwrap-in-production
let value = some_option.unwrap();
let x = risky_call(); // rust-doctor-disable-line| Category | Rule | Severity |
|---|---|---|
| Error Handling | unwrap-in-production |
Warning |
| Error Handling | panic-in-library |
Error |
| Error Handling | box-dyn-error-in-public-api |
Warning |
| Error Handling | result-unit-error |
Warning |
| Performance | excessive-clone |
Warning |
| Performance | string-from-literal |
Info |
| Performance | collect-then-iterate |
Warning |
| Performance | large-enum-variant |
Warning |
| Performance | unnecessary-allocation |
Warning |
| Architecture | high-cyclomatic-complexity |
Warning |
| Security | hardcoded-secrets |
Error |
| Security | unsafe-block-audit |
Warning |
| Security | sql-injection-risk |
Error |
| Async | blocking-in-async |
Error |
| Async | block-on-in-async |
Error |
| Framework | tokio-main-missing |
Error |
| Framework | tokio-spawn-without-move |
Error |
| Framework | axum-handler-not-async |
Warning |
| Framework | actix-blocking-handler |
Warning |
rust-doctor runs cargo clippy with pedantic, nursery, and cargo lint groups. 75+ lints have explicit category and severity overrides across: Error Handling, Performance, Security, Correctness, Architecture, Cargo, Async, Style.
These tools are optional — rust-doctor gracefully skips any that are missing and shows which passes were skipped. Run rust-doctor --install-deps to install them all at once.
| Tool | Install | What it does |
|---|---|---|
| clippy | rustup component add clippy |
700+ lint checks |
| cargo-deny | cargo install cargo-deny |
Supply-chain checking (advisories, licenses, bans) |
| cargo-audit | cargo install cargo-audit |
CVE vulnerability scanning |
| cargo-geiger | cargo install cargo-geiger |
Unsafe code auditing across dependency tree |
| cargo-machete | cargo install cargo-machete |
Unused dependency detection |
| cargo-semver-checks | cargo install cargo-semver-checks |
Semver violation detection |
rust-doctor is available as a library crate:
use std::path::Path;
// Discover the project (finds Cargo.toml, loads config)
let (dir, info, config) = rust_doctor::discovery::bootstrap_project(
Path::new("/path/to/project"), false,
)?;
// Resolve config with defaults
let resolved = rust_doctor::config::resolve_config_defaults(config.as_ref());
// Run the scan
let result = rust_doctor::scan::scan_project(&info, &resolved, false, &[], true)?;
println!("Score: {}/100 ({})", result.score, result.score_label);The score uses weighted dimension scoring across 5 dimensions (Security ×2.0, Reliability ×1.5, Maintainability ×1.0, Performance ×1.0, Dependencies ×1.0). Each dimension is scored as 100 - (unique_error_rules × 1.5) - (unique_warning_rules × 0.75) - (unique_info_rules × 0.25), and the overall score is the weighted average, clamped to 0–100.
The score counts unique rules violated, not occurrences — fixing one instance of .unwrap() won't change the score, but eliminating all .unwrap() calls removes the penalty entirely.
| Score | Label | Doctor |
|---|---|---|
| 75–100 | Great | ◠ ◠ |
| 50–74 | Needs work | • • |
| 0–49 | Critical | x x |
MIT OR Apache-2.0