watchexec is a free, open source frameworks & platforms project written in Rust and released under Apache-2.0. It has 7,239 GitHub stars, 211 forks and 34 open issues, and was last pushed 3 days ago. On this registry it ranks #57 of 125 tracked projects in Frameworks & Platforms, with 5 head-to-head comparisons available.

What is watchexec?

Watchexec is a standalone, language-agnostic command-line tool written in Rust that watches a path and runs a command whenever it detects modifications, aimed at developers who are tired of re-running the same build, test, or lint command by hand.

What it is

Watchexec is a small, self-contained file-watching utility distributed as the watchexec-cli package under the Apache-2.0 licence. It monitors the current directory and all subdirectories for changes and then runs whatever command it is given, on macOS, Linux, and Windows. Because it is compiled Rust rather than a script, it needs no language runtime and is not tied to any particular ecosystem: the same binary can drive npm run build, a Python server, or an artifact rebuild. The project also publishes a family of crates — watchexec-events, watchexec-signals, watchexec-supervisor, ignore-files, and project-origins — so that other tools can build specialised watchers on the same foundation.

The problem it solves is the repetitive loop at the centre of software development: edit a file, switch to the terminal, retype the same command, read the output. Watchexec replaces hand-rolled shell loops built around xargs and platform-specific file-watching incantations with a single invocation. It also smooths over messy filesystem events: multiple events are coalesced into one so that editors writing swap or backup files on every save do not trigger a storm of runs, .gitignore and .ignore files are loaded so that build output and vendored directories stay quiet, and process groups keep forking programs under the watcher's control. The paths that changed are passed to the command through environment variables or standard input.

Key capabilities

  • Watches the current directory and every subdirectory, with extension filtering such as watchexec -e js,css,html npm run build.
  • Restarts long-running processes with the -r flag, as in watchexec -r -e py -- python server.py.
  • Coalesces multiple filesystem events into one run, so editors that write swap or backup files during saving do not trigger repeated executions.
  • Loads .gitignore and .ignore files to keep excluded paths from triggering commands.
  • Uses process groups to retain control of forking programs instead of orphaning child processes.
  • Exposes changed paths to the executed command through environment variables or STDIN, and documents every option in watchexec --manual, watchexec -h, and the manual page in doc/watchexec.1.md.

Who uses it and how

  • Front-end developers watching JavaScript, CSS, and HTML files and triggering a bundler or build script on each save.
  • Python developers restarting a development server automatically with -r -e py -- python server.py.
  • Rust and Cargo users, through cargo watch, a specialised watcher for Rust/Cargo projects that the README now strikes through.
  • Tool authors embedding the watchexec library or watchexec-supervisor, alongside downstream projects such as cargo lambda, create-rust-app, devenv.sh, dotter, ghciwatch, and tectonic.

Getting started

Install from a package manager for Arch, Debian, Homebrew, Nix, Scoop, or Chocolatey, take a pre-built binary from the GitHub releases page, use cargo binstall watchexec-cli, or build from source with cargo install --locked watchexec-cli. The basic pattern is then watchexec followed by the command to run.

How it compares

Watchexec is built to sit alongside complementary command-line tools rather than replace them: the README suggests pairing it with checkexec to run only when source files are newer than a target, with just as a modern alternative to make, and with systemfd for socket-passing during development. Its closest named relative is cargo watch, a specialised watcher for Rust/Cargo projects now struck through in the README, while notify is credited as the third-party crate handling the underlying file-modification events.

When to use it — and when not to

Watchexec is a single binary with no database, storage layer, or mail server to operate, so the operational burden is close to zero; the trade-off is that everything is configured on the command line or through ignore files. Anyone who wants a graphical interface, a hosted service, or framework-aware defaults should look elsewhere. The README excerpt is deliberately brief and defers most detail to the CLI README and the manual page, so expect to read watchexec --manual rather than skim a long front page.

project readme (upstream, from github) — read inline

CI status on main branch

Watchexec

Software development often involves running the same commands over and over. Boring!

watchexec is a simple, standalone tool that watches a path and runs a command whenever it detects modifications.

Example use cases:

  • Automatically run unit tests
  • Run linters/syntax checkers
  • Rebuild artifacts

Features

  • Simple invocation and use, does not require a cryptic command line involving xargs
  • Runs on OS X, Linux, and Windows
  • Monitors current directory and all subdirectories for changes
  • Coalesces multiple filesystem events into one, for editors that use swap/backup files during saving
  • Loads .gitignore and .ignore files
  • Uses process groups to keep hold of forking programs
  • Provides the paths that changed in environment variables or STDIN
  • Does not require a language runtime, not tied to any particular language or ecosystem
  • And more!

Quick start

Watch all JavaScript, CSS and HTML files in the current directory and all subdirectories for changes, running npm run build when a change is detected:

$ watchexec -e js,css,html npm run build

Call/restart python server.py when any Python file in the current directory (and all subdirectories) changes:

$ watchexec -r -e py -- python server.py

More usage examples: in the CLI README!

Install

Packaging status

All options in detail: in the CLI README, in the online help (watchexec -h, watchexec --help, or watchexec --manual), and in the manual page.

Augment

Watchexec pairs well with:

  • checkexec: to run only when source files are newer than a target file
  • just: a modern alternative to make
  • systemfd: socket-passing in development

Extend

Downstreams

Selected downstreams of watchexec and associated crates:

  • cargo watch: a specialised watcher for Rust/Cargo projects.
  • cargo lambda: a dev tool for Rust-powered AWS Lambda functions.
  • create-rust-app: a template for Rust+React web apps.
  • devenv.sh: a developer environment with nix-based declarative configs.
  • dotter: a dotfile manager.
  • ghciwatch: a specialised watcher for Haskell projects.
  • tectonic: a TeX/LaTeX typesetting system.

Frequently asked questions

Is watchexec free to use?

watchexec is open source under the Apache-2.0 licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does watchexec do?

Executes commands in response to file modifications

What is watchexec written in?

watchexec is primarily written in Rust. Its source is publicly available at https://github.com/watchexec/watchexec, and it has 7,239 GitHub stars.