Watchexec
A cross-platform command-line watcher that runs tests, builds, checks or development restarts when files and directories change, with ignore rules and event coalescing.
A focused file-event workflow
Watchexec watches files and directories, coalesces editor events and runs a command when the selected scope changes. It fits local tests, linting, builds and development-server restarts when the monitored tree and task are deliberately limited.
Scope controls stability
Start with one source directory and one extension, then exclude dependencies, build output, caches, logs, version-control metadata and temporary files. A generated file inside the watch tree can otherwise trigger another run and create a loop.
Commands inherit real permissions
Watchexec executes the configured command with the current user's permissions and does not judge its behavior. Treat repository scripts as code, review the command before starting a watcher and keep destructive or deployment actions behind an explicit step.
Save to your cloud drive
Open the cloud drive to get the file directly, or save it for convenient access on another device.
Quark Cloud Drive
RecommendedSave Watchexec to this cloud drive
Baidu Netdisk
Save Watchexec to this cloud drive
Watchexec test, build and restart workflow
Use a small recoverable project, monitor one extension and run a harmless check first; only then add builds or a development-server restart.
Before you start
- Prepare a test project that can be restored and confirm the target command exits normally when run by hand.
- List source, temporary, dependency, build, log and cache directories before choosing the watch scope.
- Review every repository script and command before allowing the watcher to execute it.
Installation steps
- 01
Extract and inspect help
Verify Watchexec 2.5.1 and the Windows x64 archive, then review version, path, extension, ignore and restart options.
- 02
Run the command manually
Check working directory, permissions, exit code and generated files before adding event automation.
- 03
Define the smallest watch tree
Select one source directory and necessary extension, excluding dependencies, output, version-control metadata, cache and logs.
Quick start
- 01
Watch one file type
Configure an extension filter and run a quick non-destructive check, then save one source file to confirm a single expected trigger.
- 02
Verify ignore rules
Change a source, temporary file and generated file separately; stop immediately if output causes a repeated loop and expand exclusions.
- 03
Enable restart only when needed
For a development server, confirm the old process and children stop correctly before enabling restart, avoiding duplicate instances and port conflicts.
Usage tips
- Watchexec executes real commands with the terminal's permissions; avoid building shell commands from untrusted filenames or content.
- It may read `.gitignore` and `.ignore`, but generated and sensitive paths should still be excluded explicitly.
- Database migrations, deployments and deletion jobs are poor candidates for an unconfirmed file-event trigger.
Troubleshooting and uninstall
Why did a file change not trigger the command?
Check working directory, extension filter, ignore files, network filesystem behavior and the editor's save method, then reproduce with a local file.
Why is a port still occupied after stopping the watcher?
Find and stop leftover child processes, verify the process group and redesign the startup command before enabling restart again.
- Stop watchers and remove referencesTerminate the watcher and child processes, check editor tasks and PATH entries, then delete the extracted directory.
Frequently asked questions
What can Watchexec run after a file change?
It can run a specified command such as a test, linter, build or development-server restart with the current user permissions.
Why can one save trigger several runs?
Editors may create temporary or backup files; use extension filters, ignore rules and event coalescing to reduce unrelated triggers.
How does an infinite build loop happen?
A command writes output inside the monitored tree, and that output starts another run; exclude output, logs, caches and generated files.
Should deployment be an automatic watcher command?
Keep deployment behind a deliberate review and release step rather than allowing one local file event to launch a high-impact action.