Skip to content

Feature: Agent Hooks — file-watch auto-run commands on save #486

Description

@Delqhi

Feature Request: Agent Hooks / File Watch

Inspired by

Kiro (AWS) — agent hooks automate follow-up actions like running tests when files are saved

What it does

Watch the workspace for file changes and automatically run commands when files are saved.

Proposed CLI

sin-code watch --on-save "*.go" --run "go test ./..."
sin-code watch --on-save "*.ts" --run "npm test"
sin-code watch --on-save "*.py" --run "pytest"
sin-code watch --stop

Current state

SIN-Code has internal/hooks/ (24 lifecycle events) and internal/hooklife/ (programmatic hooks), but no file-system watcher. The hooks fire on agent lifecycle events (tool.pre, tool.post, verify.pass, etc.), not on external file changes.

Implementation approach

  1. Use fsnotify (pure Go, no CGO — M2) for file system watching
  2. New package cmd/sin-code/internal/filewatch/
  3. Pattern matching via filepath.Match or doublestar
  4. Run command via sin_bash (goes through permission engine — M4)
  5. Debounce: max 1 trigger per 2 seconds (avoid rapid-fire on bulk saves)
  6. Optional: --notify for desktop notification on pass/fail

Mandate compliance

  • M2: fsnotify is pure Go, no CGO
  • M4: Watch-triggered commands go through permission engine
  • M7: Race-free — watcher goroutine + command execution mutex

Priority: Medium

Effort: Small

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfile-watchloop-systemAgent loop core: budget, gates, delegation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions