
# Context docs for agents

Context docs are markdown pages about how your organization works, written by an owner or a person's own Builder agent and read by every agent in the organization before it builds. Add one from **Context** > **Add a doc**, write it, and press **Save**.

It worked when the page says "Added <title>. Agents read it with `agc context show <slug>`." and the doc appears in the list with that command beside it.

## Ask your agent

```text
Before you start, read our organization's context docs about data and naming,
and follow them in this change.
```

The agent lists the docs, reads the relevant ones, and says which it followed.

## Do it in the console

**Context** is in the left menu, above **Activity**. Every member can read it; only owners see **Add a doc** and **Edit**.

### Add a doc

1. Open **Context** and press **Add a doc**. In an organization with no docs yet, pick a starter instead: **How we name things**, **Our data**, **How we ship** or **Who to ask**, or **Start blank**. A starter is a skeleton of headings and prompts; it invents nothing about your company.
2. Fill in **Title**. The line under it shows the slug agents will use, e.g. `agc context show how-we-name-things`.
3. Write markdown in **Write**, or drop a `.md` or `.txt` file on **Drop a .md or .txt file here** (it replaces the text). **Preview** renders it.
4. Press **Save**.

### Edit or delete a doc

Press **Edit** on a doc's row, or on its page. Change the title or body and press **Save**; the slug stays the same when the title changes, so agents' references keep working. To delete, use **Delete this doc** at the bottom of the edit page. Agents stop seeing it at once, and Activity keeps a line.

## How it works

### What to write

Write what a new contractor gets wrong in their first week: how you name tables and money columns, which connection holds which data, your release habits, who decides what. Keep each doc to one topic, because agents read them by slug and a 40 KB catch-all gets skimmed. Don't paste anything you wouldn't hand every agent in the organization: docs aren't per app.

### No secrets

Saving a doc that contains anything secret-shaped (keys, tokens, connection strings with passwords) is refused, and the error names the line. Agents reach data through [connections](/docs/owners/connections.md), never through credentials in a doc.

### On the page

Each doc's row shows its title, a one-line excerpt, the `agc context show <slug>` command, its size and who changed it when. A doc's own page renders the markdown, with **The markdown agents read** one click away. The header counts docs against the limit, e.g. "12 of 50 docs".

## Context from agc

An agent sees only its own organization's docs: the one it joined with a join code and hasn't left. The app in the current folder must be in that organization or in none. Otherwise it's refused with `context.not_in_org`, unless that organization has no docs, when the answer is an empty list with a note. Success is `ok: true` with the organization's `docs`.

```bash
agc context
```

```json
{
  "ok": true,
  "product": "agent.cloud",
  "command": "context",
  "data": {
    "org": { "name": "Acme", "slug": "acme-1a2b3c" },
    "docs": [
      { "slug": "data-model", "title": "Data model", "bytes": 4210, "updated_at": "2026-10-18T14:02:11.000Z" },
      { "slug": "naming", "title": "Naming", "bytes": 980, "updated_at": "2026-10-12T09:40:00.000Z" }
    ],
    "writes": "every"
  },
  "next": [
    { "cmd": "agc context show data-model", "why": "Data model" },
    { "cmd": "agc context show naming", "why": "Naming" },
    { "cmd": "agc context search <words>", "why": "find the doc about a topic" }
  ]
}
```

```bash
agc context show data-model
agc context search billing cutoff
```

`show` returns one doc's markdown in `data.content`, and `search` returns the docs containing every word, with a snippet around the first match. Search is plain text, not semantic: every word must appear in the title or body, case-insensitive, with no ranking beyond title order. The "Your organization" part of the app's `AGENTS.md` also lists the doc titles and slugs, so an agent knows what exists without running anything. It says to read the ones that matter before building. `agc init` writes that part and is how you refresh it after docs change; `agc status`, `agc wait` and `agc up` never write `AGENTS.md`, and `agc status` points to `agc init --no-up` when the section is out of date.

