Claude-skill-registry check-code-quality
Run comprehensive Rust code quality checks including compilation, linting, documentation, and tests. Use after completing code changes and before creating commits.
git clone https://github.com/majiayu000/claude-skill-registry
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/check-code-quality" ~/.claude/skills/majiayu000-claude-skill-registry-check-code-quality && rm -rf "$T"
skills/data/check-code-quality/SKILL.mdRust 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.
Quick Approach (Recommended)
Run the comprehensive check script which handles everything automatically:
./check.fish --full
This runs all checks in order: typecheck → build → clippy → tests → doctests → docs
Benefits of using
:check.fish --full
- ICE recovery: Automatically cleans cache and retries on Internal Compiler Errors
- Toolchain escalation: If ICE persists, escalates to
to find a stable nightlyrust-toolchain-update.fish - Config change detection: Auto-cleans stale artifacts when Cargo.toml or toolchain changes
- Performance optimized: Uses tmpfs, ionice, and parallel jobs for speed
Other check.fish Commands
For granular control, use individual commands:
| Command | What it runs |
|---|---|
| (fast typecheck) |
| (compile production) |
| (linting) |
| + doctests |
| (quick docs) |
| All of the above |
Step-by-Step Approach (Alternative)
If you need more control or want to run checks manually:
1. Fast Typecheck
./check.fish --check # or: cargo check
Quickly verifies the code compiles without generating artifacts.
2. Compile Production Code
./check.fish --build # or: 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
./check.fish --doc # or: 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
prefix (seecrate::
skill)write-documentation - Unresolved link to a test module → Add
visibility (see#[cfg(any(test, doc))]
skill)organize-modules - 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
./check.fish --clippy # or invoke the `run-clippy` skill
Runs clippy and enforces code style standards.
6. Run All Tests
./check.fish --test # or: cargo test --all-targets && cargo test --doc
Runs all tests (unit, integration, doctests).
If tests fail, use the Task tool with
subagent_type='test-runner' to fix failures.
7. Cross-Platform Verification (Optional)
For code with platform-specific
#[cfg] gates (especially Unix-only code), verify Windows compatibility:
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
or#[cfg(unix)]
attributes#[cfg(target_os = "...")] - When working on platform-abstraction code
- Before committing changes to
input handling or other Unix-specific codeDirectToAnsi
ICE Recovery and Toolchain Escalation
The
./check.fish --full command includes automatic recovery from Internal Compiler Errors:
ICE detected → cleanup target/ → retry ↓ still ICE? ↓ escalate to rust-toolchain-update.fish (searches 46 nightly candidates, validates each) ↓ new stable nightly installed ↓ retry checks
This is especially important since we use nightly Rust (for the parallel compiler frontend). Nightly toolchains occasionally have ICE bugs, and this automatic escalation finds a working version.
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:
- Benchmarks (mark tests withcargo bench
)#[bench]
- Profiling (requires flamegraph crate)cargo flamegraph- Invoke the
skill for flamegraph-based regression detectionanalyze-performance
Supporting Files in This Skill
This skill includes additional reference material:
- 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 (wild linker, parallel frontend, tmpfs). Read this when:reference.md- 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
andcargo test --all-targetscargo test --doc
Related Skills
- For rustdoc formatting (step 3)write-documentation
- For fixing doc link warnings (step 4)fix-intradoc-links
- For linting and code style (step 5)run-clippy
- For optional performance checksanalyze-performance
agent - For fixing test failures (step 6)test-runner
Related Commands
- Explicitly invokes this skill/check