agentleFS
gravity-uigravity-ui/markdown-editor/AGENTS.md

markdown-editor

AGENTS.md428 starsChanged 2 years agoMITView on GitHub

Where this file says nothing, copy the closest existing example in the repository: folder structure, file names, names of variables, functions, types and constants, class structure, React components and hooks, styles and CSS class names, i18n keys, exports, tests, demo stories. Add a new kind of file only if the repository already has one like it. Always run visual (Playwright) tests in Docker. Never run them locally. Their setup, commands and screenshot rules are in demo/AGENTS.md; read it before writing…

  • 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 33,315 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 repository3 other files it gives its agents.

The file

We split this AGENTS.md into the rules it gives an agent

8 rules. About 0 are common, 4 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Test names (it, test, and parameterized cases) must start with should , followed by a base-form verb.

    line 13
  2. Very specific:

    Check source API contracts with the package's typecheck command.

    line 18
  3. Distinctive:

    Use explicit type assignments to check result types, methods, and overloads.

    line 19
  4. Very specific:

    Use @ts-expect-error for inputs or assignments that must be rejected.

    line 20
  5. Distinctive:

    Keep each contract check in a small function or type alias.

    line 21
  6. Distinctive:

    Never format code by hand, and never reformat lines you did not change.

    line 33
  7. Distinctive:

    Read git status after a fix run and commit only the files your change belongs to.

    line 34
  8. Very specific:

    Write code the way the linter wants it from the start: T[] instead of Array<T>, object shorthand ({foo} instead of {foo: foo}), inline type …

    line 36

≈ “Common” is an estimate: at least 1 in 5 of the 42,283 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 — gravity-ui/markdown-editor

Following existing code

Where this file says nothing, copy the closest existing example in the repository: folder structure, file names, names of variables, functions, types and constants, class structure, React components and hooks, styles and CSS class names, i18n keys, exports, tests, demo stories. Add a new kind of file only if the repository already has one like it.

Testing

Always run visual (Playwright) tests in Docker. Never run them locally. Their setup, commands and screenshot rules are in demo/AGENTS.md; read it before writing or running a visual test.

Unit tests use Vitest and run with pnpm test from the root. Import describe, it, expect, hooks, and vi explicitly from vitest; globals are disabled.

Test names (it, test, and parameterized cases) must start with should , followed by a base-form verb.

Type contract tests follow the same rules in every package:

  • Store them in the package's tests/types/ directory as *.types.ts.
  • Check source API contracts with the package's typecheck command. Contracts that import the built package may use a separate TypeScript configuration and command, run after a fresh build as part of package tests and CI. This does not require a build in typecheck.
  • Use explicit type assignments to check result types, methods, and overloads.
  • Use @ts-expect-error for inputs or assignments that must be rejected. The check must fail if the expected error disappears.
  • Keep each contract check in a small function or type alias. These files are checked without execution; runtime behavior belongs in Vitest tests.

Code style

Prettier owns formatting, ESLint and Stylelint own the rest. One command applies the fixes of all three:

pnpm fix:lint

It covers *.{js,jsx,mjs,ts,tsx,css,scss} across the whole repository. Its output lists every file Prettier went through along with the problems that need a human. pnpm lint reports the problems alone, without touching files, and is what CI runs on every pull request.

  • Never format code by hand, and never reformat lines you did not change.
  • Read git status after a fix run and commit only the files your change belongs to.
  • An eslint-disable comment that no longer suppresses anything is an error. Remove it instead of keeping it for safety.
  • Write code the way the linter wants it from the start: T[] instead of Array<T>, object shorthand ({foo} instead of {foo: foo}), inline type imports (import {type Foo} from './foo').
  • Where the linter is silent, follow the file you are editing.
  • Shared rules live in infra/linters/; per-package overrides are in the root eslint.config.mjs.

Extensions

An extension Block in packages/editor/src/extensions/ has this layout:

Block/
  BlockSpecs/
    index.ts
    const.ts
    BlockSpecs.ts
  BlockNodeView/
    components/
      <React components>
    index.ts
    BlockNodeView.ts
  plugins/
    BlockPlugin/
      index.ts
      plugin.ts
  Block.ts
  index.ts
  • Block.ts holds the extension; every index.ts only re-exports.
  • BlockSpecs/ holds the schema, the parser and the serializer; const.ts holds node and attribute names.
  • A NodeView is a class in BlockNodeView/; its React components live in components/.
  • Class names come from cn; element state is a modifier.
  • A markdown-it plugin emits one token stream; extra data goes to token.meta.
  • A markdown-it plugin only parses. The serializer lives in the extension and writes through state.

Package naming

Published @gravity-ui/* packages live directly in packages/. The npm name starts with the target (editor, viewer or plugin), and the entity name comes before its kind:

Packagenpm nameDirectory
Editor extension@gravity-ui/markdown-editor-<name>-extensionpackages/editor-<name>-extension
Viewer extension@gravity-ui/markdown-viewer-<name>-extensionpackages/viewer-<name>-extension
markdown-it plugin@gravity-ui/markdown-plugin-<name>packages/plugin-<name>
  • The directory name is the npm name without the @gravity-ui/markdown- prefix.
  • Examples: packages/editor-header-extension and packages/plugin-header.

Package structure

New editor packages split code by mode:

src/
  wysiwyg/
    extensions/
      <Extension>/
  markup/
    commands/
      <command>.ts
  toolbar/
    view/
      items.ts
    wysiwyg/
      items.ts
      presets.ts   # optional
    markup/
      items.ts
      presets.ts   # optional
    items.ts       # both modes
    presets.ts     # both modes, optional

Exports in package.json:

ExportContents
.Toolbars, WYSIWYG and markup entities
./wysiwygWYSIWYG entities only: extensions, toolbar items without markup
./wysiwyg/specsWYSIWYG specs only: spec extensions, constants
./wysiwyg/utilsWYSIWYG utils, optional
./markupMarkup entities only: CodeMirror commands and extensions, toolbar items without wysiwyg
./markup/utilsMarkup utils, optional
./wysiwyg/coreWYSIWYG core, root editor package only
./pm/*, ./cm/*ProseMirror and CodeMirror re-exports, root editor package only

Documentation

Project docs live in docs/. Read the relevant file before working on the corresponding area:

When you're working on…Read
Visual / Playwright testsdocs/how-to-add-visual-test.md
Creating a new extensiondocs/how-to-create-extension.md
Core exportersdocs/core-exporters.md
Adding Markdown text bindingsdocs/how-to-add-text-binding-extension-in-markdown.md
Customizing toolbarsdocs/how-to-customize-toolbars.md
Customizing the editordocs/how-to-customize-the-editor.md
Adding previewdocs/how-to-add-preview.md
GPT / AI extensionsdocs/how-to-connect-gpt-extensions.md
Contributing guidelinesdocs/guidelines-contributions.md

Stack

  • TypeScript, React 18
  • CodeMirror 6, ProseMirror
  • Vitest (unit), Playwright (visual/e2e)
  • pnpm + nx monorepo
  • Podman / Docker for containerized test runs

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.