agentleFS
portabletextportabletext/editor/AGENTS.md

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…

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
  1. Very specific:

    Before pushing, run the root checks CI runs: pnpm check:format, pnpm check:lint, pnpm check:types, pnpm check:knip, and the affected …

    line 11
  2. Very specific:

    Before creating a test file, look for the existing home: most contracts already have a canonical suite (for example …

    line 23
  3. Very specific:

    Use the package's existing harnesses and deterministic fixtures: keys come from createTestKeyGenerator, never hardcoded strings.

    line 26
  4. Very specific:

    Never wait with sleeps or fixed timeouts.

    line 29
  5. Distinctive:

    Use backticks around code identifiers in comments, commit messages, and docs.

    line 48
  6. Distinctive:

    Use full, easily understood variable names.

    line 50
  7. Distinctive:

    Place helper functions below the main functions they serve.

    line 52
  8. Very specific:

    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, …

    line 53
  9. Very specific:

    Use Node 24 (the nvm default).

    line 72
  10. Very specific:

    Only Chromium is installed, so test:browser:firefox / :webkit need their browsers added first (pnpm exec playwright install firefox webkit).

    line 81

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

AGENTS.md

Guidance for coding agents working on the Portable Text Editor monorepo.

Working in the 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 checks flag.

Tests

  • The file extension picks the runner: .test.tsx runs in the browser project, .test.ts in 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's tests/ directory.
  • Before creating a test file, look for the existing home: most contracts already have a canonical suite (for example tests/behavior-api.test.tsx for Behavior API contracts in packages/editor).
  • Use the package's existing harnesses and deterministic fixtures: keys come from createTestKeyGenerator, never hardcoded strings; example content is foo/bar/baz.
  • Never wait with sleeps or fixed timeouts. Anchor every wait on something observable: vi.waitFor around 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 if statement 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/utils and src/paths in packages/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 node on PATH (/exec-daemon/node) is v22.14, whose V8 predates duplicate named capture groups; under it @portabletext/plugin-character-pair-decorator's regex.character-pair unit suite throws Duplicate capture group name and pnpm test:unit fails. Interactive shells source ~/.bashrc → nvm and pick up the Node 24 default automatically; if a command lands on v22.14, run nvm use 24 first. CI runs the suite on lts/* (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, so test:browser:firefox / :webkit need their browsers added first (pnpm exec playwright install firefox webkit).
  • The runnable demo app is playground: pnpm dev:playground serves it at http://localhost:5173/ (Vite). apps/docs (pnpm dev:docs) and examples/basic (pnpm dev:example-basic) are the other runnable targets; there is no backend, database, or env/secret to configure.
  • pnpm install prints an "Ignored build scripts: esbuild" warning. It is benign here — builds, Vite, and tests all work without approving it.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.