Skill站外收录 @skilllib/skill-2117939930272416663
check-code-quality
对 Rust 代码执行全流程质量验证,涵盖快速类型检查、生产构建、文档生成与格式化、静态分析、全目标测试及文档示例执行,并支持跨平台兼容性验证,确保代码在提交前符合编译正确性、风格规范、文档完整性和功能可靠性要求。
测试与安全 AI 技能
Skills.MD
# Rust Code Quality Checks
## When to Use
- After completing significant code changes
- Before creating commits
- Before creating pull requests
- When user says "check code quality", "run quality checks", "make sure code is good", etc.
## Instructions
Run this essential quality checklist in order. These are the core checks that must pass before committing code:
### 1. Fast Typecheck
```bash
cargo check
```
Quickly verifies the code compiles without generating artifacts.
### 2. Compile Production Code
```bash
cargo build
```
Ensures production code builds successfully.
### 3. Format Rustdoc Comments
Invoke the `write-documentation` skill to format rustdoc comments using `cargo rustdoc-fmt`.
This formats markdown tables and converts inline links to reference-style.
### 4. Generate Documentation
```bash
cargo doc --no-deps
```
Verify there are no documentation build warnings or errors.
If there are link warnings, invoke the `fix-intradoc-links` skill to resolve them.
**CRITICAL: Never remove intra-doc links to fix warnings.** When you encounter:
- Unresolved link to a symbol → Fix the path using `crate::` prefix (see `write-documentation` skill)
- Unresolved link to a test module → Add `#[cfg(any(test, doc))]` visibility (see `organize-modules` skill)
- Unresolved link to a platform-specific module → Use `#[cfg(all(any(test, doc), target_os = "..."))]`
Links provide refactoring safety - `cargo doc` catches stale references. Converting to plain backticks removes this protection.
### 5. Linting
Invoke the `run-clippy` skill to run clippy and enforce code style standards.
### 6. Compile Test Code
```bash
cargo test --no-run
```
Ensures test code compiles without running the tests.
### 7. Run All Tests
```bash
cargo test --all-targets
```
Runs all tests (unit, integration, etc.) but **does not run doctests**.
If tests fail, use the Task tool with `subagent_type='test-runner'` to fix failures.
### 8. Run Doctests
```bash
cargo test --doc
```
Runs documentation examples to ensure they work correctly.
### 9. Cross-Platform Verification (Optional)
For code with platform-specific `#[cfg]` gates (especially Unix-only code), verify Windows compatibility:
```bash
cargo rustc -p <crate_name> --target x86_64-pc-windows-gnu -- --emit=metadata
```
This checks that `#[cfg(unix)]` and `#[cfg(not(unix))]` gates compile correctly on Windows without needing a full cross-compiler toolchain.
**When to run:**
- After adding or modifying `#[cfg(unix)]` or `#[cfg(target_os = "...")]` attributes
- When working on platform-abstraction code
- Before committing changes to `DirectToAnsi` input handling or other Unix-specific code
## Reporting Results
After running all checks, report results concisely to the user:
- ✅ All checks passed → "All quality checks passed! Ready to commit."
- ⚠️ Some checks failed → Summarize which steps failed and what needs fixing
- 🔧 Auto-fixed issues → Report what was automatically fixed
## Optional Performance Analysis
For performance-critical code changes, consider also running:
- `cargo bench` - Benchmarks (mark tests with `#[bench]`)
- `cargo flamegraph` - Profiling (requires flamegraph crate)
- Invoke the `analyze-performance` skill for flamegraph-based regression detection
## Supporting Files in This Skill
This skill includes additional reference material:
- **`reference.md`** - Comprehensive guide to all cargo commands used in the quality checklist. Includes detailed explanations of what each command does, when to use it, common flags, and build optimizations (sccache, wild linker, etc.). **Read this when:**
- You need to understand what a specific cargo command does
- Troubleshooting build issues
- Want to know about build optimizations in `.cargo/config.toml`
- Understanding the difference between `cargo test --all-targets` and `cargo test --doc`
## Related Skills
- `write-documentation` - For rustdoc formatting (step 3)
- `fix-intradoc-links` - For fixing doc link warnings (step 4)
- `run-clippy` - For linting and code style (step 5)
- `analyze-performance` - For optional performance checks
- `test-runner` agent - For fixing test failures (step 7)
## Related Commands
- `/check` - Explicitly invokes this skill
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「check-code-quality」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次