← Back to tools

watchexec

Execute commands when watched files change

Development Productivity linuxmacoswindows Rust Apache-2.0

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

homebrewbrew install watchexec
cargocargo install watchexec-cli
pacmansudo pacman -S watchexec

AI 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

View AGENTS.md for watchexec