11# AGENTS.md
22
3- This file defines repository-wide rules only. For any change, read this file first, then read the
4- nearest ` AGENTS.md ` in the subtree you are editing.
3+ This file defines repository-wide rules only. For any change, read this file first, then read each
4+ applicable child ` AGENTS.md ` from outermost to nearest in the subtree you are editing.
55
66## Hierarchy
77
88- The root ` AGENTS.md ` owns stable repo-wide policy.
9- - ` lib/*/AGENTS.md ` , ` packages/**/AGENTS.md ` , and ` implementations/*/AGENTS.md ` own local
10- instructions, commands, and gotchas.
9+ - ` packages/AGENTS.md ` and ` implementations/AGENTS.md ` own shared policy for all packages and
10+ reference implementations.
11+ - ` lib/*/AGENTS.md ` , ` packages/**/AGENTS.md ` , and ` implementations/*/AGENTS.md ` own more specific
12+ local instructions, commands, and gotchas.
1113- If local guidance conflicts with this file, follow the more specific ` AGENTS.md ` for that subtree.
1214- When adding a new workspace package or implementation, add a sibling ` AGENTS.md ` in the same
1315 change.
@@ -106,14 +108,7 @@ Do not hand-edit generated or local-only artifacts unless the task is explicitly
106108 before finishing if the change grew.
107109- For ` implementations/ ` edits, prefer ` pnpm implementation:lint ` after the first meaningful patch
108110 and again before finishing if the change grew.
109- - For a single workspace package, prefer targeted ` typecheck ` , ` test:unit ` , and ` build ` .
110- - For built workspace packages, run the package ` size:check ` script when runtime code, published
111- dependencies, bundler config, exports, or bundle shape changes.
112111- For cross-cutting changes, broaden validation to affected downstream packages or implementations.
113- - For package changes used by implementations, run ` pnpm build:pkgs ` before reinstalling or running
114- implementation tests.
115- - For implementation-only changes, use ` pnpm implementation:lint ` , targeted implementation
116- ` typecheck ` , and targeted E2E as needed.
117112- If you skip a relevant check because of time or environment constraints, say exactly what was not
118113 run and why.
119114
@@ -175,32 +170,66 @@ High-signal repo-wide commands:
175170 - what you already tried
176171 - the smallest next action, user input, or approval needed
177172
178- Common repo-specific failure modes:
179-
180- - An implementation does not reflect a package change: run ` pnpm build:pkgs ` , then rerun the
181- relevant ` pnpm implementation:run -- <implementation> implementation:install ` .
182- - If the goal is E2E setup rather than the narrowest possible refresh step, prefer the combined root
183- wrapper ` pnpm setup:e2e:<implementation> ` . For a full E2E run, prefer
184- ` pnpm test:e2e:<implementation> ` .
185- - Implementation-specific runtime failures such as Docker availability, Playwright browser setup,
186- emulator requirements, ` .env ` drift, PM2 state, and local port conflicts belong in the relevant
187- implementation ` AGENTS.md ` , not here.
188-
189173## Docs, Specs, And CI
190174
191- - When public SDK behavior changes, update the relevant TSDoc or JSDoc and the affected package
192- ` README.md ` in the same change.
193175- Authored supporting docs live in ` documentation/ ` ; generated TypeDoc output lives in ` docs/ ` .
194- - If a package includes a package-local dev harness or other meaningful local dev surface, keep that
195- surface relevant to the current SDK behavior and update it in the same change when the package's
196- developer-facing flows, configuration, or core capabilities change.
197176- If the repository later adds any replacement design, architecture, or specification artifacts for
198177 the changed area, keep them aligned in the same change.
199178- ` docs/ ` is generated by TypeDoc and is gitignored.
200179- Implementation E2E in ` .github/workflows/main-pipeline.yaml ` is intentionally path-filtered. If a
201180 change should alter E2E coverage, update the workflow and keep it aligned with
202181 [ CONTRIBUTING.md] ( ./CONTRIBUTING.md ) .
203182
183+ ## README And Markdown Standards
184+
185+ - Treat README files as maintained source-of-truth orientation for humans. Keep them aligned with
186+ package exports, implementation scripts, local ` .env.example ` files, and authored documentation in
187+ the same change as behavior or workflow updates.
188+ - Preserve the README family already used by the target directory:
189+ - root, published package, and reference implementation READMEs use the centered Contentful logo
190+ header, ` Contentful Personalization & Analytics ` title, subtype ` <h3> ` , navigation links, and
191+ pre-release warning.
192+ - ` documentation/**/README.md ` files are navigation indexes with frontmatter.
193+ - placeholder and internal-only README files may use a plain Markdown ` # ` title plus explicit
194+ status or internal-use admonitions.
195+ - Use title case for Markdown headings, preserving official product, package, API, component, hook,
196+ and file casing.
197+ - Lead with reader intent and scope: what to use, when to use it, and what belongs elsewhere. Prefer
198+ concrete implementation guidance over marketing language.
199+ - Keep terminology consistent: "Optimization SDK Suite", "Personalization", "Analytics", "Experience
200+ API", "Insights API", "reference implementation", and exact package names such as
201+ ` @contentful/optimization-web ` .
202+ - Use fenced code blocks with language tags (` sh ` , ` ts ` , ` tsx ` , ` json ` , ` html ` ) and prefer ` pnpm `
203+ commands. Do not introduce npm, yarn, or undocumented global-tool instructions.
204+ - Use GitHub admonitions intentionally: warning/caution for pre-release, internal, destructive, or
205+ unsafe flows; important for required contracts; note for helpful context that is not required.
206+ - Match README depth to the README category, not to the amount of available detail:
207+ - application-facing package READMEs orient the integrator, preserve common setup options, and
208+ link to authored guides or generated reference docs for deep workflows and exhaustive API
209+ details
210+ - lower-level package READMEs orient SDK maintainers and package authors, explain the layer's
211+ role, and avoid application-integration tutorial depth
212+ - reference implementation READMEs stay procedural and point readers to the code being
213+ demonstrated instead of duplicating package API tutorials
214+ - internal and placeholder READMEs stay short, explicit, and status-oriented
215+ - Move step-by-step implementation material into ` documentation/guides/ ` when an existing guide is
216+ the right home; create a new guide only when no existing guide covers that reader goal. Use
217+ generated TypeDoc reference for exhaustive signatures, method catalogs, callback payload shapes,
218+ and exported type details.
219+ - Before changing README navigation or cross-document links, account for every render target that
220+ consumes that README: GitHub source browsing, TypeDoc project documents, and npmjs package README
221+ rendering for published packages.
222+ - Keep relative links pointed at source-of-truth files in this repository when the README is only
223+ consumed in-repo or by TypeDoc, or when the package README publish rewrite flow is known to
224+ rewrite that link for npm. Use stable absolute URLs for links that must work unchanged across
225+ GitHub, TypeDoc, and npm.
226+ - Link to generated reference docs for API reference and shared README header navigation that needs
227+ to work in all render targets, not as a replacement for source README guidance.
228+ - When a README has a collapsible table of contents, preserve the exact ` <!-- mtoc-start --> ` and
229+ ` <!-- mtoc-end --> ` markers and keep entries synchronized with headings.
230+ - For Markdown edits, run Prettier on touched files when practical and at least run
231+ ` git diff --check ` before finishing.
232+
204233## Safety Rules
205234
206235- Never overwrite or delete ignored local files just to get a clean run.
@@ -211,7 +240,7 @@ Common repo-specific failure modes:
211240## Preferred Workflow
212241
2132421 . Read the root ` AGENTS.md ` .
214- 2 . Read the nearest ` AGENTS.md ` in the subtree you will edit.
243+ 2 . Read each applicable child ` AGENTS.md ` from outermost to nearest in the subtree you will edit.
2152443 . Make the narrowest source-of-truth change in the correct layer.
2162454 . Run the smallest meaningful validation set.
2172465 . Broaden validation only when exports, build tooling, mocks, or shared behavior changed.
0 commit comments