Skip to content

watch

Use runbooks watch to “watch” a runbook.mdx file (or its scripts, checks, or template files) for changes and automatically reload the Runbook as needed.

This command is intended for authors of runbooks.

Terminal window
runbooks watch RUNBOOK_SOURCE [flags]
  • RUNBOOK_SOURCE - A local path or remote URL pointing to a runbook.mdx file, the directory containing a runbook.mdx file, or an OpenTofu/Terraform module directory. See runbooks open for supported remote URL formats and OpenTofu/Terraform module auto-detection.
  • --working-dir <path> - Base directory for script execution and file generation (default: current directory)
    • All relative paths are resolved from this directory
    • Can be absolute or relative to current directory
    • Use --working-dir=::tmp for a temporary directory (automatically cleaned up on exit), useful for isolated testing or sandboxed execution
  • --output-path <path> - Directory where generated files will be written (default: generated)
    • Resolved relative to the working directory
  • --tf-runbook <keyword-or-path> - Select a built-in template or provide a local custom runbook for OpenTofu/Terraform modules. Remote URLs are not supported. See runbooks open for available templates and details.
  • --disable-live-file-reload - Enable executable registry validation. Scripts will not reload from disk when they are updated; instead, you must re-run the runbooks command to apply script changes. This trades lower convenience for higher security. See Execution Security Model for details.
  • --no-telemetry - Disable anonymous telemetry. Can also be set via RUNBOOKS_TELEMETRY_DISABLE=1 environment variable.

When you run runbooks watch:

  1. Starts the Backend Server - Launches a Go-based HTTP server on port 7825
  2. Opens Your Browser - Automatically navigates to http://localhost:7825
  3. Watches for Changes - Monitors the runbook file for any modifications
  4. Auto-Reloads - Automatically refreshes the browser when changes are detected (within ~300ms)
Terminal window
runbooks watch /path/to/runbook

Then in your editor:

  1. Make changes to runbook.mdx
  2. Save the file
  3. See your changes instantly in the browser - no manual refresh needed!
  • Uses fsnotify for efficient file system monitoring
  • Watches the directory containing your runbook file
  • Implements debouncing (300ms) to handle editors that save files multiple times
  • Only triggers on Write and Create events for your specific runbook file
  • Uses Server-Sent Events (SSE) to push notifications from server to browser
  • The browser maintains a persistent connection to /api/watch/sse
  • When the file changes, the server sends a file-change event
  • The browser receives the event and automatically reloads the page