How to Write Docs — Machine-Readable YAML Frontmatter¶
Doc frontmatter is consumed by the documentation system and agent context loader — not the skill runtime. It answers: what is this doc, and when should it be loaded?
This convention is derived from OpenClaw's doc corpus (200+ files using summary + read_when
consistently) but is not formally documented there. This guide is the canonical reference
for our agent foundation.
1. Schema¶
Scope: Frontmatter is required on all
.mdfiles that are part of the doc corpus — i.e., indexed byagentctland loaded by the agent. The following files are excluded and must not have frontmatter:README.md,CHANGELOG.md,CONTRIBUTING.md,ARCHIVED.md.
Core fields (all docs):
---
title: "Short display title"
summary: "One-line description of what this doc covers."
read_when:
- Condition under which this doc is relevant
- Another specific trigger condition
---
Extended fields (plan/experiment docs only):
---
title: "My Refactor Plan"
summary: "Plan to isolate X from Y with end-to-end deadlines."
read_when:
- Reviewing the X refactor approach
status: draft # draft | active | done
owner: my-team
last_updated: "2025-07-01"
---
Field reference¶
| Field | Required | Context | Purpose |
|---|---|---|---|
title |
Yes | All docs | Display name for nav and headings |
summary |
Yes | All docs | One-line scope description for discovery |
read_when |
Yes | All docs | Load conditions — when is this doc relevant? |
status |
No | Plans/experiments | draft, active, or done |
owner |
No | Plans/experiments | Team or person responsible |
last_updated |
No | Plans/experiments | ISO date of last meaningful update |
requires_skills |
No | Docs tied to skills | Skill slugs that must be installed for this doc to be actionable |
superseded_by |
No | Reference docs | Slug of the doc that replaces this one |
source_study |
No | Plan/architecture docs | Research study slug that informed this doc |
documents_skill |
No | Reference docs | Skill slug this doc describes |
produced_by |
No | Reference docs | Task slug that produced this doc |
descriptionappears in ~23 OpenClaw docs as an inconsistent duplicate ofsummary. Do not use it — usesummaryonly.
2. The summary field¶
One sentence. Describes the doc's scope, not its title.
# Bad — just restates the title
summary: "Skills authoring guide."
# Good — describes scope and audience signal
summary: "How to author SKILL.md files with machine-readable YAML frontmatter for Agent Zero."
3. The read_when field¶
Each entry is a specific condition, not a topic label. Write it as a sentence fragment starting with a verb or noun that completes "Read this when...":
# Bad — too vague, no actionable signal
read_when:
- Skills
- Development
# Good — specific, actionable conditions
read_when:
- Writing or reviewing a SKILL.md file
- Implementing load-time gating or keyword scoring
- Debugging skill discovery or injection
Aim for 2–4 entries. More than 4 usually means the doc covers too many topics.
4. The requires_skills field¶
Use requires_skills when the doc is only actionable if specific skills are installed. The
agent can use this to flag missing skills or suggest installing them alongside loading the doc.
requires_skills:
- payment-api # skill slug, not display name
- pdf-processing
Two cases where this applies:
- The doc describes how to use a skill — a "Payment API guide" that walks through using
the
payment-apiskill. Without the skill, the doc is informational only. - The doc references scripts or tools bundled in a skill — loading the doc without the skill means the referenced commands won't work.
Do not use requires_skills for docs that merely mention a skill in passing. Only use it
when the skill's absence makes the doc non-actionable.
5. Complete example¶
---
title: "WebSocket Manager"
summary: "Internal WebSocket session lifecycle, debug flags, and namespace routing."
read_when:
- Debugging WebSocket connection or session issues
- Changing namespace routing or broadcast logic
- Reviewing A0_WS_DEBUG flag behavior
---
With skill dependency:
---
title: "Payment API Guide"
summary: "How to authenticate, call endpoints, and handle errors for the Payment API."
read_when:
- Implementing or debugging payment API calls
- Reviewing payment error handling
requires_skills:
- payment-api
---
6. Authoring checklist¶
- [ ] File is not
README.md,CHANGELOG.md,CONTRIBUTING.md, orARCHIVED.md(those must not have frontmatter) - [ ]
titleis present and matches the H1 heading - [ ]
summaryis one sentence describing scope, not restating the title - [ ]
read_whenentries are specific, actionable conditions (2–4 entries) - [ ] Plan/experiment docs include
status,owner,last_updated - [ ]
requires_skillslists only skills whose absence makes the doc non-actionable - [ ] No
descriptionfield — usesummaryinstead