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

# Coding agents

> Let coding agents and CI jobs change your schema and content through the nohead CLI, with readable output and a note on every change.

Coding agents such as Claude Code, Cursor or Codex, and CI jobs, work best with Nohead through the `nohead` CLI: its `--json` output and exit codes cost an agent less context than a list of tools.

## Set up the CLI

[Install the CLI](https://docs.nohead.io/cli/overview.md#install), then sign in on your own machine:

```bash theme={null}
nohead login    # approve a key for the project in the web app
nohead whoami   # the key, the project in use and its scopes
```

`nohead login` opens the web app for you to approve a key for the project (an agent can run it too, and shows you the code to check). `nohead link <project>` in a checkout keeps an agent working there in that project: see [Projects](https://docs.nohead.io/cli/overview.md#projects).

In CI, or for an agent that should act with a key of its own, create a key in the web app instead, as in [Work with agents](https://docs.nohead.io/guides/agents.md#give-each-agent-its-own-key), and set it as `NOHEAD_API_KEY`. In CI, [pin the CLI's version](https://docs.nohead.io/cli/overview.md#install) too. Don't keep `NOHEAD_API_KEY` set where you've logged in: while it's set, it wins over saved keys and a folder's link.

## Output agents can rely on

* With `--json`, stdout carries exactly one JSON document: the API's own representation of the result, or for `schema` commands the plan.
* Errors go to stderr. With `--json`, they use the API's error envelope, `{ "error": { "type", "message", "request_id", "details" } }`, and the CLI adds a few types of its own, such as `network_error` and `schema_differs`. Quote the `request_id` when you ask for support.
* Rate limits (`429`), network failures and `5xx` responses are retried on their own, and every write carries an `Idempotency-Key`, so a retry never applies a change twice.
* Exit codes tell API errors, usage errors and an unreachable API apart: [Output and exit codes](https://docs.nohead.io/cli/overview.md#output-and-exit-codes) lists them.

## Schema as code in CI

Keep your collections and fields in a `nohead.schema.yaml` file in your repository, and let CI apply it. `nohead schema diff` shows a pull request's changes, `nohead schema push --yes` applies the file after merge, and a scheduled `nohead schema diff --exit-code` catches changes someone made in the web app instead. A push never deletes collections or fields, and changes that rewrite existing values (field migrations) need `--allow-migrations`. [Schema as code](https://docs.nohead.io/guides/schema-as-code.md) covers the file and the workflow.

## Change content safely

```bash theme={null}
nohead records update rec_01J9ZQ3F8X --set price:=12 --if-revision 3 --note "Fix the price typo"
nohead drafts create rec_01J9ZQ3F8X --set title="Spring menu"
nohead records revert rec_01J9ZQ3F8X 2 --dry-run
```

* **Say why.** `--note` is kept with the revision, the merge or the schema change it makes, and shown in history next to the key's name and the client it came through, such as the CLI. Through the API, send the `Nohead-Change-Note` header; in the SDKs, pass `changeNote` (TypeScript) or `change_note` (Python, Ruby).
* **Don't overwrite newer edits.** `--if-revision` refuses the change with `412` if someone changed the record since the revision the agent read. Read it again, and apply the change again.
* **Propose, don't publish.** A draft holds changes until a person reviews them and merges them in the editor (**Publish changes**, or **Apply changes** for an unpublished record), or with `nohead drafts merge`.
* **Sync without duplicates.** Through the API, an SDK or the MCP server's `create_record`, creating a record with `upsert_on`, the key of a `unique` field such as a slug, updates the record that already has that value instead of adding another, so a sync job can run again and again.
* **Undo.** Every record change is a revision you can revert, `--dry-run` previews a revert, and deleted records, fields, collections and assets can be restored for 30 days.

## A snippet for your AGENTS.md

Tell your coding agent how your project uses Nohead, in `AGENTS.md`, `CLAUDE.md` or your tool's rules file:

```markdown theme={null}
## Content (Nohead)

- The schema lives in `nohead.schema.yaml`. Change it there and run
  `nohead schema diff`; CI runs `nohead schema push --yes`. Never push field
  migrations (`--allow-migrations`) without showing a person the diff's
  migration preview first.
- Use `--json` and check exit codes. Pass `--note "<why>"` on every write and
  `--if-revision <n>` when updating a record you read earlier.
- Propose content changes as drafts for review instead of publishing them.
- API map: https://api.nohead.io/llms.txt
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.