TL;DR — Quick Summary

cargo-watch watches your Rust project and auto-runs cargo commands on file changes. Build, test, clippy, run — instant feedback loop for Rust development.

cargo-watch gives Rust instant feedback. Save, build, test — automatically, on every change.

Installation

# Cargo
cargo install cargo-watch

Usage

# Auto-check (default)
cargo watch

# Auto-build
cargo watch -x build

# Auto-test
cargo watch -x test

# Auto-run (restarts on change)
cargo watch -x run

# Auto-clippy
cargo watch -x clippy

# Chain commands (run in order)
cargo watch -x check -x test -x clippy

# Custom command
cargo watch -- cargo fmt --check

# Ignore patterns
cargo watch --ignore "*.log"

# Clear screen between runs
cargo watch -c

# Watch specific paths
cargo watch -w src -w tests

# Debounce (delay between change and run)
cargo watch -d 2

# With shell command
cargo watch -s "cargo test && echo 'All good!'"

Summary

  • cargo-watch auto-runs cargo commands on file changes
  • Build, test, clippy, run, fmt — any cargo command
  • Chain multiple commands for a full development pipeline
  • Clear screen, debounce, ignore patterns
  • Essential for Rust development workflow