editor
AGENTS.md285 starsChanged 14 days agoMITView on GitHub
Guidance for coding agents working on the Portable Text Editor monorepo. - Packages live in packages/*, apps in apps/*. Run a package's scripts with pnpm --filter @portabletext/editor <script> from the root. - A fresh checkout needs pnpm install, then pnpm --filter '<package>...' build before that package's tests pass. - Before pushing, run the root checks CI runs: pnpm check:format, pnpm check:lint, pnpm check:types, pnpm check:knip, and the affected package's tests (test:unit, test:browser:chromium). pnpm format and pnpm lint:fix fix what their…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,700 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository11 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- backportingSkill
- changesetsSkill
- code-commentsSkill
- commitsSkill
- next-branchSkill
- pr-descriptionsSkill
- reviewing-prsSkill
- writing-testsSkill
- product-copy-assistantSkill
- portable-text-editorSkill
The file
We split this AGENTS.md into the rules it gives an agent
10 rules. About 0 are common, 3 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 11
Before pushing, run the root checks CI runs: pnpm check:format, pnpm check:lint, pnpm check:types, pnpm check:knip, and the affected …
- Very specific: line 23
Before creating a test file, look for the existing home: most contracts already have a canonical suite (for example …
- Very specific: line 26
Use the package's existing harnesses and deterministic fixtures: keys come from createTestKeyGenerator, never hardcoded strings.
- Very specific: line 29
Never wait with sleeps or fixed timeouts.
- Distinctive: line 48
Use backticks around code identifiers in comments, commit messages, and docs.
- Distinctive: line 50
Use full, easily understood variable names.
- Distinctive: line 52
Place helper functions below the main functions they serve.
- Very specific: line 53
Before writing a walk, a node guard, a path or key helper or a plain util, look for the existing one: src/traversal, src/selectors, …
- Very specific: line 72
Use Node 24 (the nvm default).
- Very specific: line 81
Only Chromium is installed, so test:browser:firefox / :webkit need their browsers added first (pnpm exec playwright install firefox webkit).
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
Guidance for coding agents working on the Portable Text Editor monorepo.
Working in the monorepo
- Packages live in
packages/*, apps inapps/*. Run a package's scripts withpnpm --filter @portabletext/editor <script>from the root. - A fresh checkout needs
pnpm install, thenpnpm --filter '<package>...' buildbefore that package's tests pass. - Before pushing, run the root checks CI runs:
pnpm check:format,pnpm check:lint,pnpm check:types,pnpm check:knip, and the affected package's tests (test:unit,test:browser:chromium).pnpm formatandpnpm lint:fixfix what their checks flag.
Tests
- The file extension picks the runner:
.test.tsxruns in the browser project,.test.tsin the unit project. Never encode the runner in a suffix like.browser.test.tsx. - Unit tests sit next to the source file they cover in
src/; browser tests live in the package'stests/directory. - Before creating a test file, look for the existing home: most contracts
already have a canonical suite (for example
tests/behavior-api.test.tsxfor Behavior API contracts inpackages/editor). - Use the package's existing harnesses and deterministic fixtures: keys come
from
createTestKeyGenerator, never hardcoded strings; example content isfoo/bar/baz. - Never wait with sleeps or fixed timeouts. Anchor every wait on something
observable:
vi.waitForaround a real assertion. - Assert full values with
toEqual, not fragments or partial matchers, and assert inline: no helper indirection that hides the expected value. - A test that pins a fix must fail on the pre-fix code; run it against the old behavior to prove it.
Comments
- The default is no comment. A comment earns its place only by telling the reader something the code and tests cannot: a browser quirk, a spec constraint, an invariant the code relies on but does not check.
- Comments explain why, never what, and never argue with code that is no longer there: a comment contrasting the current code with a deleted version belongs in the commit message.
- Comments for an
ifstatement go inside it, not above it.
Code style
- Use backticks around code identifiers in comments, commit messages, and docs.
- Use full, easily understood variable names; never one-character names.
- Type casting is a last resort.
- Place helper functions below the main functions they serve.
- Before writing a walk, a node guard, a path or key helper or a plain
util, look for the existing one:
src/traversal,src/selectors,src/utilsandsrc/pathsinpackages/editor, and the exports of@portabletext/schema(getSubSchema,isTypedObject,isSpan,isTextBlock). A deliberate copy in another package carries a keep-in-sync pointer to its source. - Conditional rendering in JSX uses a ternary with an explicit
: null, never&&.
Commits and PRs
- Conventional commit subjects, lowercase, imperative, naming the
actual mechanism, never the vague intent ("fix: selection bug"):
fix: only rewrite the DOM selection when it disagrees with the model. - User-facing changes ship a changeset (
.changeset/*.md); tests, tooling, and internal refactors do not.
Cursor Cloud specific instructions
- Use Node 24 (the nvm default). The VM's baseline
nodeonPATH(/exec-daemon/node) is v22.14, whose V8 predates duplicate named capture groups; under it@portabletext/plugin-character-pair-decorator'sregex.character-pairunit suite throwsDuplicate capture group nameandpnpm test:unitfails. Interactive shells source~/.bashrc→ nvm and pick up the Node 24 default automatically; if a command lands on v22.14, runnvm use 24first. CI runs the suite onlts/*(Node 24). - Browser tests (
.test.tsx, e.g.pnpm test:browser:chromium) need the Playwright Chromium browser; it is provisioned by the startup update script. Only Chromium is installed, sotest:browser:firefox/:webkitneed their browsers added first (pnpm exec playwright install firefox webkit). - The runnable demo app is
playground:pnpm dev:playgroundserves it athttp://localhost:5173/(Vite).apps/docs(pnpm dev:docs) andexamples/basic(pnpm dev:example-basic) are the other runnable targets; there is no backend, database, or env/secret to configure. pnpm installprints an "Ignored build scripts: esbuild" warning. It is benign here — builds, Vite, and tests all work without approving it.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

