with one click
rust-clippy
Rust Clippy 静态分析技能:使用 cargo clippy 进行 Rust 代码质量检测,配合 cargo fix 自动修复
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
Rust Clippy 静态分析技能:使用 cargo clippy 进行 Rust 代码质量检测,配合 cargo fix 自动修复
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
AI记忆持久化系统。使用memrec存储、检索、管理跨会话记忆。支持项目隔离、混合检索(KNN+BM25)、MMR重排、中文搜索。触发场景:(1)重要决策需记录,(2)关键知识需保存,(3)项目上下文需跨会话保持,(4)用户偏好需记忆,(5)检索历史知识辅助当前任务。
Rust 性能分析技能:通过 cargo flamegraph 生成火焰图(SVG),定位 CPU 热点函数并量化占比。适用于 Rust 项目性能瓶颈定位、热点分析、优化验证。触发场景:(1)分析 Rust 代码性能瓶颈,(2)定位 CPU 热点函数,(3)量化函数调用占比,(4)优化前后对比验证,(5)bench/unittest 性能不达预期时根因分析。
读取所有源代码,解构为设计图、设计文档、数据库设计; 没有执行文件,请按流程执行
项目问题侦测技能:综合分析设计、性能、安全问题,评分并提出重构或重建方案
局部代码修改技能:最小化修改完成功能,确保无蝴蝶效应,支持独立测试验证和全量关联检查
该skill没有执行文件,为操作指引:如何重构
| name | rust-clippy |
| description | Rust Clippy 静态分析技能:使用 cargo clippy 进行 Rust 代码质量检测,配合 cargo fix 自动修复 |
PROJECT_DIR=. # Rust 项目根目录(包含 Cargo.toml)
cargo clippy # 基础检查
cargo clippy --all-targets # 含测试、示例
cargo clippy -p <package_name> # 特定包
cargo clippy -- --deny warnings # 严格模式
cargo clippy -- --allow <lint_name> # 允许特定 lint
cargo clippy -- --deny <lint_name> # 禁止特定 lint
cargo clippy --fix # 安全修复
cargo clippy --fix --allow-dirty --allow-staged # 允许语义变更修复
cargo clippy --all-targets # 验证修复结果
cargo clippy --message-format=json > clippy-report.json # JSON
cargo clippy --message-format=short # 简短
报告模板见 templates/report.md。
| 级别 | 描述 | 组名 | 严格程度 |
|---|---|---|---|
| allow | 允许,不提示 | clippy::all(默认) | 适中 |
| warn | 警告 | clippy::pedantic | 严格 |
| deny | 错误,阻止编译 | clippy::correctness | 严格 |
| forbid | 禁止,无法覆盖 | clippy::restriction | 最严格 |
其他组:style(宽松)、complexity(适中)、perf(适中)、cargo(宽松)、nursery(不稳定)。
cargo clippy -- --clippy::pedantic
cargo clippy -- --allow clippy::too_many_arguments
cargo clippy -- --clippy::pedantic --deny clippy::unwrap_used
#![warn(clippy::pedantic)]
#![allow(clippy::too_many_lines)]
#[allow(clippy::too_many_arguments)]
fn complex_function(a: i32, b: i32, c: i32, d: i32, e: i32) {}
[lints]
workspace = true
[workspace.lints.clippy]
pedantic = "warn"
unwrap_used = "deny"
too_many_arguments = "allow"
模板见 templates/ 目录:
ci-github-actions.yaml — GitHub Actionsci-pre-commit.yaml — pre-commit hookMakefile — Make 目标# 统计 lint 类型
cargo clippy --message-format=json 2>/dev/null | \
jq -r 'select(.message != null) | .message.code | .code // empty' | \
sort | uniq -c | sort -nr
# 提取错误级别
cargo clippy --message-format=json 2>/dev/null | \
jq -r 'select(.message != null and .message.level == "error") | .message.rendered'
| 场景 | 命令 |
|---|---|
| 快速检查 | cargo clippy --all-targets |
| CI 严格模式 | cargo clippy --all-targets -- --deny warnings |
| 渐进式采用 | --fix → --warn clippy::pedantic → --deny clippy::unwrap_used |
| 修复后验证 | cargo clippy --fix --allow-dirty && cargo clippy --all-targets -- --deny warnings && cargo test |
clippy::all 到 pedantic--fix#[allow()] 并附注释rustup update--fix 可能改变语义,修复后务必测试nursery 组不稳定,可能变化restriction 需手动启用#[deny(warnings)] 冲突时 clippy 警告也会被拒绝技能版本: 1.0.0 | 工具: cargo clippy | 适用: Rust 项目