---
title: AGENT.md Format and Deterministic Builds
description: Complete reference for AGENT.md frontmatter keys, folder layout, lazy skills, subagents, custom tools, determinism rules, and cvm agent build.
canonical: https://docs.caveman.so/agents/agent-md
product: Caveman Cloud
tab: Documentation
group: Build & Deploy Agents
---

# AGENT.md Format and Deterministic Builds

> Complete reference for AGENT.md frontmatter keys, folder layout, lazy skills, subagents, custom tools, determinism rules, and cvm agent build.

An agent build is a folder containing `AGENT.md` (YAML frontmatter plus Markdown instructions), or a single `.md` agent file. Running `cvm agent build` compiles that folder offline into a deterministic `agent.json` manifest and SHA-256 digest matching the public schema `https://caveman.so/schemas/agent-build.schema.json`.

## Folder layout

```text
my-agent/
├── AGENT.md                  # Frontmatter + instructions (required)
├── skills/
│   └── refunds/
│       └── SKILL.md          # Lazy-loaded skill (every file under skills/<name>/)
├── agents/
│   └── security/
│       └── AGENT.md          # Nested subagent (every file under agents/<name>/)
├── tools/
│   └── prorate_refund.mjs    # Custom code tool annotated with // @caveman-tool
└── evals/
    └── basic.eval.json       # Eval files (*.eval.json, *.eval.yaml, *.eval.yml)
```

Anything outside those conventions is reported as excluded from the build. With no path argument, `cvm agent build` builds `./AGENT.md`, or a single agent located under `.caveman/agents/` (`<name>.md` or `<name>/AGENT.md`).

## Build and inspect locally (no network)

```bash
cvm agent build ./my-agent
cvm agent build ./my-agent --out ./dist-build
```

Without `--out`, nothing is written to disk. `--out` requires a new or empty directory and writes `agent.json` plus all included build files.

## Frontmatter keys

`cvm agent build` parses fourteen frontmatter keys directly:

```markdown
---
name: support-triage
description: Route billing tickets and draft refunds
engine: caveman
model: claude-sonnet-5-5
computer: none
connectors:
  linear:
    tools: [list_issues, create_issue]
    after_untrusted: approve
drives:
  /kb: support-kb
  /memory: { drive: support-memory, write: true }
secrets: [STRIPE_KEY]
budgets:
  tools: 4000
channels:
  slack:
    events: [app_mention, direct_message]
    thread_mode: session
    approvals: interactive
schedules:
  daily-audit:
    cron: "0 9 * * 1-5"
    timezone: "UTC"
    task: "Summarize open escalations."
    concurrency: skip
    budget_usd: 2
output_schema:
  type: object
  required: [verdict, summary]
  properties:
    verdict: { type: string }
    summary: { type: string }
---

Your agent instructions go here.
```

| Key | Purpose | Allowed values / notes |
| --- | --- | --- |
| `name` | Agent identity | `[A-Za-z0-9._-]{1,100}`. Defaults to folder or file name when omitted. |
| `description` | Short summary | Displayed in `cvm deployments` and agent cards. |
| `engine` | Agent runtime loop | `caveman` (default), `claude-agent`, or `codex`. |
| `model` | Model class or exact slug | `fast`, `base`, `frontier`, `auto`, or an exact catalog model ID (`cvm models`). |
| `computer` | Sandbox tier | `none` (default for lightweight agents), `code`, or `linux`. `none` strips coding tools to keep prompt prefixes small. |
| `tools` | Built-in or custom tools | Built-in tool name string, or `{type: custom, name, description, input_schema}` for caller-answered tools. |
| `connectors` | Org MCP connectors | List (`[linear, notion]`) or map with `tools` (1-200), `as` (`shared`, `user`, `end_user`, or `{read, write}`), `args` (up to 16 scalar defaults), `approve`, `unpinned`, and `after_untrusted`. Up to 32 connectors; names only, never URLs or secrets. |
| `budgets` | Token budgets | `{tools: N}` (`100` to `100,000`) caps total tokens consumed by the connector tool card. |
| `drives` | Mounted versioned Drives | Map of mount path to Drive name (`"/kb": "support-kb"`) or `{drive, write, review, as}`. Set `review: true` so writes land in human-reviewed changesets. |
| `secrets` | Named org secrets | List of org secret names (`[STRIPE_KEY]`). Injected per command on Linux sandboxes; never embedded in the build. |
| `schedules` | Cron triggers | Named schedules with `cron`, `timezone`, `task`, `concurrency` (`skip`), and `budget_usd`. |
| `channels` | Inbound integrations | `slack` (`events`, `thread_mode`, `approvals`) or `github` (`events`, `mention`, `thread_mode`). |
| `subagents` | Subagent configuration | Subagent definitions alongside `agents/<name>/AGENT.md`. |
| `output_schema` | Structured final output | Standard JSON Schema object describing the agent's final structured payload. |

## Frontmatter syntax rules

Frontmatter supports plain and quoted scalars, inline arrays `[a, b]`, inline objects `{a: b}` (single-line or indented), block lists, nested block maps, or a single JSON object.

The parser fails closed (exit `2`) with an exact line number on:

- YAML block scalars (`|`, `>`), anchors, aliases, or tags
- Tab indentation
- Multi-line scalar continuations
- Unrecognized connector fields or out-of-range tool budgets

## Determinism and size limits

Two identical folders always produce the exact same `agent.json` SHA-256 digest:

- Files are sorted bytewise by relative path.
- No timestamps, git commits, local machine paths, or credentials enter `agent.json`.
- **Refused (exit `2`)**: symlinks, non-UTF-8 binary files, any file over `2 MiB`, `AGENT.md` or `agent.json` over `256 KiB`, or a total build over `8 MiB` or `1,000` files.

## Compile from TypeScript

`@caveman-ai/agent` exposes the exact same folder compiler programmatically:

```ts
import { compileAgentFolder } from "@caveman-ai/agent";

const build = compileAgentFolder("./my-agent");
console.log(build.digest);
```

## Verify and undo

Validate a folder without touching the network:

```bash
cvm agent build ./my-agent --format json
```

Next: test locally and ship with [Deploy, Run & Rollback](/agents/deploy-and-run).
