Skip to Content
04 ReferenceFile watcher setup guide

File watcher setup guide

Auto-sync your rules when you save changes to agent files. This guide provides the fastest and most reliable options for each platform.


Quick start

For each platform, we provide two options:

  1. Fastest: Quickest to set up (1-2 minutes)
  2. Most Reliable: Production-ready, handles edge cases

Choose your platform below:

VS Code (Fastest: ~2 minutes)

Option 1: VS Code task (fastest)

Create .vscode/tasks.json:

{ "version": "2.0.0", "tasks": [ { "label": "AlignTrue Auto-Sync", "type": "shell", "command": "aligntrue sync", "presentation": { "reveal": "silent", "panel": "dedicated", "showReuseMessage": false }, "runOptions": { "runOn": "folderOpen" } } ] }

Create .vscode/settings.json:

{ "files.autoSave": "afterDelay", "files.autoSaveDelay": 1000, "task.autoDetect": "on" }

Usage:

  • Files auto-save after 1 second of inactivity
  • Task runs aligntrue sync automatically
  • Silent output (check Terminal if needed)

Option 2: VS Code extension (most reliable)

Install Run on Save extension:

  1. Open Extensions (Cmd/Ctrl+Shift+X)
  2. Search “Run on Save”
  3. Install by emeraldwalk

Create .vscode/settings.json:

{ "emeraldwalk.runonsave": { "commands": [ { "match": "\\.cursor/rules/.*\\.mdc$", "cmd": "aligntrue sync" }, { "match": "AGENTS\\.md$", "cmd": "aligntrue sync" } ] } }

Advantages:

  • Only runs on specific file changes
  • Handles rapid edits gracefully
  • Shows sync status in output panel

Troubleshooting

Sync runs too often

Problem: File saves trigger multiple syncs

Solution: Add debounce delay

{ "delay": 2000 // Wait 2 seconds before syncing }

Sync doesn’t trigger

Problem: File watcher not detecting changes

Solutions:

  1. Check file paths are correct
  2. Verify aligntrue sync works manually
  3. Check watcher is running (ps aux | grep nodemon)
  4. Restart watcher service

VS Code task won’t run

Problem: Task not executing on file save

Solutions:

  1. Open Command Palette (Cmd/Ctrl+Shift+P)
  2. Search “Tasks: Run Task”
  3. Select “AlignTrue Auto-Sync”
  4. Check Terminal output for errors

High CPU usage

Problem: File watcher using too much CPU

Solutions:

  1. Exclude unnecessary directories:
{ "ignore": ["node_modules", ".git", "dist"] }
  1. Increase delay between checks
  2. Use more targeted watch patterns

Permission errors

Problem: “EACCES” or “permission denied”

Solutions (macOS/Linux):

chmod +x watch-sync.sh chmod 755 .cursor/rules

Solutions (Windows):

  • Run PowerShell as Administrator
  • Check file permissions in folder properties

Performance tips

  1. Watch specific directories only (not entire project)
  2. Add debounce delay (1-2 seconds)
  3. Exclude large directories (node_modules, .git)
  4. Use nodemon for production (most optimized)
  5. Limit concurrent syncs (nodemon handles this)

Recommendation by use case

Use CaseRecommendationWhy
Solo dev, VS CodeVS Code TaskBuilt-in, no install
Solo dev, any editornodemonUniversal, reliable
Team, CI/CDsystemd/launchdAlways on, restarts
Windows power userPowerShellNative, no dependencies
Quick experimentfswatch/inotifywaitMinimal setup

Next steps

  1. Choose option for your platform
  2. Set up file watcher (fastest option first)
  3. Edit .cursor/rules/*.mdc or AGENTS.md
  4. Save and verify sync runs automatically
  5. If issues, try “most reliable” option

Questions? Check docs/troubleshooting.md or open an issue.


Last Updated: 2025-10-28

Last updated on