A person's own Builder agent in your organization can add a doc, or edit one it has read, passing the `updated_at` it read as `--base`:

```bash
agc context add --title "Money columns" --file money.md
agc context edit money-columns --base 2026-10-18T14:02:11.000Z --file money.md
```

`--file -` reads standard input, and an edit can change `--title`, `--file` or both; the slug stays. The console's rules apply (no secrets, 100 KB, 50 docs). If someone saved the doc after the `--base` you read, the edit is refused with `context.changed`. Agents can't delete. The doc's row and Activity name the agent, e.g. "by agent <name>". To keep an agent to one doc, its person sets **Context it writes** to that slug on **Your agents**, and `writes` then shows that slug (otherwise `every` or `none`). Deploy keys, task tokens and other purposes can't write at all.

## Reference

| Field | Rule |
|---|---|
| Title | Required, up to 120 characters |
| Slug | Made from the title when the doc is created; a collision gets `-2`, `-3`; unchanged by later title edits |
| Body | Markdown, up to 100 KB, not empty |
| Upload | `.md` or `.txt` only, up to 100 KB |

| Command | `data` |
|---|---|
| `agc context` | `org` (`name`, `slug`, or null), `docs` (`slug`, `title`, `bytes`, `updated_at`), `note` when there are none, and `writes` (`every`, a slug, or `none`) whenever `org` isn't null |
| `agc context show`, `add`, `edit` | `slug`, `title`, `content`, `updated_at` |
| `agc context search` | `query`, `org`, `matches` (each doc's fields plus `snippet`) |

Flags: [CLI reference](/docs/reference/cli-reference.md).

## Errors

Console messages; the composer comes back with what you typed and the reason.

| Message | HTTP | Cause | Fix |
|---|---|---|---|
| "Line <n> looks like <what>. Context is shared with every agent in the organization, so remove it first." | 400 | A secret-shaped line. | Remove it; use a connection or secret instead. |
| "A doc is at most 100 KB." | 400 | Body or upload too large. | Split it into topics. |
| "An organization keeps at most 50 docs. Delete or merge one first." | 400 | At the doc limit. | Merge related docs. |
| "Upload a .md or .txt file." | 400 | Another file type. | Convert it to markdown. |
| "Give the doc a title." / "The doc is empty." | 400 | Missing title or body. | Fill both in. |

From agc, every `context.*` code, its exit and fix is in the [Error code catalog](/docs/reference/error-code-catalog.md). The two you'll hear about: `context.not_in_org` (the agent hasn't joined the app's organization; make it a Start an app prompt) and `agent.purpose` (only a person's own Builder agent writes; it tells you what to add instead).

## Limits

| Limit | Value |
|---|---|
| Docs per organization | 50 |
| Doc size | 100 KB |
| Title | 120 characters |
| Search | First 8 distinct words, 200 characters; snippet about 80 characters either side of the first match |

## Agent notes

- Read context with `agc context show <slug>` before building; don't scrape the console page. An empty list with a note isn't an error.
- A doc states the organization's conventions; it never overrides Agent Cloud's rules (approvals, secrets by name only, data kept out of chat).
- `context.not_in_org` isn't fixed by retrying: the person brings you in with a join code.
- Write conventions, never a secret or anything that belongs to one app (that stays in its repo).

## Related

- [Setting up an organization](/docs/owners/setting-up-an-organization.md)
- [Quickstart: start from the console](/docs/getting-started/quickstart-new-app.md#start-from-the-console)
- [Connections](/docs/owners/connections.md)
- [Members, roles, invites, join requests](/docs/owners/members-roles-invites-join-requests.md)
- [Activity log](/docs/owners/activity-log.md)

<!-- feedback:start -->
---
Wrong, outdated or unclear? Run `agc feedback docs "owners/context-docs-for-agents: <what is wrong>" --body <file>` with the sentence quoted in the file. No code or app data is sent.
<!-- feedback:end -->
