# Agents

Give a coding agent the run, and let it fix and re-verify until nothing fails.

## MCP server

```bash
haystack verify mcp
```

Runs a stdio MCP server that exposes the verifier to an agent, with tools including `verify_start` and `verify_wait`. Point your agent at it and it can start runs and wait on verdicts without shelling out.

## Machine-readable output

```bash
haystack verify --json
haystack verify status --json
haystack verify findings --json
```

`--json` is available on the run commands and the read commands, so an agent can act on findings rather than parse a screen.

## Exit codes

`haystack verify watch` distinguishes three outcomes, which is what makes an automated loop safe to write:

```
0   every test passed
1   tests failed
2   the run or the infrastructure broke
```

An agent should keep iterating on **1** and stop on **2**. Retrying a broken run wastes compute and can look like a fix when the tests never actually ran.

## Intent transcripts

```bash
haystack verify --intent-transcript ./agent-session.md
```

When an agent wrote the change, its transcript is evidence of what the change was meant to do. Passing it lets the run judge behaviour against intent, not just against the base revision.
