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

# Your first loop

> One agent — a contract reviewer — taken from a sentence to a validated spec, a build, and a first verdict.

This walkthrough builds one agent end to end: a **contract reviewer** that extracts governing law,
indemnification and termination clauses from vendor contracts. Everything shown is from a real
session.

<Info>
  **Binary:** `cd` into your project and run `helix` — you are at the prompt. Not installed yet?
  See [Standalone binary](/helix/install/standalone).
  **Plugin** (Claude Code / Codex): open your coding agent in the project and type `/mutagent-helix`.
</Info>

## Spec the contract reviewer

One sentence starts the interview:

```
/spec a contract-review agent that extracts governing law, indemnification and termination clauses from vendor contracts
```

Helix reads your project for context (a sample contract in `contracts/` gets noticed and used), then
interviews you — structured questions with written-out options, not a blank form:

<Frame caption="A real /spec run, trimmed and sped up — about 8 seconds of a 3-minute session.">
  <img src="https://mintcdn.com/architech/HQbLuNnglP7czETc/images/helix/spec-interview.gif?s=539d605392aed1e837d6da65a5ed86d9" alt="An animated capture of the spec interview: the dashboard, the /spec command being typed, the agent reasoning about the contract-review domain, and the structured question dialog appearing with options for output format." width="1080" height="660" data-path="images/helix/spec-interview.gif" />
</Frame>

For this agent it asked, among others:

| Question                                                   | The answer taken                                                                  |
| ---------------------------------------------------------- | --------------------------------------------------------------------------------- |
| How should the agent structure the extracted clauses?      | Structured JSON with exact clause text, section citations, and key-term summaries |
| When a contract is silent on a topic, how should it react? | Flag as missing/silent with a risk notice — never fabricate                       |
| Where will the agent run?                                  | A Claude Code markdown agent (`.claude/agents/contract-reviewer.md`)              |

The interview ends with a validated `agentspec.yaml` — the portable definition of the agent. An
excerpt of what this run produced:

```yaml .mutagent/specs/contract-reviewer/agentspec.yaml theme={null}
metadata:
  id: contract-reviewer
  name: Contract Reviewer
spec:
  intent:
    outcomes:
      - "Extract governing law jurisdiction, indemnification coverage/triggers, and
         termination terms into validated structured JSON."
      - "Provide exact section citations and verbatim clause excerpts for legal verification."
      - "Explicitly flag missing or silent clauses with risk notices."
    constraints:
      - "Never fabricate or hallucinate contract language."
      - "Must provide exact section references and verbatim text excerpts for every clause."
    nonGoals:
      - "Negotiating contract language or redlining terms."
      - "Providing definitive legal advice or enforceable legal opinions."
```

The spec also carries the agent's system prompt, its standard operating procedure (ingest →
locate clauses → structure the output), and — this matters for the rest of the loop — its
**evaluation contract**: `verbatim-extraction-accuracy`, `missing-clause-detection`,
`structured-json-validity`. The session closes by naming the next step:

```
### Next Lifecycle Step
To turn this Definition into executable code, run:
*build
```

## Build it

```
/build
```

Build implements the validated spec into the target the interview chose — here, a markdown agent at
`.claude/agents/contract-reviewer.md` — through an implement-and-verify loop, and stops at a working
agent. [Build](/helix/lifecycle/build) has the mechanism.

## Evaluate it

```
/evaluate contract-reviewer
```

Evaluate scores the agent against the criteria the spec declared: did every citation match verbatim
contract text, did silent clauses get flagged rather than invented, did the JSON validate. Each
criterion returns pass/fail with a confidence, rolled into one verdict.
[Evaluate](/helix/lifecycle/evaluate) has the full pipeline.

## Improve one you already have

You don't have to start at Spec. Point Helix at an agent that already runs and has traces:

```
evaluate contract-reviewer against last month's reviews
```

Where it flags failures, ask why:

```
why is contract-reviewer missing indemnification clauses in order forms?
```

Diagnose returns ranked remedies. Nothing is applied until you approve; when you accept one, Helix
applies it and re-runs the loop so you can confirm it helped.

## You're done when

* The Helix dashboard renders (`/help` repaints it any time), and
* `/spec` (or just asking for a spec) starts the interview.

A full `/evaluate` needs a subject and its traces — that's the loop proper, above.

<Tip>
  Prefer prose to commands? Every command here has a natural-language equivalent — "I want a
  contract-review agent…" routes to `/spec` the same way. See
  [Commands](/helix/reference/commands).
</Tip>
