← Back to tools
View AGENTS.md for watchexec
watchexec
Execute commands when watched files change
Description
watchexec watches a directory for changes and runs a command when files are modified. It supports filtering by file extension or glob pattern, debouncing, and signal handling for clean restarts.
Install
homebrew
brew install watchexeccargo
cargo install watchexec-clipacman
sudo pacman -S watchexecAI Summary
A file watcher that executes commands on changes. Watches directories, filters by extension or glob, debounces events, and handles process restarts cleanly.
Capabilities
- + Watches files and directories for changes
- + Filter by file extension, glob pattern, or ignore patterns
- + Debouncing to avoid rapid re-execution
- + Clean process restart with signal handling
Use When
- → Auto-running tests when source files change
- → Rebuilding a project on file save
- → Need a language-agnostic file watcher
Avoid When
- x Your build tool already has watch mode (e.g., cargo watch, nodemon)
Usage Patterns
Run tests on file changes
watchexec -e py -- pytest Runs pytest whenever a .py file changes
Restart a server on changes
watchexec -r -- ./server Restarts the server process when files change