> ## Documentation Index
> Fetch the complete documentation index at: https://aspect.build/llms.txt
> Use this file to discover all available pages before exploring further.

# Watch mode for aspect run and aspect gazelle

> aspect run --watch rebuilds a binary as you edit and restarts it only when its runfiles change, or hands the change to a dev server over the ibazel protocol or the Incremental Build Protocol.

[← Shipped](https://aspect.build/shipped)

# Watch mode for aspect run and aspect gazelle

***

![An edit rebuilds the target and reloads the running process](https://mintlify.s3.us-west-1.amazonaws.com/aspectbuild/images/marketing/illustrations/shipped-run-watch.svg)

Edit, Ctrl-C, `bazel run`, wait, repeat. Pass `--watch` to [`aspect run`](https://aspect.build/docs/cli/tasks/run) and the task rebuilds the target after each settled batch of workspace changes, then gets the new build into the running process.

```shell theme={null}
aspect run --watch //services/api:server -- --port 9090
```

## How the new build gets in

* **Restart, only when it matters.** A rebuild that changes the target's runfiles restarts the binary with the same arguments. An edit that doesn't touch the binary or its runfiles leaves it running.
* **ibazel protocol.** A target tagged `ibazel_notify_changes` gets `IBAZEL_BUILD_STARTED` and `IBAZEL_BUILD_COMPLETED SUCCESS` on stdin instead of a restart, so dev servers written for `ibazel run` work unchanged.
* **Incremental Build Protocol.** A binary that connects to the socket named in `IBP_WATCH_SOCKET_FILE` receives the changed files after each build and applies them in place, keeping its state. Tag it `supports_incremental_build_protocol` to require the connection.

[`aspect gazelle --watch`](https://aspect.build/docs/cli/tasks/gazelle) reruns Gazelle the same way, so BUILD files keep up while you edit.

Both are in the Aspect CLI, free. [Watch mode](https://aspect.build/docs/cli/tasks/run.md#watch-mode) covers how the task picks a protocol for each target.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.