agentleFS
rcore-osrcore-os/tgoskits/.agents/skills/rust-code-quality/SKILL.md

rust-code-quality

Skill76 starsChanged 8 days agoApache-2.0View on GitHub

编写、修改、重构或审查本 TGOSKits 仓库中的 Rust 代码时使用。提供所有 Rust 改动都应满足的实现质量、命名、函数、注释、错误处理、代码异味和确定性测试基线;公共接口、并发或 unsafe 专项问题由对应技能补充。

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Files
SKILL.md

Rust 代码质量

1. 适用方式

本技能是所有 Rust 实现与审查的基础约束。先理解调用链、所有权、失败路径和验证入口,再判断是否同时读取公共接口、并发、unsafe、功能开发或领域技能。规则重叠时采用能够更直接保护实际不变量的一项,不复制多份相同结论。

开始实现或审查前,完整阅读 实现与表达。任务涉及运行时失败、错误传播、错误修复、测试新增或验证证据时,再完整阅读 错误与测试。

2. 相邻技能

本技能只提供通用基线。下列语义出现时还要读取对应技能:

  • 公共或共享接口、类型、错误、软件包、模块、依赖或宏边界:rust-api-design;
  • 同一能力跨多个目标架构的共同性、能力子集、默认实现或编译期后端选择:multi-arch-layering;
  • 锁、原子操作、异步执行、中断、任务调度或共享状态:rust-concurrency-safety;
  • unsafe、外部函数接口、用户内存、内存映射输入输出或直接内存访问:rust-unsafe-safety;
  • 新增或扩展用户可见行为、软件包、子系统、平台或硬件能力:feature-development;
  • 测试策略、层级选择、确定性回归、必要性或低价值测试审计:test-quality;
  • 可移植驱动、平台启动、系统调用或测试套件:继续读取命中的领域技能。

3. 项目验证

使用仓库任务工具作为验证入口。修改代码后运行 cargo fmt;未提交的改动用 cargo xtask clippy --package <软件包> 检查受影响范围,提交后可用 cargo xtask clippy --since <引用> 并核对选中项。需要标准库测试证明改动行为时,按 AGENTS.md 使用 cargo xtask test --since <引用>;直接修改白名单时遵循 update-std-tests。ArceOS、StarryOS 和 Axvisor 的构建、测试与运行也使用相应的 cargo xtask 子命令,QEMU 或板卡测试按受影响目标和用例选择。提交拉取请求不要求额外执行全量本地矩阵。

模块通过 include! 等方式间接声明时,先确认 cargo fmt 是否覆盖实际变更文件;例如 Starry 的 include!("root.rs") 不保证 Rustfmt 会遍历其模块树。仍须运行 cargo fmt,并用仓库固定工具链的 rustfmt --edition 2024 对遗漏的变更文件定向格式化和检查,不能把未被遍历文件的格式问题记为通过。

核对测试的实际条件编译入口:Clippy 开启 axtest feature 不等于编译 #[cfg(all(test, axtest))] 测试。修改这类模块内测试后,必须通过对应的 cargo xtask ktest 入口真实编译、选择并执行,不能仅以 feature 组合的静态检查替代。

不得用原生 Cargo 命令替代已有的项目入口,也不得通过新增 allow 属性、削弱测试、放宽匹配规则或静默跳过来制造通过结果。项目任务工具确实没有入口时,先检查其实现,再使用能够精确复现项目参数的特殊命令并说明原因。

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.