Validate WCAG 2.1 Level AA compliance and accessibility best practices. Use when performing accessibility audits and WCAG certification.
日本語の概要は準備中です。原文の説明を表示しています。
Validate Rust code quality with rustfmt, clippy, cargo check, and security analysis. Use for Rust codebases to ensure idiomatic Rust code and best practices.
インストールする前に、エージェントに与えられる指示の中身を確認できます。
This skill provides comprehensive Rust code quality validation including formatting (rustfmt), linting (clippy), compilation checks (cargo check), testing (cargo test), security analysis (cargo audit), and best practices validation. Ensures code meets Rust idioms and project standards.
Verify Rust Toolchain:
# Check Rust version
rustc --version
# Check Cargo version
cargo --version
# Check rustfmt
rustfmt --version
# Check clippy
cargo clippy --version
Install/Update Components:
# Update Rust toolchain
rustup update
# Install rustfmt (if not present)
rustup component add rustfmt
# Install clippy (if not present)
rustup component add clippy
# Install cargo-audit for security checks
cargo install cargo-audit
# Install cargo-tarpaulin for coverage
cargo install cargo-tarpaulin
Deliverable: Rust toolchain ready
Check Formatting:
# Check if code is formatted
cargo fmt -- --check
# Check with edition
cargo fmt --edition 2021 -- --check
# Check specific files
rustfmt --check src/main.rs
# Check with verbose output
cargo fmt --verbose -- --check
Auto-Format Code:
# Format all code
cargo fmt
# Format with specific edition
cargo fmt --edition 2021
# Format specific file
rustfmt src/main.rs
Configuration (rustfmt.toml):
# rustfmt.toml
edition = "2021"
max_width = 100
hard_tabs = false
tab_spaces = 4
newline_style = "Unix"
use_small_heuristics = "Default"
reorder_imports = true
reorder_modules = true
remove_nested_parens = true
fn_single_line = false
where_single_line = false
imports_granularity = "Crate"
group_imports = "StdExternalCrate"
Deliverable: Formatting validation report
Fast Compilation Check:
# Basic check
cargo check
# Check with all features
cargo check --all-features
# Check workspace
cargo check --workspace
# Check specific package
cargo check --package my-package
# Check with verbose output
cargo check --verbose
Full Compilation:
# Build project
cargo build
# Build in release mode
cargo build --release
# Build with all features
cargo build --all-features
# Build all targets
cargo build --all-targets
Deliverable: Compilation status report
Run Clippy:
# Basic clippy check
cargo clippy
# Deny all warnings
cargo clippy -- -D warnings
# Pedantic mode (strictest)
cargo clippy -- -W clippy::pedantic
# All clippy lints
cargo clippy -- -W clippy::all
# Nursery lints (unstable but useful)
cargo clippy -- -W clippy::nursery
# Check workspace
cargo clippy --workspace
Clippy with Auto-Fix:
# Fix clippy suggestions
cargo clippy --fix
# Fix with deny warnings
cargo clippy --fix -- -D warnings
Configuration (clippy.toml or .clippy.toml):
# clippy.toml
msrv = "1.70" # Minimum Supported Rust Version
# Allow certain lints
allow = [
"clippy::module_name_repetitions",
]
# Warn on these
warn = [
"clippy::all",
"clippy::pedantic",
"clippy::cargo",
]
# Deny these
deny = [
"clippy::unwrap_used",
"clippy::expect_used",
"clippy::panic",
]
Deliverable: Clippy lint report
Run Tests:
# Run all tests
cargo test
# Run with verbose output
cargo test -- --nocapture
# Run specific test
cargo test test_name
# Run tests in specific module
cargo test module::test_name
# Run doc tests only
cargo test --doc
# Run with all features
cargo test --all-features
Test with Coverage:
# Install tarpaulin
cargo install cargo-tarpaulin
# Generate coverage
cargo tarpaulin --out Html --out Xml
# Coverage with threshold
cargo tarpaulin --fail-under 80
# Coverage for workspace
cargo tarpaulin --workspace
Deliverable: Test execution and coverage report
Dependency Security Check:
# Install cargo-audit
cargo install cargo-audit
# Run security audit
cargo audit
# Audit with JSON output
cargo audit --json
# Audit and fix vulnerabilities
cargo audit fix
# Check for yanked crates
cargo audit --deny yanked
Update Dependencies:
# Install cargo-outdated
cargo install cargo-outdated
# Check for outdated dependencies
cargo outdated
# Update dependencies
cargo update
# Update specific dependency
cargo update -p dependency-name
Deliverable: Security audit report
Check Dependency Tree:
# Show dependency tree
cargo tree
# Show dependencies for specific package
cargo tree --package my-package
# Show duplicates
cargo tree --duplicates
# Show dependencies with specific features
cargo tree --features feature-name
# Invert tree (show reverse dependencies)
cargo tree --invert
Check Unused Dependencies:
# Install cargo-udeps
cargo install cargo-udeps
# Find unused dependencies
cargo +nightly udeps
Deliverable: Dependency analysis report
Check for Unsafe Code:
# Find unsafe blocks
grep -r "unsafe" src/
# Count unsafe blocks
grep -r "unsafe" src/ | wc -l
# Use cargo-geiger for unsafe usage report
cargo install cargo-geiger
cargo geiger
Check Documentation:
# Build documentation
cargo doc
# Check for missing docs
cargo rustdoc -- -D missing_docs
# Check documentation tests
cargo test --doc
Deliverable: Code quality assessment
Benchmark Tests:
# Run benchmarks
cargo bench
# Run specific benchmark
cargo bench benchmark_name
# Use criterion for better benchmarks
# Add to Cargo.toml:
# [dev-dependencies]
# criterion = "0.5"
cargo bench
Performance Profiling:
# Build with release mode
cargo build --release
# Use flamegraph
cargo install flamegraph
cargo flamegraph
# Use perf (Linux)
perf record --call-graph dwarf ./target/release/binary
perf report
Deliverable: Performance analysis report
Run All Checks:
#!/bin/bash
# scripts/quality-check.sh
set -e # Exit on first error
echo "=== Rust Quality Checks ==="
echo "1. Code Formatting (rustfmt)..."
cargo fmt -- --check
echo "2. Compilation Check..."
cargo check --workspace
echo "3. Linting (clippy)..."
cargo clippy --workspace -- -D warnings
echo "4. Testing..."
cargo test --workspace
echo "5. Documentation Check..."
cargo doc --no-deps --document-private-items
echo "6. Security Audit..."
cargo audit
echo "7. Unused Dependencies..."
cargo +nightly udeps || true # Don't fail build
echo "=== All Quality Checks Passed ✅ ==="
Makefile Integration:
# Makefile
.PHONY: check fmt lint test quality
check:
cargo check --workspace
fmt:
cargo fmt
fmt-check:
cargo fmt -- --check
lint:
cargo clippy --workspace -- -D warnings
test:
cargo test --workspace
quality: fmt-check check lint test
@echo "All quality checks passed ✅"
Deliverable: Comprehensive quality report
| Check | Tool | Threshold | Auto-Fix |
|---|---|---|---|
| Formatting | rustfmt | Must pass | Yes |
| Compilation | cargo check | 0 errors | No |
| Linting | clippy | 0 warnings | Partial |
| Testing | cargo test | All pass | No |
| Coverage | tarpaulin | ≥ 80% | No |
| Security | cargo audit | 0 critical | Partial |
| Unsafe code | cargo geiger | Minimize | No |
Setup Git Hooks:
#!/bin/bash
# .git/hooks/pre-commit
echo "Running Rust quality checks..."
# Format check
if ! cargo fmt -- --check; then
echo "❌ Code not formatted. Run: cargo fmt"
exit 1
fi
# Clippy
if ! cargo clippy -- -D warnings; then
echo "❌ Clippy warnings found"
exit 1
fi
# Tests
if ! cargo test --quiet; then
echo "❌ Tests failed"
exit 1
fi
echo "✅ All pre-commit checks passed"
Make hook executable:
chmod +x .git/hooks/pre-commit
Deliverable: Pre-commit hooks configured
GitHub Actions Example:
# .github/workflows/rust-quality.yml
name: Rust Quality Checks
on: [push, pull_request]
env:
CARGO_TERM_COLOR: always
jobs:
quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: rustfmt, clippy
override: true
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Check formatting
run: cargo fmt -- --check
- name: Check compilation
run: cargo check --workspace
- name: Run clippy
run: cargo clippy --workspace -- -D warnings
- name: Run tests
run: cargo test --workspace --verbose
- name: Check documentation
run: cargo doc --no-deps --document-private-items
- name: Security audit
run: |
cargo install cargo-audit
cargo audit
- name: Generate coverage
run: |
cargo install cargo-tarpaulin
cargo tarpaulin --out Xml --fail-under 80
- name: Upload coverage
uses: codecov/codecov-action@v3
with:
files: ./cobertura.xml
Deliverable: CI/CD quality pipeline
# Check what would change
cargo fmt -- --check
# Apply formatting
cargo fmt
# Check specific file
rustfmt --check src/main.rs
# Check with verbose output
cargo check --verbose
# Clean and rebuild
cargo clean
cargo check
# Check dependencies
cargo tree
# Show detailed warnings
cargo clippy -- -W clippy::all
# Auto-fix suggestions
cargo clippy --fix
# Ignore specific warning (last resort)
#[allow(clippy::warning_name)]
# Run with verbose output
cargo test -- --nocapture
# Run specific test
cargo test test_name -- --exact
# Show test output
cargo test -- --show-output
# Rust Quality Check Report
## Summary
- **Status**: ✅ All checks passed
- **Date**: 2024-01-15
- **Project**: my-rust-project
## Checks Performed
### Formatting (rustfmt)
- **Status**: ✅ PASS
- **Files Checked**: 42
- **Issues**: 0
### Compilation (cargo check)
- **Status**: ✅ PASS
- **Workspace**: All packages compile
- **Warnings**: 0
### Linting (clippy)
- **Status**: ✅ PASS
- **Warnings**: 0
- **Pedantic**: Enabled
### Testing (cargo test)
- **Status**: ✅ PASS
- **Tests**: 156 passed
- **Doc Tests**: 23 passed
### Coverage (tarpaulin)
- **Status**: ✅ PASS
- **Coverage**: 87% (target: 80%)
### Security (cargo audit)
- **Status**: ✅ PASS
- **Vulnerabilities**: 0
- **Yanked Crates**: 0
### Documentation
- **Status**: ✅ PASS
- **Docs Build**: Success
- **Missing Docs**: 0
## Details
All Rust quality checks passed successfully. Code is well-formatted, compiles cleanly, passes all lints, has good test coverage, and is secure.
## Recommendations
- Continue maintaining high test coverage
- Keep dependencies updated
- Document all public APIs
- Minimize unsafe code usage
Input: Rust codebase quality check request Process: Run all Rust quality tools and analyze results Output: Comprehensive quality report with pass/fail status Next Step: Report to code-quality-specialist for consolidation
cargo fmt on save (IDE integration)cargo watch for continuous checkingまだレビューはありません。使ってみた感想をお寄せください。
概要と使いどころ
Validate WCAG 2.1 Level AA compliance and accessibility best practices. Use when performing accessibility audits and WCAG certification.
日本語の概要は準備中です。原文の説明を表示しています。
Analyze feature requirements, dependencies, and security considerations. Use when starting feature implementation from GitHub issues to understand scope, technical feasibility, and risks.
日本語の概要は準備中です。原文の説明を表示しています。
Run SQL queries against psql, BigQuery, or MySQL from the terminal, including natural-language-to-SQL and schema exploration. Use when analyzing data, inspecting DB state, or debugging tables. Trigger on "query the database", "SQL", "show me data from", "explore table".
日本語の概要は準備中です。原文の説明を表示しています。
Design REST APIs or function contracts with clear request/response specifications, error handling patterns, authentication strategies, and comprehensive documentation.
日本語の概要は準備中です。原文の説明を表示しています。
Generate comprehensive API endpoint tests for REST and GraphQL APIs. Creates tests for all HTTP methods, status codes, authentication, and validation.
日本語の概要は準備中です。原文の説明を表示しています。
Design component architecture and module structure using established architectural patterns for clean, maintainable, and scalable systems.
日本語の概要は準備中です。原文の説明を表示しています。