watchman
File watching service for large codebases
TLDR
Watch a directory
SYNOPSIS
watchman command [options] [arguments]
DESCRIPTION
watchman is a file watching service that monitors directories and triggers actions when files change. It was designed for large codebases requiring efficient file change detection.
The daemon maintains inotify/FSEvents watches and records file changes. Clients query for changes efficiently - even with millions of files, queries return in milliseconds.
Triggers execute commands when matching files change. This enables automated testing, building, or syncing. Triggers can filter by file pattern and use templated commands.
The query system uses a JSON expression language for complex file matching. Queries can filter by name, type, size, modification time, and more. Results include file metadata.
Clock values track change history. Subscribing to changes since a clock enables incremental processing - only handling new changes rather than full scans.
Watchman integrates with build tools (Buck, Bazel), IDEs, and testing frameworks. It provides the file watching layer that other tools build upon.
PARAMETERS
watch PATH
Start watching directory.watch-del PATH
Stop watching directory.watch-list
List all watches.watch-project PATH
Watch project root.find ROOT [ARGS]
Find files matching criteria.query ROOT EXPR
Query files with expression.since ROOT CLOCK
Find files changed since clock.trigger ROOT NAME PATTERN -- CMD
Set up triggered command.trigger-del ROOT NAME
Remove trigger.trigger-list ROOT
List triggers.log-level LEVEL
Set logging level.get-config ROOT
Get watch configuration.shutdown-server
Stop watchman daemon.version
Show version and capabilities.
CAVEATS
Daemon must be running for watches. System limits on watched files may need increasing. Not all filesystems support efficient watching. Configuration persists across restarts. Memory usage grows with file count.
HISTORY
watchman was developed at Facebook (Meta) and released in 2012. It was designed to handle Facebook's massive codebase where inotify alone wasn't sufficient. The project became a foundation for various developer tools needing efficient file change detection.
SEE ALSO
inotifywait(1), entr(1), fswatch(1)
