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

# Agen CLI

> Reference guide for managing and streaming AI workloads locally.

The Agen CLI enables developers to directly integrate AI workloads right where they code. The CLI natively communicates with your existing active sessions to retrieve code created inside Agen isolated sandbox instances.

## Installation

Ensure that you have `npm` or `yarn` correctly installed via Node.

```bash theme={null}
npm install -g @agenhq/cli
```

### Setup and Authentication

Before pulling any patch files from active Sandbox sessions, confirm you have securely logged in to the Agen web portal inside your local terminal environment.

```bash theme={null}
agen login
```

Running the `login` command launches a secure authorization flow directly inside your default web browser. Once finished, an HTTP API token maps uniquely to your verified user account and local `.agen` workspace configurations.

## The Watch Command

The real magic happens behind the scenes while the CLI listens to your codebase changes seamlessly.

The following command starts a continuous bidirectional synchronization stream:

```bash theme={null}
agen watch <SESSION_ID>
```

When you launch this, real-time files created, deleted, and modified via AI changes are parsed, previewed via standard stdout console updates, and integrated into your Git-backed codebase instantly! As your preferred LLM provider generates iterations of variables, code loops, tests, and component styling, `agen watch` streams the exact differences dynamically into your code editor.

## Common Issue: Stale Patches

If you shut down the `agen CLI` during an active process, some previously active sessions might be missed. You can simply resume your stream via the same command:

```bash theme={null}
agen watch <SESSION_ID>
```

The system automatically pulls the entire directory delta changes (git format patches) previously produced over our real-time messaging network and catches your local codebase repository accurately back up to the current sandbox state.
