loc bengaluru, ist | local --:-- srijanshukla18@gmail.com →
[post]/tech/vigil-watch-command-for-autonomous-llms

vigil - a live file-diff watcher for coding agents

/ 4 min read· ai

Once I had LLMs editing code autonomously, I wanted to watch a directory breathe in real time. Existing tools gave me file events or diffs or a TUI, never all three, so I built vigil.

GitHub: github.com/srijanshukla18/vigil

When I have coding agents running autonomously in a repo, I want a small terminal pane on the side where I can watch what files they are touching and see the exact inline diffs in real time.

Existing CLI tools each do only one piece of this:

  • watch / viddy: re-runs a command every N seconds
  • fswatch / entr: prints file paths when events fire, no UI or diffs
  • lazygit: shows git diffs, but isn’t a live chronological event stream of what the agent just touched 2 seconds ago

At first I tried hacking it together with a one-liner:

fswatch -r . | xargs -I{} sh -c 'echo "--- {} ---" && git diff {}'

Which fell apart pretty fast:

  • git diff completely misses new untracked files, scratch files, or files outside a git repo
  • when an agent formats or saves 15 files at once, the terminal scrollback explodes
  • no easy way to pause scrolling, inspect a diff, or clear the screen without restarting the command

So I vibe-coded a small Rust TUI for it called vigil.

What vigil does

Run one command in the directory you want to watch:

vigil .

What you get:

  • recursive file watcher on the directory
  • live event stream (created / modified / deleted) with inline colored text diffs
  • auto-follows new edits by default, pauses auto-scroll as soon as you scroll up manually
  • debounces rapid save bursts and skips binary/huge files
  • ignores .git, node_modules, target, .DS_Store out of the box

How it’s built

Kept the Rust crate stack super standard:

  • notify for cross-platform filesystem events
  • similar for computing line diffs in memory
  • ratatui + crossterm for the TUI
  • clap for CLI flags

Wait - how does it show diffs for untracked files if it doesn’t use git diff?

When vigil starts up, it snapshots an in-memory baseline of the text files in the directory. Whenever a file changes on disk, similar diffs the new file contents against the last cached version in memory and updates the snapshot. That way you see exact line-by-line diffs even on brand-new scratch files or repos that haven’t been committed yet.

Keybindings are standard vim-style:

  • j / k to scroll, g / G for top/bottom
  • d to toggle inline diffs on/off
  • c to clear the event stream
  • q to quit

Why I keep it open

When a background agent is running for 10+ minutes, you don’t wanna stare at its chat stream reading every tool call, and you also don’t wanna walk away blind and come back to 40 ruined files.

Keeping vigil . open in a corner pane lets you glance over and immediately see:

  • is the agent editing the same file 8 times in a loop?
  • did it randomly start touching files in a folder it has no business editing?
  • are the generated tests landing where they should?

If it looks good, I let it cook. If I see it touching weird files in vigil, I hit Ctrl+C on the agent right away before it wastes another 50k tokens.