watch
runbooks watch
Section titled “runbooks 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.
runbooks watch RUNBOOK_SOURCE [flags]Arguments
Section titled “Arguments”RUNBOOK_SOURCE- A local path or remote URL pointing to arunbook.mdxfile, the directory containing arunbook.mdxfile, 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=::tmpfor 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 therunbookscommand 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 viaRUNBOOKS_TELEMETRY_DISABLE=1environment variable.
What it does
Section titled “What it does”When you run runbooks watch:
- Starts the Backend Server - Launches a Go-based HTTP server on port 7825
- Opens Your Browser - Automatically navigates to
http://localhost:7825 - Watches for Changes - Monitors the runbook file for any modifications
- Auto-Reloads - Automatically refreshes the browser when changes are detected (within ~300ms)
Writing a new runbook
Section titled “Writing a new runbook”runbooks watch /path/to/runbookThen in your editor:
- Make changes to
runbook.mdx - Save the file
- See your changes instantly in the browser - no manual refresh needed!
Technical details
Section titled “Technical details”File watching
Section titled “File watching”- Uses
fsnotifyfor 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
Auto-reload mechanism
Section titled “Auto-reload mechanism”- 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-changeevent - The browser receives the event and automatically reloads the page