modules/home/programs/cli-agents/shared/skills/rust/SKILL.md
Use cargo for Rust development with check-first workflow. Prefer cargo check over cargo build, use debug builds for testing, AVOID release builds unless explicitly needed.
npx skillsauth add not-matthias/dotfiles-nix rustInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You are a Rust development specialist using cargo and related tools. This skill provides comprehensive workflows, best practices, and common patterns for Rust development.
AVOID expensive builds:
cargo build --release or cargo install --path . (very slow)cargo check firstcargo check to verify compilation (fast, no codegen)cargo run for iterative development and testing functionality (builds debug + runs in one command)cargo build without --release)Decision tree:
cargo check (fastest)cargo run (builds debug + runs - use this for iteration)cargo build (debug)cargo build --release (slow)Always follow this sequence when developing or validating Rust code:
cargo test --quiet
cargo check --quiet # Fast compilation check (PREFER - no binary output)
cargo clippy
IMPORTANT: Use cargo check, NOT cargo build, for validation. Only use cargo build when you actually need the binary artifact.
For iterative development and testing functionality:
cargo run # Builds debug and runs (PREFERRED for development iteration)
cargo run -- arg1 arg2 # Pass arguments to test different scenarios
# OR
cargo build --quiet # Only if you need the binary artifact without running it
Rationale:
cargo run to iterate on functionality, or cargo build if you need the artifactRust commands can be long-running, especially for large projects:
# Standard timeout (2 minutes) - sufficient for most operations
cargo test --quiet
cargo check --quiet
cargo build --quiet # Debug build
# timeout: 120000
# Extended timeout ONLY for release builds (10 minutes) - AVOID if possible
cargo build --release # WARNING: Very slow, only use when explicitly needed
# timeout: 600000
Best practice: Use the standard 2-minute timeout for check/test/debug builds. Only use extended timeout if you absolutely must do a release build.
Always attempt automatic fixes first:
cargo clippy --fix --allow-dirty
Flags:
--fix: Automatically apply suggested fixes--allow-dirty: Allow fixes even with uncommitted changes--no-deps and --all-targetsSeparate actionable issues from domain-appropriate patterns:
Actionable bugs:
Domain-appropriate suppressions:
cast_possible_truncation in Excel formula evaluators)unused_assignments for loop invariants)missing_errors_doc)needless_pass_by_value)Function-level suppression:
#[allow(clippy::cast_possible_truncation)]
fn process_excel_value(val: u64) -> u32 {
val as u32 // Domain: Excel row numbers are always < u32::MAX
}
Module-level suppression (top of file):
#![allow(clippy::missing_errors_doc)]
#![allow(clippy::cast_possible_truncation)]
// Rest of module code...
Project-level suppression (Cargo.toml):
[lints.clippy]
missing_errors_doc = "allow"
cast_possible_truncation = "allow"
needless_pass_by_value = "allow"
cargo clippy to see all warningscargo clippy --fix --allow-dirty to auto-fixOften suppressed in domain-specific code:
cast_possible_truncation - When domain guarantees safetycast_sign_loss - When values are known positivemissing_errors_doc - Internal tools/librariesmissing_panics_doc - When panics are domain-impossibleneedless_pass_by_value - API design choicesmodule_name_repetitions - Sometimes necessary for claritytoo_many_lines - Large but cohesive functionsunused_assignments - Loop invariants and initialization patternsGenerally should fix:
redundant_closure - Simplify codeunnecessary_unwrap - Handle errors properlymanual_map - Use iterator methodsmatch_same_arms - Reduce duplicationneedless_return - Clean up styleGet detailed information about any lint:
cargo clippy --explain <LINT_NAME>
# Warn on specific lint
cargo clippy -- -W clippy::unwrap_used
# Deny specific lint (error)
cargo clippy -- -D clippy::unwrap_used
# Allow specific lint
cargo clippy -- -A clippy::needless_pass_by_value
# Forbid specific lint (cannot be overridden)
cargo clippy -- -F clippy::unwrap_used
cargo check # Fast compilation check (PREFER THIS)
cargo check --quiet # Suppress output
cargo check --all-targets # Check all targets
Use cargo check instead of cargo build when you just need to verify code compiles.
cargo build # Debug build (use for testing binary)
cargo build --quiet # Suppress output
cargo build --all-targets # Build all targets (bins, libs, tests, benches)
cargo build --target <TARGET> # Cross-compile for target
# AVOID unless explicitly needed (very slow):
cargo build --release # Optimized release build (WARNING: SLOW)
cargo test # Run all tests
cargo test --quiet # Suppress output except failures
cargo test <NAME> # Run specific test
cargo test --lib # Test library only
cargo test --doc # Test documentation examples
cargo test -- --nocapture # Show println! output
cargo test -- --test-threads=1 # Run tests serially
cargo run # Run default binary (debug build)
cargo run --bin <NAME> # Run specific binary
cargo run --example <NAME> # Run example
cargo run -- <ARGS> # Pass arguments to binary
# AVOID unless you need optimized performance (very slow to build):
cargo run --release # Run optimized build (WARNING: SLOW)
cargo doc # Build documentation
cargo doc --open # Build and open in browser
cargo doc --no-deps # Only document this crate
cargo add <CRATE> # Add dependency
cargo add <CRATE>@<VERSION> # Add specific version
cargo add --dev <CRATE> # Add dev dependency
cargo remove <CRATE> # Remove dependency
cargo update # Update dependencies in Cargo.lock
cargo update <CRATE> # Update specific dependency
cargo new <NAME> # Create new binary project
cargo new --lib <NAME> # Create new library project
cargo init # Initialize in current directory
cargo clean # Remove target directory
cargo search <QUERY> # Search crates.io
cargo publish # Publish to crates.io
cargo package # Create distributable package
cargo tree # Show dependency tree
Cargo can leave processes running that cause "resource busy" or lock errors:
pkill -f cargo
Use this before running cargo commands if you encounter:
Place comments on separate lines, not inline:
Correct:
# This dependency is used for CLI parsing
clap = "4.0"
# Linting configuration
[lints.clippy]
# Suppress in domain where values are guaranteed valid
cast_possible_truncation = "allow"
Incorrect:
clap = "4.0" # This may cause parsing errors
cast_possible_truncation = "allow" # Don't do this
[lints.clippy]
# Code quality - generally enforce
unwrap_used = "warn"
expect_used = "warn"
# Domain-specific allowances
cast_possible_truncation = "allow"
missing_errors_doc = "allow"
# Style preferences
needless_pass_by_value = "allow"
module_name_repetitions = "allow"
# 1. Create feature branch (outside cargo)
git checkout -b feature/new-thing
# 2. Develop code
# ... edit files ...
# 3. Run full validation sequence
cargo test --quiet
cargo check --quiet # Use check, not build, for validation
cargo clippy
# 4. Auto-fix clippy warnings
cargo clippy --fix --allow-dirty
# 5. Re-run validation
cargo test --quiet
cargo check --quiet
cargo clippy
# 6. Commit changes
git add .
git commit -m "Add new feature"
# 1. See all warnings
cargo clippy
# 2. Auto-fix what's possible
cargo clippy --fix --allow-dirty
# 3. Review remaining warnings
cargo clippy
# 4. For domain-specific warnings, add suppressions
# Edit Cargo.toml [lints.clippy] section or add #[allow(...)]
# 5. Verify clean clippy
cargo clippy
# 6. Ensure tests still pass
cargo test --quiet
# 1. Clean build artifacts
cargo clean
# 2. Kill any stuck processes
pkill -f cargo
# 3. Check compilation only (faster)
cargo check
# 4. Full build with verbose output
cargo build --verbose
# 5. If still failing, check with different targets
cargo check --lib
cargo check --tests
# 1. Check current dependency tree
cargo tree
# 2. Update all dependencies
cargo update
# 3. Or update specific dependency
cargo update serde
# 4. Validate after update
cargo test --quiet
cargo check --quiet # Use check, not build, for validation
cargo clippy
# 5. Review Cargo.lock changes
git diff Cargo.lock
# Complete validation before committing (PREFER THIS)
cargo test --quiet && cargo check --quiet && cargo clippy
# If any step fails, the sequence stops
# Fix issues and repeat
# NOTE: Only use cargo build instead of cargo check if you actually need
# the binary artifact. For validation, cargo check is sufficient and much faster.
# Fast check loop
cargo check
# ... fix errors ...
cargo check
# ... fix more ...
cargo test --quiet # when ready to validate
WARNING: Only use this workflow when preparing an actual release. For regular development, use the check-first workflow.
# Full validation for release (SLOW - only for actual releases)
cargo test
cargo test --release # WARNING: SLOW
cargo build --release # WARNING: VERY SLOW
cargo clippy -- -D warnings # Deny all warnings
cargo doc --no-deps
For regular development, use instead:
cargo test --quiet
cargo check --quiet
cargo clippy
# Check everything
cargo check --all-targets
cargo test --all-targets
cargo clippy --all-targets
# Test code examples in docs
cargo test --doc
# Build and review docs
cargo doc --open
Issue: "could not compile due to previous error"
# Solution: Check specific error, may need cargo clean
cargo clean
cargo build
Issue: "waiting for file lock on package cache"
# Solution: Kill stuck processes
pkill -f cargo
Issue: Clippy warnings overwhelming
# Solution: Auto-fix first, then strategic suppression
cargo clippy --fix --allow-dirty
# Review remaining, add suppressions as needed
Issue: Tests passing but clippy failing
# Solution: This is normal - fix clippy issues or suppress appropriately
cargo clippy --fix --allow-dirty
# Then review and add strategic suppressions
development
Emulates not-matthias's technical blog writing style. Use when writing blog posts, technical articles, README content, or any long-form technical prose. Produces investigation-driven, first-person narratives with dry humor, practical code examples, and concrete takeaways.
development
Create and manage Git worktrees for parallel feature development. Use when user wants to work on multiple features simultaneously or needs isolated development environments.
development
Systematic technical research and brainstorming. Given a question, recursively explores attached specifications, source code, documentation, GitHub repositories, and authoritative online sources to build comprehensive, accurate answers. Surfaces edge cases, caveats, and implementation details that matter.
development
Converts a research paper (PDF path, uploaded PDF, or URL) into a reusable skill that stores distilled knowledge for future sessions. Use when a user asks to "turn this paper into a skill", "make this PDF reusable", "encode this research", or wants project-specific decisions backed by a specific paper without re-uploading it.