# grepai watch

> CLI reference for grepai watch

## grepai watch

Start the real-time file watcher daemon

### Synopsis

Start a background process that monitors file changes and maintains the index.

The watcher will:
- Perform an initial scan comparing disk state with existing index
- Skip unchanged files by comparing modification times (ModTime) for faster subsequent launches
- Index modified and new files
- Monitor filesystem events (create, modify, delete, rename)
- Apply debouncing (500ms) to batch rapid changes
- Handle atomic updates to avoid duplicate vectors

Background mode:
  grepai watch --background              Run in background with default log directory
  grepai watch --background --log-dir /custom/path  Run with custom log directory
  grepai watch --status                  Check if background watcher is running
  grepai watch --stop                    Stop the background watcher

Default log directories:
  Linux:   ~/.local/state/grepai/logs (or $XDG_STATE_HOME/grepai/logs)
  macOS:   ~/Library/Logs/grepai
  Windows: %LOCALAPPDATA%\grepai\logs

Log file name:
  Inside a git repository: grepai-worktree-<id>.log (--status prints the ID)
  Elsewhere:               grepai-watch.log

Log management:
  Logs are not rotated automatically. To prevent disk usage growth, periodically
  truncate or archive the log file:
    echo "" > ~/Library/Logs/grepai/grepai-watch.log  (macOS example)
  Or set up logrotate (Linux) / Newsyslog (macOS) for automatic rotation.

```
grepai watch [flags]
```

### Options

```
      --background         Run in background mode
  -h, --help               help for watch
      --log-dir string     Directory for log files (default: OS-specific)
      --no-ui              Disable interactive UI in foreground mode
      --status             Show background watcher status
      --stop               Stop the background watcher
      --workspace string   Workspace name for multi-project mode
```

### SEE ALSO

* [grepai](/grepai/commands/grepai/)	 - Semantic code search CLI

###### Auto generated by spf13/cobra on 30-Oct-2026
