# \[Feature Request\] File-Watcher Automations: Trigger Agent Chats on File/Directory Changes (Event-Driven Alternative to Cron)

**URL:** <https://discuss.ai.google.dev/t/feature-request-file-watcher-automations-trigger-agent-chats-on-file-directory-changes-event-driven-alternative-to-cron/190360>\
**Category:** Google Antigravity\
**Tags:** feature-request, gemini\
**Created:** [October 18, 2026, 5:24pm UTC](https://discuss.ai.google.dev/t/feature-request-file-watcher-automations-trigger-agent-chats-on-file-directory-changes-event-driven-alternative-to-cron/190360 "2026-10-18T17:24:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kevin\_Genskowsky](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/kevin_genskowsky/32/129681_2.png) [@Kevin\_Genskowsky](https://discuss.ai.google.dev/u/Kevin_Genskowsky)\
**Post date:** [October 18, 2026, 5:24pm UTC](https://discuss.ai.google.dev/t/feature-request-file-watcher-automations-trigger-agent-chats-on-file-directory-changes-event-driven-alternative-to-cron/190360/1 "2026-10-18T17:24:13Z")

</div>

Antigravity currently supports time-based scheduled automations (`builtin: "schedule"` / cron / `/schedule`). We propose adding an **event-driven file watcher trigger** (e.g., a `/watch` command or a `"builtin": "watch"` sidecar) that triggers an agent conversation whenever specified files or glob patterns are modified, created, or deleted.

### **Problem Statement & Motivation**

Time-based scheduling (cron) works well for routine periodic checks (e.g., daily standup summaries or hourly PR reviews), but modern development workflows are inherently **event-driven**.

Currently, if a developer wants an agent to react to local code changes, they have to:

1. **Poll aggressively with cron** (e.g., every 1–5 minutes), which wastes tokens, introduces unnecessary lag, and clutters history with no-op runs.
2. **Manually prompt the agent** after every edit or test run.
3. **Build an external script** using OS tools (like `fswatch`, `inotifywait`, or PowerShell `FileSystemWatcher`) to invoke the CLI, which lacks clean IDE integration.

### **Proposed Solution**

#### **1. In-Chat Slash Command (`/watch`)**

Allow developers to start a file-watching session directly in chat:

```auto
text

```

/watch “src/\*\*/\*.ts” “Run tests for modified files and fix any failing unit tests”

Or with debouncing options:

```auto
text

```

/watch --pattern=“docs/\*\*/\*.md” --debounce=3000ms “Review documentation for clarity and style consistency”

#### **2. Declarative Automation (`sidecar.json`)**

Extend the automations/sidecar engine to support file triggers alongside cron schedules:

```auto
json

```

{

“builtin”: “file\_watch”,

“display\_name”: “Test & Lint Watcher”,

“restart\_policy”: “always”,

“args”: {

“patterns”: [“src/\*\*/\*.ts”, “tests/\*\*/\*.ts”],

“ignore”: [“\*\*/node\_modules/\*\*”, “\*\*/.git/\*\*”, “\*\*/dist/\*\*”],

“events”: [“modify”, “create”],

“debounce\_ms”: 2000,

“max\_runs\_per\_hour”: 15

},

“prompt”: “The following files were modified: {{changed\_files}}. Run pytest/npm test on them and explain or fix any regressions.”

}

#### **3. Context Injection**

When a file change event triggers the agent, provide rich context in the initial turn:

- List of changed/created/deleted file paths (`{{changed_files}}`).
- Optional diff preview or patch snippet for modified files.

* * *

### **Target Use Cases**

- **Continuous Test-Driven Pair Programming (TDD):** The agent automatically inspects failing tests and offers inline fixes as soon as test files or source files are saved.
- **Documentation & Schema Sync:** Modifying `schema.prisma`, OpenAPI specs, or protobuf definitions automatically prompts the agent to update client SDKs, types, or doc files.
- **Drop-Folder / Ingestion Automations:** Dropping a new CSV, PDF, or log file into a designated directory triggers the agent to parse, validate, and summarize the data.
- **Auto-Linter & Style Fixer:** Automatically reviewing code against `.agents/rules/` or project guidelines whenever non-trivial edits are detected.

* * *

### **Key Considerations & Safeguards**

- **Debouncing & Batching:** Crucial to prevent multiple runs when IDEs auto-save rapidly or during `git checkout` / `npm install`. An adjustable debounce window (e.g., 1–3 seconds default) should bundle multiple related changes into a single agent turn.
- **`.gitignore` Awareness:** Automatically inherit `.gitignore` rules to avoid triggering on temporary build artifacts, `.lock` files, or cache directories.
- **Token Budget & Rate Limiting:** Built-in safeguards (e.g., `max_runs_per_hour` or a prompt asking _“Do you want the agent to continue watching?”_) to prevent runaway token spend.
- **Conversation Strategy:** Configurable option to either **start a fresh conversation** per event batch or **append as a new turn** to an active thread.
