skills/nocobase-plugin-development/SKILL.md
Step-by-step playbook for developing a NocoBase plugin, covering scaffolding, server-side code (collections, APIs, ACL, migrations), client-side code (blocks, fields, actions, settings pages, routes, components), i18n, and verification. TRIGGER when: user asks to create, build, implement, or develop a NocoBase plugin, mentions 'NocoBase plugin', or describes a feature to be built as a NocoBase plugin. This skill contains NocoBase-specific conventions and templates that general coding cannot replicate — always invoke it instead of planning from scratch.
npx skillsauth add nocobase/skills nocobase-plugin-developmentInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Guide an AI agent through the complete process of developing a NocoBase plugin — from requirement analysis to working code — producing a plugin that follows NocoBase conventions and can be enabled immediately.
yarn pm create.nocobase-ui-builder).nocobase-client-v2-plugin-migration).These rules apply to ALL generated plugin code. Violating them is always wrong.
this.app.use() or React Providersthis.app.use() is an internal API. Plugins must NEVER use it to wrap the app with React providers. This is not a suggestion — it is a hard rule with no exceptions.
Providers add unnecessary React rendering layers, hurt performance, and make plugins harder to maintain. When implementing global effects (watermarks, overlays, theming, tracking, global listeners, etc.), use these approaches instead:
registerModelLoaders, registerFlow, registerModels for UI capabilities.this.context holds global data (e.g., this.context.api, this.context.dataSourceManager, this.context.logger). Read from it directly instead of creating Providers to pass data around. Note: some properties like user, viewer, message, themeToken are only available after React renders — use them in flow handlers or components, not in load().this.app.apiClient.request() to fetch it directly. Axios interceptors are allowed but should not be the first choice — prefer direct requests or reading from context when possible.load() for visual effects. No React component needed.this.app.eventBus for reacting to app lifecycle events.If you find yourself thinking "I need a Provider for this", stop and reconsider. There is always a better alternative.
client-v2 ONLYAll client-side plugin code must be written in src/client-v2/. The src/client/ directory is for the legacy v1 client — do NOT write or modify any files there. Import Plugin from @nocobase/client-v2, never from @nocobase/client.
/v2/ URL prefixThe client-v2/ source directory corresponds to the /v2/ runtime URL prefix. After login, users land on /v2/admin/ by default. When telling users where to access something, use the v2 URL pattern:
| What you registered | Accessible at |
|---|---|
| Plugin manager, built-in admin pages | /v2/admin/ |
| Plugin settings pages | /v2/admin/settings/<menuKey> |
| Custom routes via this.router.add('xxx', { path: '/foo' }) | /v2/foo (NOT /v2/admin/foo) |
If the user says "I enabled the plugin but nothing shows up" or hits a 404, the most common cause is they are on a /admin/... URL (v1 plugin manager, which calls pm:listEnabled) instead of /v2/admin/ (v2 plugin manager, which calls pm:listEnabledV2). Tell them to switch to the /v2/ URL.
| Input | Required | Default | Validation | Clarification Question |
|---|---|---|---|---|
| requirement | yes | none | non-empty natural language description | "What should this plugin do?" |
| nocobase_root | yes | current working directory | must contain package.json with @nocobase/server | "Where is your NocoBase project root directory?" |
| plugin_name | no | derived from requirement | @<scope>/plugin-<name> format | "What should the plugin package name be?" |
Rules:
nocobase_root is not provided, check if the current working directory is a NocoBase project.plugin_name is not provided, derive a reasonable name from the requirement and confirm with the user.23nocobase_root is a valid NocoBase project with yarn available.requirement is clear enough to determine which extension points are needed.CRITICAL: You MUST always confirm the plan with the user before writing any code or running any scaffold command — even if the requirement seems perfectly clear. Users often have unstated assumptions, edge cases they haven't considered, or preferences about scope. The plan confirmation step (Step 2) is a hard gate, not a suggestion. Never skip it.
nocobase_root contains a valid NocoBase project (package.json with @nocobase/server).yarn is available.packages/core/ exists → AI can read source code for troubleshooting.packages/core/ → rely on documentation and online references only.Analyze the user's requirement and determine which extension points are needed:
Do NOT ask the user about technical details (e.g., "Do you need a BlockModel or TableBlockModel?"). Map requirements to extension points internally.
This step is mandatory and must not be skipped, regardless of how clear the requirement appears. Even seemingly straightforward requirements can have unstated edge cases, scope preferences, or assumptions the user hasn't mentioned. Always present the plan and wait for explicit confirmation before proceeding to Step 3.
Present a functional plan in plain language the user can understand. Proactively highlight decisions the user may not have considered (e.g., "Should the data persist after plugin disable?", "Do you need a settings page for configuration?"). Example:
"Here's my plan:
- Create a settings page where you can configure the API key
- Add a scheduled task that syncs data every 5 minutes
- Create a data table to store the synced records
- The table will be available as a block in the UI
A few things to confirm:
- Should the synced data be cleared when the plugin is disabled?
- Do you need permission control for who can access the settings?
Does this look right?"
Do NOT run yarn pm create or write any code until the user explicitly confirms.
The exact command is:
yarn pm create <plugin_name>
# Example: yarn pm create @nocobase-sample/plugin-hello
# Creates: packages/plugins/@nocobase-sample/plugin-hello/
This is the only correct command. Do NOT use create-plugin, generate, or any other variant. Do NOT look up alternatives — just run it.
Read references/getting-started.md for the expected project structure.
You MUST read the relevant reference files BEFORE writing any code. Do NOT skip this by searching source code, reading examples, or relying on prior knowledge. The references contain project-specific conventions that override general knowledge.
Read references/index.md to locate the relevant reference files, then read the ones needed for this plugin.
These are hard gates, not suggestions. Read the file BEFORE editing the corresponding code:
| When you edit... | You MUST first read |
|---|---|
| src/client-v2/plugin.tsx | references/client/plugin.md |
| src/server/plugin.ts | references/server/plugin.md |
| Any file in src/client-v2/models/ | references/client/block.md, references/client/field.md, or references/client/action.md (whichever applies) |
| Any file in src/server/collections/ | references/server/collection.md |
If your implementation involves any of these concepts, you MUST also read the corresponding reference:
| Keywords in your code | MUST read |
|---|---|
| route, router, navigate, location, pathname | references/client/router.md and references/client/ctx.md |
| ctx.api, ctx.viewer, ctx.message, ctx.model | references/client/ctx.md |
| registerFlow, uiSchema, on: event handlers | references/client/flow.md |
| resource, MultiRecordResource, SingleRecordResource | references/client/resource.md |
| tExpr, useT, this.t | references/client/i18n.md |
| acl.allow, permissions | references/server/acl.md |
| defineCollection, fields, relations | references/server/collection.md |
Flexible — adapt to the plugin's needs:
Checkpoint before writing client code: Review the "Hard Constraints" section. Never use this.app.use() or Providers. Use FlowEngine, context, pure DOM, or EventBus instead.
Default behavior (do NOT ask):
src/locale/zh-CN.json and src/locale/en-US.json.locale.ts for tExpr and useT imports.Only ask about additional languages if:
yarn pm enable <plugin_name>
After enabling, describe what the user should see in the UI and how to test the plugin. When quoting URLs to the user, always use the /v2/ prefix (e.g., /v2/admin/, /v2/admin/settings/<menuKey>, /v2/<custom-path>) — see the "v2 mode runs under the /v2/ URL prefix" rule under Hard Constraints.
These defaults apply unless the user explicitly requests otherwise. Do NOT ask about them.
| Decision | Default | When to ask |
|---|---|---|
| Client version | client-v2 ONLY. All client code in src/client-v2/. Never use src/client/ or import from @nocobase/client | Never |
| Model registration | registerModelLoaders (lazy loading) | Never |
| Route registration | componentLoader (lazy loading) | Never |
| Settings page registration | pluginSettingsManager.addMenuItem() + addPageTabItem() with componentLoader | Never |
| ACL | acl.allow('*', '*', 'loggedIn') | User mentions fine-grained permissions |
| Locale files | zh-CN.json + en-US.json | User mentions other languages |
| addCollection (client-side) | Do NOT add — recommend UI "Data Source Management" instead | Only as a demo; if needed, use eventBus pattern (NOT direct call in load()) |
| install() seed data | Do NOT add | User mentions preset/demo data |
| tExpr import | From plugin's locale.ts, NOT from @nocobase/flow-engine directly | Never |
| this.app.use() (Provider) | Do NOT use — use FlowEngine mechanisms or pure DOM instead. See client/plugin.md | Never |
When the plugin doesn't work as expected:
/v2/admin/, not /admin/... — only the v2 plugin manager fetches via pm:listEnabledV2 and shows v2 plugins; (b) plugin has been enabled with yarn pm enable <name>; (c) package.json has correct NocoBase metadata.addCollection with filterTargetKey: 'id' and eventBus pattern. See client/plugin.md.componentLoader (not Component) for client-v2.define({ label: tExpr('...') }) and registerModelLoaders in plugin load().load() database query fails → load() runs before DB sync. Move DB operations to install() or request handlers.tExpr is imported from locale.ts not @nocobase/flow-engine.on event name. Use 'click' for buttons, 'beforeRender' for initialization.If the environment is a source install, the AI agent may read NocoBase core source code to debug issues:
packages/core/server/src/ — Server core
packages/core/client/src/ — Client core (v1, reference only)
packages/core/client-v2/src/ — Client core (v2, recommended)
packages/core/database/src/ — Database layer
packages/core/flow-engine/src/ — FlowEngine
When a full working example is needed:
packages/plugins/@nocobase-example/ for working example plugins.| Reference | Use When | Notes | |---|---|---| | references/index.md | Always, after Step 1 | Global index — read this to find relevant module references | | references/getting-started.md | Step 3 (scaffolding) | Plugin scaffold + project structure | | references/server/*.md | Plugin needs server-side code | One file per server module | | references/client/*.md | Plugin needs client-side code | One file per client module | | references/build.md | User asks about building/packaging | Build and distribution |
High-impact actions:
yarn pm create (creates files in user's project)yarn pm enable (modifies database state)Secondary confirmation template:
{{command}} in {{directory}}. This will {{impact}}. Should I proceed?"Rollback guidance:
yarn pm create produced wrong scaffold → delete the generated directory and re-run.yarn pm disable <name>.yarn nocobase install -f without explicit user confirmation — it resets the database.yarn is available.this.app.use() or React Provider patterns in generated code (Hard Constraint).zh-CN.json and en-US.json are generated with all translatable strings.yarn pm enable without errors.Final response must include:
tools
Use when a NocoBase task requires AI employee lifecycle work such as discovering existing employees, judging fit, creating a dedicated employee, or configuring profile, prompt, model, skills, tools, or knowledge base before another skill binds it to a UI surface.
tools
Use when users need to inspect, create, revise, enable, or diagnose NocoBase workflows through the `nb` CLI, including trigger selection, node-chain changes, version safety checks, and execution troubleshooting.
tools
DEFAULT entry point for NocoBase Modern UI authoring or tweaks: new pages, blocks, menu items, and localized edits to blocks, fields, actions, layouts, or reactions on an already-running app via backend flow-surfaces through nb api. Also handles AI employee / AI assistant action placement on UI surfaces. Hand off employee lifecycle work such as discovering, judging, creating, or configuring profile, prompt, model, skills, tools, or knowledge base to nocobase-ai-employee, then return for the UI write. Only hand off to nocobase-dsl-reconciler when the user explicitly asks for DSL, YAML, git, or cli push workflow. Does not handle ACL, data modeling, workflow orchestration, browser reproduction, page error postmortems, or non-Modern page navigation.
data-ai
Create and manage NocoBase data models through the available data-modeling surface. Use when users want to inspect or change collections, fields, relations, or view-backed schemas in a NocoBase app.