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:
- Fastest: Quickest to set up (1-2 minutes)
- Most Reliable: Production-ready, handles edge cases
Choose your platform below:
VS Code
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 syncautomatically - Silent output (check Terminal if needed)
Option 2: VS Code extension (most reliable)
Install Run on Save extension:
- Open Extensions (Cmd/Ctrl+Shift+X)
- Search “Run on Save”
- 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:
- Check file paths are correct
- Verify
aligntrue syncworks manually - Check watcher is running (
ps aux | grep nodemon) - Restart watcher service
VS Code task won’t run
Problem: Task not executing on file save
Solutions:
- Open Command Palette (Cmd/Ctrl+Shift+P)
- Search “Tasks: Run Task”
- Select “AlignTrue Auto-Sync”
- Check Terminal output for errors
High CPU usage
Problem: File watcher using too much CPU
Solutions:
- Exclude unnecessary directories:
{
"ignore": ["node_modules", ".git", "dist"]
}- Increase delay between checks
- Use more targeted watch patterns
Permission errors
Problem: “EACCES” or “permission denied”
Solutions (macOS/Linux):
chmod +x watch-sync.sh
chmod 755 .cursor/rulesSolutions (Windows):
- Run PowerShell as Administrator
- Check file permissions in folder properties
Performance tips
- Watch specific directories only (not entire project)
- Add debounce delay (1-2 seconds)
- Exclude large directories (node_modules, .git)
- Use nodemon for production (most optimized)
- Limit concurrent syncs (nodemon handles this)
Recommendation by use case
| Use Case | Recommendation | Why |
|---|---|---|
| Solo dev, VS Code | VS Code Task | Built-in, no install |
| Solo dev, any editor | nodemon | Universal, reliable |
| Team, CI/CD | systemd/launchd | Always on, restarts |
| Windows power user | PowerShell | Native, no dependencies |
| Quick experiment | fswatch/inotifywait | Minimal setup |
Next steps
- Choose option for your platform
- Set up file watcher (fastest option first)
- Edit
.cursor/rules/*.mdcorAGENTS.md - Save and verify sync runs automatically
- If issues, try “most reliable” option
Questions? Check docs/troubleshooting.md or open an issue.
Last Updated: 2025-10-28
Last updated on