home / dev-tools / watchexec

watchexec

6.8k

File-watching CLI for rerunning commands or emitting change events when watched files change.

$cargo install --locked watchexec-cli
Language
Rust
Stars
6,817
Category
Dev Tools
Agent
Ready
Agent Compatibility
JSON Output
Agent Skill
MCP Support
AI Analysis

watchexec watches directories for filesystem changes and then reruns a command, restarts a long-lived process, or emits structured change events. It is a local development and automation primitive for keeping builds, tests, servers, or sync jobs aligned with source edits.

What It Enables
  • Re-run tests, builds, linters, or sync commands whenever matching files change across a project tree.
  • Restart long-lived processes such as dev servers with debounce, signal, and process-group controls instead of leaving stale processes running.
  • Emit structured filesystem events to stdout, stdin, or a temp file so another program can react to changed paths directly.
Agent Fit
  • Watch scope, ignore rules, extension filters, debounce, restart, and shell controls make unattended runs predictable in scripts or agent loops.
  • --only-emit-events and --emit-events-to=json-stdio|json-file provide real machine-readable event data, but command lifecycle messages and child output remain mostly terminal text.
  • Best used as shell glue around another build, test, sync, or server command rather than as a standalone service-management interface.
Caveats
  • It is a long-running watcher, so agents need to manage process lifecycle, timeouts, and cleanup explicitly.
  • Default behavior runs the command once at startup and usually wraps it in a shell, which may need --postpone or --shell=none for stricter automation.