# Agents and CI

Dryv is built to be driven by scripts and agents as safely as by people.

## Give an agent the context

`dryv init` writes `dryv/README.md` and a Dryv block in `AGENTS.md`. Refresh them any time:

```bash
dryv docs --write
```

Agents can read the built-in guides offline: `dryv docs`, `dryv docs dryv-yaml`, `dryv docs errors`, `dryv docs agents`.

## Rules an agent should follow

- Use `--json --no-input` and branch on `status` and `code`.
- Order: `dryv doctor`, `validate`, `plan`, `generate --dry-run`, then `generate --yes`.
- Never hand-edit managed generated files; change the definitions or the pack.
- Ask the user before choosing names, structure or behaviour.
- Use `dryv why <path>` before touching a generated file.

## CI

```bash
dryv generate --check --json --no-input
```

It exits with status 2 when generated output is out of date. Grant workspace trust explicitly with `dryv trust --yes`: Dryv never trusts a workspace on its own in CI. The engine needs no key or token.

See the [CLI reference](/docs/usage/cli) for every command and error code.

## The loop at a glance

```mermaid
flowchart TD
    D["dryv doctor"] --> V["dryv validate"]
    V --> P["dryv plan"]
    P --> R["dryv generate --dry-run"]
    R --> G{"Diff as expected?"}
    G -- yes --> W["dryv generate --yes"]
    G -- no --> E["Fix definitions or pack"]
    E --> V
    W --> X["dryv generate --check in CI"]
```
