skills/nocobase-data-modeling/SKILL.md
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.
npx skillsauth add nocobase/skills nocobase-data-modelingInstall 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.
Use the available NocoBase data-modeling surface to inspect and change collections, fields, relations, and view-backed schemas.
Prefer the transport in this order:
nb api data-modeling CLI whenever it is availableDo not make the skill depend on one executable name. Treat CLI command names and equivalent wrappers as transport details around the same modeling operations.
Transport-selection rule:
nb api data-modeling CLI is available in the current environment.Read references/decision-matrix.md first when the request is broad or the correct modeling path is unclear.
nb api data-modeling CLI is available, that should be the chosen transport.references/plugin-provided-capabilities.md before mutating schema.view collections, verify the upstream database view exists with db-views list|get before creating or updating anything.--help once and follow the generated help text for flags and examples. When CLI is unavailable and another non-CLI transport must be used, inspect its exposed parameter schema before first use.Stop and ask the user to fix auth when the chosen transport returns 401, 403, Auth required, or equivalent access errors. If the chosen transport is nb api data-modeling CLI, guide the user to restore CLI authentication rather than switching transports.
Use only this final data-modeling operation surface:
collections listcollections getcollections fields listdataSources list-enableddataSources collections listdataSourcesCollections.fields listcollections applyfields applydataSourcesCollections.fields applycollections destroydb-views list|getWhen the transport is CLI-based, prefer learning exact flags from help instead of keeping large command-shape reminders in prompt context:
nb api data-modeling collections apply --helpnb api data-modeling collections fields list --helpnb api data-modeling fields apply --helpnb api data-modeling data-sources list-enabled --helpnb api data-modeling data-sources collections list --helpnb api data-modeling data-sources-collections fields list --helpnb api data-modeling data-sources-collections fields apply --helpnb api data-modeling collections destroy --helpDo not prefer older low-level collection or nested field commands when the final command surface can handle the task.
general, tree, file, calendar, comment, sql, view, or inherit from the name alone.template: "file", or uses wording such as "文件表", "合同文件", "扫描件", "证书文件", or "the file itself is the record", treat that as a binding collection-type requirement and choose template: "file" first.template: "comment", "评论表", or "评论插件的表", treat that as a binding plugin-backed collection-type requirement and choose template: "comment" after the comments plugin gate.general collection just because extra metadata fields are also needed.collections apply and fields apply. Let the server fill derived defaults.collections apply or fields apply for routine post-mutation confirmation. Use follow-up collections get or collections fields list only when the apply response is missing details needed for the task, or when relation/template side effects must be inspected in full.sequence when the user asks for 编码, 编号, 单号, 序号, 流水号, or similar auto-generated codes. Reserve code for code-editor content such as source code, SQL, JSON, or other syntax-oriented text.collections apply, do not send built-in system fields such as id, createdAt, createdBy, updatedAt, updatedBy, or template-owned structural fields unless the current command help explicitly says they are required.general, tree, file, calendar, comment, and other supported templates, assume the server will create the template defaults. Only send business fields that the user is actually adding.file, do not manually send built-in fields such as title, filename, extname, size, mimetype, path, url, preview, storage, or meta unless the task is explicitly customizing one of those existing fields on an already-created collection.comment, do not manually send the template-owned content field in a compact create payload unless the task is explicitly customizing that existing field on an already-created comment collection. The server baseline owns content.tree, do not manually include parentId, parent, or children in the compact create payload unless you are intentionally overriding an existing schema with a fully expanded raw shape.collections apply or fields apply still needs an explicit interface. The compact API reduces derived options, but it does not infer business field interfaces from the field name alone.collections apply or fields apply (select, multipleSelect, radioGroup, checkboxGroup), every enum item must be an object with explicit value, label, and color. Do not use string shorthand such as ["draft", "paid"].red, magenta, volcano, orange, gold, lime, green, cyan, blue, geekblue, purple, and default.type. Let the server derive it from interface. Only pass type when the current command help or a reference explicitly requires it.interface values now fail fast. If the correct interface is unclear, stop and inspect references or command help instead of guessing.vditor, formula, map geometry fields, or special relation fields, confirm the plugin-backed capability first.textarea.vditor first when the plugin capability is available.vditor to ordinary markdown when the plugin is unavailable or the user explicitly wants the simpler markdown field.comment collections, let the template create the markdown-capable content field instead of adding a separate plain text substitute.tableoid unless the user explicitly asks for that system-info field.point, lineString, circle, or polygon. Do not collapse them into generic json or text.formula, do not invent expressions from memory.references/fields/plugins/formula.md first.name, title, interface, expression, and optional engine or dataType.NocoBase supports server-side field validation through field options. These rules run in repository create and update, and are based on Joi. They are different from frontend uiSchema.x-validator; do not use x-validator when the user asks for service-side or database-model validation.
Prefer the compact validators shorthand in fields apply or nested collection fields. The server converts it to validation.rules, fills missing rule keys, and infers validation.type from the field interface:
{
"collectionName": "contacts",
"name": "email",
"title": "Email",
"interface": "email",
"validators": ["required", "email"]
}
Use full validation when the Joi type or rule shape must be explicit:
{
"collectionName": "orders",
"name": "amount",
"interface": "number",
"validation": {
"type": "number",
"rules": [
{ "key": "required", "name": "required" },
{ "key": "min", "name": "min", "args": { "limit": 0 } },
{ "key": "precision", "name": "precision", "args": { "limit": 2 } }
]
}
}
Common Joi-based rules:
string: required, min, max, length, pattern, email, uri, uuid, hex.number: required, min, max, greater, less, integer, multiple, precision.date: required, min, max, greater, less, timestamp.boolean and object: mainly required.Argument conventions:
min, max, length, and precision use args: { "limit": value }.pattern uses args: { "regex": "^[A-Z]+$" }.email, uuid, or uri, may use paramsType: "object" with an options object in args.Add validation rules when the business requirement says a value is required, must match a format, must stay within a length or numeric range, must use a fixed decimal precision, or must match a stable identifier format. Avoid adding strict rules just from field names alone if the requirement is ambiguous.
references/relation-fields.md before mutation.foreignKey, through, otherKey, sourceKey, and targetKey instead of relying on generated defaults.collections list or collections get.collections fields list.db-views list|get first.--help before first use in the current task.Before writing, determine:
Summarize the intended model in natural language before destructive or broad changes.
collections apply for collection-level creation or updates.fields apply for targeted field creation or updates.dataSources list-enabled, dataSources collections list, and dataSourcesCollections.fields list to inspect external data source metadata before writing relation fields.dataSourcesCollections.fields apply for external data source field metadata updates, especially relation fields on external data source collections.collections destroy only for explicit delete requests.Compact payloads are preferred. Supply only the fields the command contract requires, such as collection template/name/title and field name/title/interface, plus any necessary special options that cannot be derived safely.
For external data source relation fields, do not use main data source fields apply. Use dataSourcesCollections.fields apply with the external collection locator and compact relation interface, for example interface: "m2o", name, target, and explicit keys when stable names matter.
For collection creation, this usually means:
name, title, template, and a small number of template-specific flags;After each mutation, first inspect the apply response. collections apply should return key collection summary fields, applied field summaries, and verification diagnostics. fields apply should return the applied field summary.
Do not automatically run a second get or list after every successful apply. Read back only when the apply response does not include the details needed to prove the requested outcome, or when the task involves relation ownership, reverse fields, plugin/template side effects, or a user explicitly asks for a full read-back.
Confirm:
Load only the references needed for the active task:
references/collection-types/index.mdreferences/field-capabilities.mdreferences/relation-fields.mdreferences/plugin-provided-capabilities.mdreferences/model-packs/*.mdreferences/verification-playbook.mdAfter opening an index file, continue only into the matching subtype file that is actually in scope.
general: ordinary business records.tree: hierarchical data.file: file-centric records where the file is first-class.calendar: schedule-oriented objects.comment: plugin-backed comment records with a template-owned content field.sql, view, inherit: only after capability and prerequisites are confirmed.Do not emulate tree, file, or comment with weaker general-table substitutes unless the user explicitly asks for that tradeoff.
Explicit override rule:
general.file unless the user explicitly says the file is only a subordinate attachment on another business table.template: "comment", "评论表", or "评论插件的表", this overrides any default bias toward general; confirm the comments plugin and use template: "comment".references/field-capabilities.md as the source of truth for interface support.references/relation-fields.md before creating or changing relations.400 or 422: inspect the payload, then correct collection type, field interface, missing required options, enum shape, missing/invalid enum colors, or relation keys before retrying.| Topic | File |
| --- | --- |
| Collection type selection | references/collection-types/index.md |
| Field capability matrix | references/field-capabilities.md |
| Relation overview | references/relation-fields.md |
| Plugin-backed modeling capabilities | references/plugin-provided-capabilities.md |
| Whole-schema examples | references/model-packs/*.md |
| Verification order and checks | references/verification-playbook.md |
| Decision helper | references/decision-matrix.md |
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.
development
Use when users need NocoBase backup restore or migration publish operations through nb api backup and nb api migration commands.