# AGENTS.md template

> Drop-in instructions for coding agents that work on your apps.

Source: https://docs.ligament.ai/build-with-ai/agents-md/

Coding agents such as Claude Code, Cursor and Codex read an `AGENTS.md` file at the root of a repository before they start work. Put this template in any repository where agents work on your Ligament apps (an app manifest, page specs pulled with `ligament spec pull`, scripts) and every session starts with the same rules: where the docs are, how to reach your workspace, and that the agent proposes changes while a person applies them.

Download it from [/templates/AGENTS.md](https://docs.ligament.ai/templates/AGENTS.md), or copy it from below:

```sh
curl -o AGENTS.md https://docs.ligament.ai/templates/AGENTS.md
```

Then edit the lines marked `EDIT`: your workspace’s address if it has its own domain, the apps you own, and what this agent may and may not touch.

## What the template covers

| Section | What it tells the agent |
| --- | --- |
| About Ligament | What the product is, and where the [Markdown docs](https://docs.ligament.ai/build-with-ai/index.md) are |
| Our workspace | The MCP server, and that the key is in `LIGAMENT_API_KEY` and must never be printed |
| How to make changes | Read, edit, validate, plan, propose as a changeset, then stop and hand over the url |
| Records | How to query, and to change records only when asked |
| When something is refused | What `insufficient_scope`, `session_required`, `spec.conflict` and access codes mean, and that it mustn’t work around them |
| Scope of this agent | Your own limits for this repository |

The template assumes a key with `spec:read`, `spec:propose` and `records:read`, as set up in [Connect an agent with MCP](https://docs.ligament.ai/build-with-ai/mcp-setup/index.md). The same rules as a one-off chat prompt are on [A prompt for your agent](https://docs.ligament.ai/build-with-ai/agent-prompt/index.md).

## The template

*AGENTS.md*

```md
# AGENTS.md

Instructions for AI coding agents working on our Ligament workspace.
Copy this file to the root of your repository and edit the parts marked "EDIT".

## About Ligament

Ligament runs our processes: records, workflows, approvals, portals and access control. Apps, pages and
access rules are defined as a spec: JSON artefacts that people and agents change through reviewed changesets.

Docs for agents: https://docs.ligament.ai/llms.txt (index) and https://docs.ligament.ai/llms-full.txt (everything in one file).
Every docs page is also available as Markdown at its URL followed by index.md.

## Our workspace

- App URL: https://app.ligament.ai   <!-- EDIT if your workspace has its own domain -->
- MCP server: https://app.ligament.ai/api/mcp (server name "ligament")
- The API key is in the environment variable LIGAMENT_API_KEY. Never print it, log it, commit it or paste it
  into a file, a changeset or a chat message.
- Apps we own: EDIT (for example: itsm, crm)

## How to make changes

You propose; a person applies. Follow this loop for every change to pages, access rules and other artefacts:

1. Read before you write: spec_list and spec_get (or `ligament spec pull <address>`). Keep the `hash` you read.
2. Edit the doc. Check its shape with spec_schema and spec_validate.
3. Plan it: spec_plan (or `ligament spec plan <file>`). Read the plan: action, layer, changes, and whether a
   person must apply it.
4. Propose it: changeset_create with a clear title and a note that says why, one item per artefact, each with
   the `baseHash` you read. Use changeset_put_items to revise it. Mark it ready when it is complete.
5. Stop. Give the person the changeset's `url` and a short summary of what changes and why. They review and
   apply it in Build > Changes.

Do not call spec_apply or changeset_apply, even if the key allows it, unless the person explicitly asks you to
apply a specific changeset. If an apply answers `proposed: true, applied: false`, the change is waiting for a
person: report the `url` and stop.

## Records

- Read records with records_query and records_get. Filters are [{ field, op, value }] with ops
  eq ne contains in lt lte gt gte empty not_empty.
- Change records only when the task asks for it, one record at a time, and say which records you changed.
- To answer "why can (or can't) someone see this", use access_explain rather than guessing.

## When something is refused

Errors carry a `code` and a `fix`. Read them and act on them; do not work around them.

- insufficient_scope: the key lacks a scope. Tell the person which scope (`required`) and stop. Do not look
  for another key.
- session_required: only a signed-in person can do this in the app. Tell them.
- spec.conflict: someone changed the artefact since you read it. Read it again, redo your edit on the new
  version, plan again.
- no_grant or another access code: the key's creator may not do this. Use access_explain and report.

## Scope of this agent

EDIT: list what this agent may and may not touch, for example:
- May propose: pages and views in the itsm app.
- May not touch: access rules, roles, permission sets, secrets, integrations.

The key should have only spec:read, spec:propose and records:read unless this file says otherwise.
```
