بنقرة واحدة
check-code-quality
// Run comprehensive Rust code quality checks including compilation, linting, documentation, and tests. Use after completing code changes and before creating commits.
// Run comprehensive Rust code quality checks including compilation, linting, documentation, and tests. Use after completing code changes and before creating commits.
Apply private modules with public re-exports (barrel export) pattern for clean API design. Includes conditional visibility for docs and tests. Use when creating modules, organizing mod.rs files, or before creating commits.
Write and format Rust documentation correctly. Apply proactively when writing code with rustdoc comments (//! or ///). Covers voice & tone, prose style (opening lines, explicit subjects, verb tense), structure (inverted pyramid), intra-doc links (crate:: paths, reference-style), constant conventions (binary/byte literal/decimal), and formatting (cargo rustdoc-fmt). Also use retroactively via /fix-intradoc-links, /fix-comments, or /fix-md-tables commands.
Run clippy linting, enforce comment punctuation rules, format code with cargo fmt, and verify module organization patterns. Use after code changes and before creating commits.
Publish a crate release to crates.io with changelog, git tag, and GitHub release. Use when releasing a new version of any workspace crate.
Analyze log files by stripping ANSI escape sequences first. Use when asked to process, handle, read, or analyze log files that may contain terminal escape codes.
Core design principles for the codebase - cognitive load, progressive disclosure, type safety, abstraction worth. Use when designing APIs, modules, or data structures.
| name | check-code-quality |
| description | Run comprehensive Rust code quality checks including compilation, linting, documentation, and tests. Use after completing code changes and before creating commits. |
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:
rust-toolchain-update.fish to find a stable nightlyFor granular control, use individual commands:
| Command | What it runs |
|---|---|
./check.fish --check | cargo check (fast typecheck) |
./check.fish --build | cargo build (compile production) |
./check.fish --clippy | cargo clippy --all-targets (linting) |
./check.fish --test | cargo test + doctests |
./check.fish --doc | cargo doc --no-deps (quick docs) |
./check.fish --quick-doc | cargo doc --no-deps (fastest, no staging/sync) |
./check.fish --full | All of the above + lychee link rot check |
If you need more control or want to run checks manually:
./check.fish --check
# (runs: cargo check)
Quickly verifies the code compiles without generating artifacts.
./check.fish --build
# (runs: cargo build)
Ensures production code builds successfully.
Invoke the write-documentation skill to format rustdoc comments using cargo rustdoc-fmt.
This formats markdown tables and converts inline links to reference-style.
./check.fish --quick-doc
# (runs: cargo doc --no-deps, directly to serving dir - fastest for iteration)
Verify there are no documentation build warnings or errors. Use --quick-doc for fast feedback
during development. Use --doc for final verification before commits (includes staging/sync).
If there are link warnings, use the /fix-intradoc-links command to resolve them.
Heading Anchor (Slug) Integrity:
If you modified any heading text (e.g., # My Heading), the automatically generated HTML anchor
(e.g., #my-heading) will change.
grep_search to find any existing links (e.g., path#old-slug)
that point to the old anchors and update them.cargo doc warns about many broken fragments, proactive searching
prevents "orphan" links in external documentation or complex intra-doc paths.CRITICAL: Never remove intra-doc links to fix warnings. When you encounter:
crate:: prefix (see write-documentation skill)#[cfg(any(test, doc))] visibility (see organize-modules skill)#[cfg(all(any(test, doc), target_os = "..."))]Links provide refactoring safety - cargo doc catches stale references. Converting to plain backticks removes this protection.
Included automatically in ./check.fish --full. Runs lychee on git-modified files to detect
broken external URLs in rustdoc comments.
cargo doc --no-deps (step 4) validates intra-doc links but not external HTTP/HTTPS URLs.
lychee fills that gap. Config in lychee.toml (repo root) excludes known false positives
(example file:// URIs, test fixture URLs, sites that block automated requests).
If lychee reports 404s, fix the URL by finding the new location. See the task file
task/add-lychee-to-detect-link-rot.md for the full categorization of findings.
./check.fish --clippy
# or invoke the `run-clippy` skill
Runs clippy and enforces code style standards.
./check.fish --test
# (runs: 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.
After major refactors or changes that affect process spawning, PTY tests, or async infrastructure, run the full test suite 20 times back-to-back to detect flaky regressions:
for i in {1..20}; do echo "=== Run $i/20 ===" && cargo test --all-targets -- --nocapture 2>&1 | grep -E "^test result:" | head -3 || { echo "FAILED on run $i"; exit 1; }; done && echo "ALL 20 RUNS PASSED"
When to run:
generate_pty_test!, spawn_controlled_in_pty)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:
#[cfg(unix)] or #[cfg(target_os = "...")] attributesDirectToAnsi input handling or other Unix-specific codeThe ./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.
After running all checks, report results concisely to the user:
For performance-critical code changes, consider also running:
cargo bench - Benchmarks (mark tests with #[bench])cargo flamegraph - Profiling (requires flamegraph crate)analyze-performance skill for flamegraph-based regression detectionThis 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 (wild linker, parallel frontend, tmpfs). Read this when:
.cargo/config.tomlcargo test --all-targets and cargo test --docwrite-documentation - For rustdoc formatting (step 3) and fixing doc link warnings (step 4)run-clippy - For linting and code style (step 5)analyze-performance - For optional performance checkstest-runner agent - For fixing test failures (step 6)/check - Explicitly invokes this skill