AGENT SKILL
Rust 预提交检查
rust-precommit
在每次提交前运行强制性的 PET Rust 预提交检查(cargo fmt + cargo clippy -D warnings)。当即将提交 Rust 更改、应用审查反馈后,或需要验证格式和 lint 是否干净时调用。
- License 许可
- MIT
- 最近更新
- 2026-11-10
- Stars
- ★ 209
- Forks
- 48
01 前言 Front Matter
- name
- rust-precommit
- description
- Run the mandatory PET Rust pre-commit checks (cargo fmt + cargo clippy -D warnings) before every commit. Invoke whenever you are about to commit Rust changes, after applying review feedback, or whenever you need to verify formatting and lint cleanliness.
03 SKILL.md 正文
Rust Pre-Commit Checks
The PET maintainer workflow requires cargo fmt --all and cargo clippy --all -- -D warnings to pass before every commit. This skill wraps both into a single script invocation.
When to use
- Before staging any Rust changes for commit.
- After fixing review comments on a PR, before pushing.
- Whenever the agent is asked "run pre-commit checks" or "validate the Rust code".
How to run
From the workspace root:
Windows (pwsh)
./scripts/rust-precommit.ps1
macOS / Linux
./scripts/rust-precommit.sh
Both scripts:
- Run
cargo fmt --all(auto-formats; fails only on unrecoverable errors). - Run
cargo clippy --all -- -D warnings(treats warnings as errors). - Exit non-zero on the first failure so callers can gate commits.
Handling failures
- fmt failure: rare; usually a syntax error preventing parsing. Fix the underlying compile error first.
- clippy failure: read the diagnostic, fix the code. Do not add
#[allow(...)]to suppress unless absolutely justified. - After any fix, re-run the script until it reports
ALL PRE-COMMIT CHECKS PASSED.
Notes
- The script must be run from the repository root (or pass the workspace path as the first arg to the
.shvariant /-WorkspacePathto the.ps1variant). - Keep the script in sync with
.github/copilot-instructions.md"Required Before Committing" section.
04 同仓库更多 Skills
PET Rust 编码规范
rust-locator-patterns
PET(Python Environment Tools)Rust 编码约定:定位器顺序、线程安全、平台门控、JSONRPC 规则、版本检测以及路径/符号链接处理。在本仓库编写或审查 Rust 代码时参考,以避免违反约定而导致审查反复修改。
★ 209
PET 项目 Rust 编码
rust-coding-skill
在 PET 中编辑 Rust 代码时使用,以编写具备分配感知、跨平台、字节安全的代码,并附带可证明行为正确性的测试。
★ 209