Goal
Manage NocoBase workflows end to end through nb api workflow.
- Require an authenticated
nb CLI.
- Run
-h once before first using a subcommand in the current task.
- Use only workflow-specific CLI interfaces; do not substitute generic CRUD or source edits.
Scope
- Inspect, create, update, version, copy, enable, and diagnose workflows.
- Configure triggers and sequential node chains.
- Move, duplicate, test, or delete nodes and branches.
- Inspect executions and failed jobs.
- Author workflow-bound approval surfaces through
flowSurfaces.
Non-Goals
nb installation or authentication setup.
- Data-model design; use
nocobase-data-modeling.
- Ordinary pages, tabs, popups, or routes; use
nocobase-ui-builder.
- Whole-workflow deletion.
- Approval schema wiring.
- Invented types, fields, keys, filters, or evaluator functions.
Input Contract
Environment and Tooling
- Stop on authentication or authorization errors.
- For
expression, load the matching formula.js or math.js reference; never invent functions.
Filter Authoring Gate
Before drafting any workflow node/trigger filter or condition, or any user/assignee query object, load the nocobase-utils skill with topic filter, then read Filter Condition Format in the current task. This is mandatory even when the natural-language comparison looks obvious; the relative link is only the exact document location and does not replace the skill invocation.
- Read the target collection's field metadata and resolve the terminal field's frontend interface/type.
- Select the operator only from that field group's documented allowlist.
- For date fields, map “before/less than” to
$dateBefore, “after/greater than” to $dateAfter, “not before/at least/greater than or equal” to $dateNotBefore, and “not after/at most/less than or equal” to $dateNotAfter. Never use $lt, $lte, $gt, or $gte on a date field.
- Keep the configuration's documented filter shape and verify the final field/operator pairs before mutation.
Commercial Plugin Capability Gate
Verify the required plugin is installed and enabled before mutation:
| Capability |
Plugin |
| Approval and approval surfaces |
@nocobase/plugin-workflow-approval |
| Webhook |
@nocobase/plugin-workflow-webhook |
| Subflow |
@nocobase/plugin-workflow-subflow |
If unavailable, name the prerequisite and stop that path. Never replace requested approval semantics with a manual node. See commercial plugin gate.
Mandatory Clarification Gate
- Ask only about unresolved create-time, destructive, high-risk, or owner choices; at most two rounds and three questions per round.
- Proceed when later-editable details are at least 70% certain; verify them after mutation.
- Require a unique target and exact intended end state before mutation.
- Do not ask which copy mode the user means; infer it through the following gate and state the chosen outcome before mutation.
Workflow Update and Copy Intent Gate
Users usually describe a change, not a technical revision. Route by desired outcome:
| Intent |
Signals |
Route and consequence |
| Modify the existing workflow |
Update/adjust logic, trigger, condition, or nodes |
Fetch nodes and versionStats. If versionStats.executed > 0, create a same-workflow revision first; otherwise edit in place. Never create an independent workflow. |
| Create a new version |
Explicit new version/revision, preserved history, or successor version |
Create a revision with the same key. Version executions start at zero; history and key-level aggregate statistics remain. |
| Copy the workflow entity |
Copy/clone/save as, another process/template, renamed copy, reset statistics, or bare “copy this workflow” |
Create an independent workflow with a new key; execution count and history start empty. |
Precedence: explicit version continuity → revision; explicit separate identity → independent copy; concrete behavior change → update; bare workflow copy → independent copy.
Use exactly these revision calls:
# Same workflow, new version
nb api workflow workflows revision \
--filter-by-tk <source-id> \
--filter '{"key":"<source-key>"}'
# Independent workflow
nb api workflow workflows revision \
--filter-by-tk <source-id>
- Same-workflow mode requires the exact top-level control object
{"key":"..."}. Never nest it in $and/$or, put it in the body, or use an empty filter.
- Omit
filter for an independent copy.
- Read back before further mutation: revision means new
id and unchanged key; independent copy means both differ.
- The CLI sends
filter as one JSON query object; the repository switches mode only on direct filter.key.
Collection Resolution Gate
For any required but unclear collection:
- Inspect existing collections and fields with
nocobase-data-modeling.
- Use a match at 70% confidence or higher.
- Otherwise ask the user to identify or create the collection.
This applies to collection-bound triggers, operations, schedules, and nodes. See workflow conventions.
Reference Loading Map
- Version and copy operations: workflows CLI
- HTTP transport: workflows HTTP API
- Keys, versions, and statistics: workflow model
- Authoring: triggers, nodes, and conventions
- Any node/trigger filter, condition, or assignee query: load
nocobase-utils with topic filter, then read Filter Condition Format before operator selection
- Approval UI: approval UI index and surface constraints
Final Command Surface
- Workflows:
workflows list|get|create|update|revision|sync|execute
- Nodes:
workflows nodes create; flow-nodes get|update|destroy|destroy-branch|move|duplicate|test
- Diagnostics:
executions list|get; jobs list|get|resume
- Approval surfaces:
flowSurfaces get|catalog|applyApprovalBlueprint|addBlock|addField|addAction|compose|configure|setLayout
Use CLI index for flags and HTTP API index only for underlying request shapes.
Approval UI Entry
- Approval surfaces are bound by
approvalUid or taskCardUid; they are not ordinary pages.
- Initiator UI requires
ApplyFormModel; approver UI requires both ApprovalDetailsModel and ProcessFormModel.
- Use only actions and blocks returned by the live catalog; do not patch reconciled node action config manually.
- Use
applyApprovalBlueprint for first setup or replacement.
- Resolve the bound root before localized operations.
- Task cards support
fields + layout; use setLayout for layout-only edits.
- Read field-component options from
catalog.node.configureOptions.fieldComponent.enum.
- Load the approval UI index before authoring; load surface constraints for payload rules.
Safety Gate
- Create workflows disabled; require confirmation before enabling.
- Apply the update and copy gate before editing or copying.
- Pass a concrete target to every mutation or destructive call.
- Create nodes sequentially and chain them with
upstreamId.
- Apply the Filter Authoring Gate to every persisted node/trigger filter; wrap workflow data/query filters in
$and or $or. See the intent gate for revision control.
- Reference node results by the returned node
key, never its numeric id.
- Model raw JSON with
json-variable-mapping or json-query before downstream use.
- Read back every mutation.
- Require confirmation before manual execution.
Workflow
Planning Phase
Resolve intent, trigger, node chain, sync mode, collections, filters, mappings, variables, and raw JSON modeling. If any persisted filter is required, load nocobase-utils with topic filter, read the Filter reference, and resolve each terminal field type before drafting operators. State the plan and any history/statistics consequence.
For approval UI, classify the request as whole-surface setup/replacement or localized editing, then load the approval UI reference.
Creating a New Workflow
- Resolve collections.
- Create with
enabled: false.
- Configure the trigger.
- Build the node chain under the Safety Gate.
- Complete the Verification Checklist.
Editing an Existing Workflow
- Fetch the workflow with
nodes and versionStats.
- Apply the update and copy gate.
- Mutate only the resolved editable
id.
- Complete the Verification Checklist.
Diagnosing a Failed Execution
- List executions by
workflowId, newest first.
- Fetch the execution with jobs, workflow, and nodes; omit job results initially.
- Find status
-1 (failed), -2 (error), or -3 (aborted).
- Fetch the failed job and inspect
result.
- Fix the configuration, then follow the Safety Gate.
Error Handling
400/422: correct the reported type, field, or link error, then retry.
- Authentication error: stop and request restored access.
- Node creation failure: fix or remove it before creating downstream nodes.
- Revision failure: re-fetch state before retrying.
Verification Checklist
Verify:
- Workflow type, title, sync mode, and enabled state.
- Trigger configuration.
- Node count, order, types, configs, and
upstreamId chain.
- Required mutation filters are non-empty.
- Revision/copy
id and key match the selected mode.
- Approval roots and surface readback match the intended route.
- Raw JSON is modeled before downstream use.
- Required commercial plugins are enabled.
- The returned mutation state matches the requested outcome.
- Every persisted filter field/operator pair was checked against the terminal field's frontend operator group; date fields contain no number comparison operators.
Plugin version control revision rule
- Load
nocobase-revision every round. If unavailable, ignore this section and disclose nothing about it.
- Reveal no revision information until that skill confirms
nb revision create is available.
- If available, make one revision decision immediately before the final reply; report a created revision or the concrete reason none was created.
References
1---2name: nocobase-workflow-manage3description: NocoBase 2 only; never use in a NocoBase 3 project. Use when users need to inspect, create, update, copy, enable, or diagnose NocoBase workflows through `nb`, including version-safe edits, node changes, approval surfaces, and execution troubleshooting.4---5
6# Goal
7
8Manage NocoBase workflows end to end through `nb api workflow`.
9
101. Require an authenticated `nb` CLI.
112. Run `-h` once before first using a subcommand in the current task.
123. Use only workflow-specific CLI interfaces; do not substitute generic CRUD or source edits.
13
14# Scope
15
16- Inspect, create, update, version, copy, enable, and diagnose workflows.
17- Configure triggers and sequential node chains.
18- Move, duplicate, test, or delete nodes and branches.
19- Inspect executions and failed jobs.
20- Author workflow-bound approval surfaces through `flowSurfaces`.
21
22# Non-Goals
23
24- `nb` installation or authentication setup.
25- Data-model design; use `nocobase-data-modeling`.
26- Ordinary pages, tabs, popups, or routes; use `nocobase-ui-builder`.
27- Whole-workflow deletion.
28- Approval schema wiring.
29- Invented types, fields, keys, filters, or evaluator functions.
30
31# Input Contract
32
33## Environment and Tooling
34
35- Stop on authentication or authorization errors.
36- For `expression`, load the matching [formula.js](../nocobase-utils/references/evaluators/formulajs.md) or [math.js](../nocobase-utils/references/evaluators/mathjs.md) reference; never invent functions.
37
38## Filter Authoring Gate
39
40Before drafting any workflow node/trigger `filter` or `condition`, or any user/assignee query object, load the `nocobase-utils` skill with topic `filter`, then read [Filter Condition Format](../nocobase-utils/references/filter/index.md) in the current task. This is mandatory even when the natural-language comparison looks obvious; the relative link is only the exact document location and does not replace the skill invocation.
41
421. Read the target collection's field metadata and resolve the terminal field's frontend interface/type.
432. Select the operator only from that field group's documented allowlist.
443. For date fields, map “before/less than” to `$dateBefore`, “after/greater than” to `$dateAfter`, “not before/at least/greater than or equal” to `$dateNotBefore`, and “not after/at most/less than or equal” to `$dateNotAfter`. Never use `$lt`, `$lte`, `$gt`, or `$gte` on a date field.
454. Keep the configuration's documented filter shape and verify the final field/operator pairs before mutation.
46
47## Commercial Plugin Capability Gate
48
49Verify the required plugin is installed and enabled before mutation:
50
51| Capability | Plugin |
52|---|---|
53| Approval and approval surfaces | `@nocobase/plugin-workflow-approval` |
54| Webhook | `@nocobase/plugin-workflow-webhook` |
55| Subflow | `@nocobase/plugin-workflow-subflow` |
56
57If unavailable, name the prerequisite and stop that path. Never replace requested approval semantics with a `manual` node. See [commercial plugin gate](references/commercial-plugin-gate.md).
58
59# Mandatory Clarification Gate
60
61- Ask only about unresolved create-time, destructive, high-risk, or owner choices; at most two rounds and three questions per round.
62- Proceed when later-editable details are at least 70% certain; verify them after mutation.
63- Require a unique target and exact intended end state before mutation.
64- Do not ask which copy mode the user means; infer it through the following gate and state the chosen outcome before mutation.
65
66## Workflow Update and Copy Intent Gate
67
68Users usually describe a change, not a technical revision. Route by desired outcome:
69
70| Intent | Signals | Route and consequence |
71|---|---|---|
72| Modify the existing workflow | Update/adjust logic, trigger, condition, or nodes | Fetch `nodes` and `versionStats`. If `versionStats.executed > 0`, create a same-workflow revision first; otherwise edit in place. Never create an independent workflow. |
73| Create a new version | Explicit new version/revision, preserved history, or successor version | Create a revision with the same `key`. Version executions start at zero; history and key-level aggregate statistics remain. |
74| Copy the workflow entity | Copy/clone/save as, another process/template, renamed copy, reset statistics, or bare “copy this workflow” | Create an independent workflow with a new `key`; execution count and history start empty. |
75
76Precedence: explicit version continuity → revision; explicit separate identity → independent copy; concrete behavior change → update; bare workflow copy → independent copy.
77
78Use exactly these revision calls:
79
80```bash
81# Same workflow, new version
82nb api workflow workflows revision \
83 --filter-by-tk <source-id> \
84 --filter '{"key":"<source-key>"}'
85
86# Independent workflow
87nb api workflow workflows revision \
88 --filter-by-tk <source-id>
89```
90
91- Same-workflow mode requires the exact top-level control object `{"key":"..."}`. Never nest it in `$and`/`$or`, put it in the body, or use an empty filter.
92- Omit `filter` for an independent copy.
93- Read back before further mutation: revision means new `id` and unchanged `key`; independent copy means both differ.
94- The CLI sends `filter` as one JSON query object; the repository switches mode only on direct `filter.key`.
95
96## Collection Resolution Gate
97
98For any required but unclear `collection`:
99
1001. Inspect existing collections and fields with `nocobase-data-modeling`.
1012. Use a match at 70% confidence or higher.
1023. Otherwise ask the user to identify or create the collection.
103
104This applies to collection-bound triggers, operations, schedules, and nodes. See [workflow conventions](references/conventions/index.md#the-collection-field-in-trigger-and-node-configuration).
105
106# Reference Loading Map
107
108- Version and copy operations: [workflows CLI](references/cli/workflows.md)
109- HTTP transport: [workflows HTTP API](references/http-api/workflows.md)
110- Keys, versions, and statistics: [workflow model](references/modeling/workflows.md)
111- Authoring: [triggers](references/triggers/index.md), [nodes](references/nodes/index.md), and [conventions](references/conventions/index.md)
112- Any node/trigger filter, condition, or assignee query: load `nocobase-utils` with topic `filter`, then read [Filter Condition Format](../nocobase-utils/references/filter/index.md) before operator selection
113- Approval UI: [approval UI index](references/approval/ui-config/index.md) and [surface constraints](references/approval/ui-config/surfaces.md)
114
115## Final Command Surface
116
117- Workflows: `workflows list|get|create|update|revision|sync|execute`
118- Nodes: `workflows nodes create`; `flow-nodes get|update|destroy|destroy-branch|move|duplicate|test`
119- Diagnostics: `executions list|get`; `jobs list|get|resume`
120- Approval surfaces: `flowSurfaces get|catalog|applyApprovalBlueprint|addBlock|addField|addAction|compose|configure|setLayout`
121
122Use [CLI index](references/cli/index.md) for flags and [HTTP API index](references/http-api/index.md) only for underlying request shapes.
123
124# Approval UI Entry
125
126- Approval surfaces are bound by `approvalUid` or `taskCardUid`; they are not ordinary pages.
127- Initiator UI requires `ApplyFormModel`; approver UI requires both `ApprovalDetailsModel` and `ProcessFormModel`.
128- Use only actions and blocks returned by the live catalog; do not patch reconciled node action config manually.
129- Use `applyApprovalBlueprint` for first setup or replacement.
130- Resolve the bound root before localized operations.
131- Task cards support `fields + layout`; use `setLayout` for layout-only edits.
132- Read field-component options from `catalog.node.configureOptions.fieldComponent.enum`.
133- Load the [approval UI index](references/approval/ui-config/index.md) before authoring; load [surface constraints](references/approval/ui-config/surfaces.md) for payload rules.
134
135# Safety Gate
136
1371. Create workflows disabled; require confirmation before enabling.
1382. Apply the [update and copy gate](#workflow-update-and-copy-intent-gate) before editing or copying.
1393. Pass a concrete target to every mutation or destructive call.
1404. Create nodes sequentially and chain them with `upstreamId`.
1415. Apply the [Filter Authoring Gate](#filter-authoring-gate) to every persisted node/trigger filter; wrap workflow data/query filters in `$and` or `$or`. See the intent gate for revision control.
1426. Reference node results by the returned node `key`, never its numeric `id`.
1437. Model raw JSON with `json-variable-mapping` or `json-query` before downstream use.
1448. Read back every mutation.
1459. Require confirmation before manual execution.
146
147# Workflow
148
149## Planning Phase
150
151Resolve intent, trigger, node chain, sync mode, collections, filters, mappings, variables, and raw JSON modeling. If any persisted filter is required, load `nocobase-utils` with topic `filter`, read the Filter reference, and resolve each terminal field type before drafting operators. State the plan and any history/statistics consequence.
152
153For approval UI, classify the request as whole-surface setup/replacement or localized editing, then load the approval UI reference.
154
155## Creating a New Workflow
156
1571. Resolve collections.
1582. Create with `enabled: false`.
1593. Configure the trigger.
1604. Build the node chain under the [Safety Gate](#safety-gate).
1615. Complete the [Verification Checklist](#verification-checklist).
162
163## Editing an Existing Workflow
164
1651. Fetch the workflow with `nodes` and `versionStats`.
1662. Apply the [update and copy gate](#workflow-update-and-copy-intent-gate).
1673. Mutate only the resolved editable `id`.
1684. Complete the [Verification Checklist](#verification-checklist).
169
170## Diagnosing a Failed Execution
171
1721. List executions by `workflowId`, newest first.
1732. Fetch the execution with jobs, workflow, and nodes; omit job results initially.
1743. Find status `-1` (failed), `-2` (error), or `-3` (aborted).
1754. Fetch the failed job and inspect `result`.
1765. Fix the configuration, then follow the [Safety Gate](#safety-gate).
177
178## Error Handling
179
180- `400/422`: correct the reported type, field, or link error, then retry.
181- Authentication error: stop and request restored access.
182- Node creation failure: fix or remove it before creating downstream nodes.
183- Revision failure: re-fetch state before retrying.
184
185# Verification Checklist
186
187Verify:
188
1891. Workflow type, title, sync mode, and enabled state.
1902. Trigger configuration.
1913. Node count, order, types, configs, and `upstreamId` chain.
1924. Required mutation filters are non-empty.
1935. Revision/copy `id` and `key` match the selected mode.
1946. Approval roots and surface readback match the intended route.
1957. Raw JSON is modeled before downstream use.
1968. Required commercial plugins are enabled.
1979. The returned mutation state matches the requested outcome.
19810. Every persisted filter field/operator pair was checked against the terminal field's frontend operator group; date fields contain no number comparison operators.
199
200# Plugin version control revision rule
201
202- Load `nocobase-revision` every round. If unavailable, ignore this section and disclose nothing about it.
203- Reveal no revision information until that skill confirms `nb revision create` is available.
204- If available, make one revision decision immediately before the final reply; report a created revision or the concrete reason none was created.
205
206# References
207
208- [Commercial plugin gate](references/commercial-plugin-gate.md)
209- [Approval UI index](references/approval/ui-config/index.md) and [surface constraints](references/approval/ui-config/surfaces.md)
210- [Workflow model](references/modeling/index.md) and [workflow fields](references/modeling/workflows.md)
211- [Conventions](references/conventions/index.md)
212- [CLI](references/cli/index.md) and [HTTP API](references/http-api/index.md)
213- [Triggers](references/triggers/index.md) and [nodes](references/nodes/index.md)
214- [Filter format](../nocobase-utils/references/filter/index.md) and [evaluators](../nocobase-utils/references/evaluators/index.md)
215- [Data modeling skill](../nocobase-data-modeling/SKILL.md)
216- [Official workflow handbook](https://docs.nocobase.com/handbook/workflow) and [revision guide](https://docs.nocobase.com/handbook/workflow/advanced/revisions) [verified: 2026-04-09]