lobe-editor
AGENTS.md180 starsChanged 12 days agoMITView on GitHub
Guidance for AI agents working in this repository. Downstream users of the package should read <https://editor.lobehub.com/skills.md> and <https://editor.lobehub.com/llms.txt> instead. @lobehub/editor is a Lexical-based rich text editor for React: a framework-agnostic kernel, 20+ plugins, React components (Editor, ChatInput, ...), a headless entry and a read-only renderer. The docs site (<https://editor.lobehub.com>) is built with @lobehub/docs-kit (lobedocs) from the index.mdx files next to the source. Skills live in .agents/skills/<name>/SKILL.md. Read the whole SKILL.md (and any reference/ files it links) before starting a task…
We split this AGENTS.md into the rules it gives an agent
5 rules. About 0 are common, 0 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 50
Follow .agents/skills/using-docs-kit/SKILL.md.
- Very specific: line 60
Demos: put them in <folder>/demos/ (index.tsx for the basic one), one export default component each, importing the library by package name …
- Very specific: line 66
Structure: start at ## (the title is the H1).
- Very specific: line 81
Use an existing plugin as the template: hr (small decorator node), collapsible (element node with commands, Markdown and LiteXML), toc …
- Very specific: line 149
Imports: use the @/ alias for src/ inside the library.
≈ “Common” is an estimate: at least 1 in 5 of the 36,368 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 AI agents working in this repository. Downstream users of the package should read https://editor.lobehub.com/skills.md and https://editor.lobehub.com/llms.txt instead.
Overview
@lobehub/editor is a Lexical-based rich text editor for React: a framework-agnostic kernel,
20+ plugins, React components (Editor, ChatInput, ...), a headless entry and a read-only
renderer. The docs site (https://editor.lobehub.com) is built with @lobehub/docs-kit
(lobedocs) from the index.mdx files next to the source.
Key paths:
| Path | What lives there |
src/editor-kernel/ | Kernel (kernel.ts), KernelPlugin base class (plugin.ts), DataSource, React glue |
src/plugins/<name>/ | One folder per plugin (kernel plugin + optional React plugin + docs + demos) |
src/react/<Component>/ | High-level React components (Editor, ChatInput, SendButton, ...) |
src/renderer/ | LexicalRenderer / LexicalDiff and per-node renderers (renderers/) |
src/headless/ | createHeadlessEditor and its default plugin list |
src/codemirror/ | CodeMirror loader and code-block UI (@lobehub/editor/codemirror) |
src/locale/index.ts | Default English strings; ILocaleKeys is inferred from it (src/types/locale.ts) |
src/types/ | Public kernel / plugin interfaces (kernel.ts), hotkeys, locale types |
src/index.ts | Main entry; every plugin must be re-exported here |
docs/, docs.config.ts | Docs home (docs/index.tsx), guide pages, site config |
tests/ | Cross-cutting integration tests |
.agents/skills/ | Agent skills for this repo (see below) |
.cursor/rules/ | Cursor rules with more detail on structure, plugins, React, hotkeys, logging and docs |
Using Skills
Skills live in .agents/skills/<name>/SKILL.md. Read the whole SKILL.md (and any
reference/ files it links) before starting a task that matches it, then follow it.
| Skill | Use it when |
using-docs-kit | Writing or editing any docs page (index.mdx), demos, docs.config.ts, or fixing a lobedocs build failure. See reference/config.md and reference/validations.md. |
building-landing-home | Changing the docs home page (docs/index.tsx) built from @lobehub/ui/awesome landing components. |
Notes:
- These skills are for maintainers.
skills.mdandllms.txton the docs site are generated bylobedocs buildfor downstream users; do not edit them by hand. - Each
SKILL.mdstarts with YAML frontmatter (name,description), so skill CLIs can discover them; check withnpx skills add ./ --listfrom the repo root.
Writing Docs
Follow .agents/skills/using-docs-kit/SKILL.md. Repo specifics:
- Location: one
index.mdxper documented folder.docs.config.tssetsatomDirstosrc/react,src/pluginsandsrc/renderer, sosrc/plugins/hr/index.mdxbecomes/components/plugins/hrandsrc/react/SendButton/index.mdxbecomes/components/react/send-button. Only files namedindex.mdxare picked up (index.mdis ignored). - Frontmatter:
title,description(one or two plain sentences; it feeds search, SEO andllms.txt) andcategory. Reuse existing categories:Core,Plugins(plugins);General,Data Entry,Layout,Playground,Providers(React);Renderer. Do not add dumi fields (nav,group,atomId). - Demos: put them in
<folder>/demos/(index.tsxfor the basic one), oneexport defaultcomponent each, importing the library by package name (@lobehub/editor,@lobehub/editor/react);docs.config.tsaliases it tosrc. Reference them withimport DemoIndex from './demos/index.tsx?demo';and<Demo of={DemoIndex} />. Useeditable={false}for editor playgrounds,layout="bare"for full-width ones,isolatedfor demos that use portals or global CSS. - Structure: start at
##(the title is the H1); typical sections are## Introduction,## Basic Usage, then features, then## APIswith property tables (| Property | Description | Type | Default |). This repo writes API tables by hand; keep them in sync with the TypeScript types. - Preview:
pnpm dev(alias oflobedocs dev; restart it after editingdocs.config.ts).pnpm docs:buildruns every docs validation (frontmatter, demo references, broken links). - Do not hand-edit
compatibility.json(legacy URL inventory) unless you move or rename an existing page; the build checks that every legacy URL is still produced. - Changes that affect users also go in
README.mdonly if they change installation or the quick-start example; the README links to the docs site for everything else.
Adding a New Plugin / Component
Plugin (src/plugins/<name>/)
Use an existing plugin as the template: hr (small decorator node), collapsible (element node
with commands, Markdown and LiteXML), toc (service + hooks, no node).
- Node —
node/<Name>Node.ts: the custom Lexical node and$create…/$is…helpers. - Commands —
command/index.ts:createCommand<Payload>('INSERT_…_COMMAND')plus aregister…Command(editor)function returning a cleanup. - Kernel plugin —
plugin/index.ts:export const <Name>Plugin: IEditorPluginConstructor<Options> = class extends KernelPlugin implements IEditorPlugin<Options>with a uniquestatic pluginName. In the constructor callkernel.registerNodes([...]),kernel.registerThemes({...})and, for decorator nodes,this.registerDecorator(...). InonInit(editor)wrap registrations inthis.register(...). - Markdown — in
onInit,this.kernel.requireService(IMarkdownShortCutService)thenregisterMarkdownShortCut/registerMarkdownWriter/registerMarkdownReader(seesrc/plugins/hr/plugin/index.ts,src/plugins/collapsible/plugin/index.ts). - LiteXML —
this.kernel.requireService(ILitexmlService)thenregisterXMLWriter(nodeType, …)andregisterXMLReader(tagName, …), so AI edits and the headless export round-trip the node. - React plugin —
react/React<Name>Plugin.tsx,react/type.ts(props with JSDoc),react/style.ts(createStaticStylesfrom@lobehub/ui),react/index.ts(x)exportingReact<Name>Pluginandexport type * from './type'. - Services (optional) —
service/with agenServiceIdtoken, registered viakernel.registerService(seesrc/plugins/toc/service/i-toc-service.ts). - Strings — add user-facing text to
src/locale/index.ts; read it withuseTranslation()from@/editor-kernel/react/useTranslationin React code, orkernel.t(...)in the kernel plugin. - Logging —
createDebugLogger('plugin', '<name>')from@/utils/debug; no bareconsole.log. - Barrel —
src/plugins/<name>/index.tsexports the commands, plugin and React plugin. - Entries — add
export * from './plugins/<name>';tosrc/index.ts. If the node must survive server-side processing, add the kernel plugin toDEFAULT_HEADLESS_EDITOR_PLUGINSinsrc/headless/index.ts. If saved content should render read-only, add the node class tosrc/renderer/nodes/index.tsand a renderer insrc/renderer/renderers/, registered increateDefaultRenderers()(src/renderer/renderers/index.ts). - Demo & docs —
demos/index.tsx+index.mdx(see Writing Docs). Also wire the plugin into the playgroundsrc/react/Editor/demos/index.tsxwhen it is user-visible. - Tests — Vitest + jsdom, colocated in
__tests__/(*.test.ts(x)), e.g.src/plugins/toc/__tests__/. Cover commands, Markdown and LiteXML round-trips; headless behaviour goes insrc/headless/__tests__/.
React component (src/react/<Component>/)
Mirror src/react/SendButton/: <Component>.tsx, type.ts (props with JSDoc), style.ts,
index.ts (export { default } from './<Component>'; export * from './type';),
demos/index.tsx, index.mdx, and __tests__/ when there is logic. Export it from
src/react/index.ts (export { default as <Component>, type <Component>Props } from './<Component>';).
New public entry (rare)
A new subpath needs both an exports entry in package.json and an entry in
tsdown.config.ts (the browser build lists index, react, renderer, codemirror; the
node build lists headless and shared chunks). Run pnpm build to confirm the output.
Before you finish
pnpm type-check
pnpm lint # ESLint --fix on src and tests
pnpm lint:circular # dpdm, fails on circular imports
pnpm vitest run # or scope it: pnpm vitest run src/plugins/<name>
pnpm docs:build # when you touched docs or demosConventions & Checks
- Package manager: pnpm (
packageManager: pnpm@10.20.0). There is no lockfile (.npmrcsetslockfile=false); do not add one. If type-check fails on missing exports from@lobehub/uietc., yournode_modulesis stale: runpnpm install. - Scripts (
package.json):dev/docs:dev,docs:build,build,test,test:coverage,lint,lint:style,lint:md,lint:circular,type-check,ci(lint:circular + lint + type-check),prettier,demo:yjs-server,verify:node-identity-package. - Imports: use the
@/alias forsrc/inside the library; demos import from@lobehub/editor. - Commits: gitmoji + Conventional Commits, lowercase scope, e.g.
✨ feat(table): add column resize,🐛 fix: …,📝 docs: …(checked by commitlint via@lobehub/lint). - Hooks:
.husky/pre-commitrunstype-check(skipped whenCI=true),lint:circularandlint-staged(Prettier, ESLint, Stylelint, remark on staged files). Never bypass hooks with--no-verify; fix the failure instead. - Release: semantic-release (
release.config.js,.github/workflows/release.yml) publishes frommaster; do not bumpversionor editCHANGELOG.mdby hand. .cursor/rules/expand on this file (project structure, plugin and React patterns, hotkeys, debug logging, docs). Keep them in sync: when you change a convention here, update the matching rule too.
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 28,693 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 repository10 other files it gives its agents.
- .cursor/rules/coding-standards.mdcCursor rule
- .cursor/rules/debug-logging.mdcCursor rule
- .cursor/rules/documentation-standards.mdcCursor rule
- .cursor/rules/environment-setup.mdcCursor rule
- .cursor/rules/hotkey-standards.mdcCursor rule
- .cursor/rules/plugin-development.mdcCursor rule
- .cursor/rules/project-structure.mdcCursor rule
- .cursor/rules/react-development.mdcCursor rule
- building-landing-homeSkill
- using-docs-kitSkill
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.

