.agents/skills/plate-plugin-creator/rules/typing.md
Default to:
createSlatePlugincreatePlatePluginStep up to:
createTSlatePlugincreateTPlatePluginonly when you need explicit PluginConfig control for exported options, API,
transforms, or selectors.
Plugin callbacks already receive rich context. Prefer:
editorplugintypeapitfgetOptionssetOptionsetOptionsDo not teach people to pass SlateEditor through callback signatures, helper
inputs, or public option callbacks when this context is already present.
For shipped/shared plugin surfaces, prefer KEYS from
packages/utils/src/lib/plate-keys.ts:
key: KEYS.blockSelection
targetPlugins: [KEYS.p]
editor.getType(KEYS.codeBlock)
This is the default for real package/plugin code because:
Use raw literals only when the plugin is tiny and truly local, or when you are in a test fixture that is intentionally not modeling the shared contract.
These are usually noise, not help:
extendTransforms(({ editor }: { editor: SlateEditor }) => ...)
targetPluginToInject: ({ editor }: { editor: SlateEditor }) => ...
If inference fails, prefer fixing the plugin config shape with createT* or a
real exported PluginConfig alias before spraying manual editor annotations.
extendApi / extendTransforms
Use when the surface semantically belongs to that plugin.extendEditorApi / extendEditorTransforms
Use when you intentionally want merged editor convenience.The distinction is real. Do not blur it because one version is shorter to type.
Use explicit plugin config aliases when the plugin exports a meaningful contract that callers should understand and TypeScript should preserve.
Good fits:
BaseCommentConfigCodeBlockConfigCopilotPluginConfigAlso keep literal option types stable when they matter:
options: {
trigger: '@' as const,
}
When files disagree, trust them in this order:
packages/core/src/lib/plugin/*packages/core/src/react/plugin/*packages/core/type-tests/*