File-watching CLI for rerunning commands or emitting change events when watched files change.
$cargo install --locked watchexec-cli
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-eventsand--emit-events-to=json-stdio|json-fileprovide 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
--postponeor--shell=nonefor stricter automation.