Skip to content

Commit 5d2b9e5

Browse files
akoclaude
andcommitted
Add write-workflows skill for workflow MDL syntax reference
Covers exploring workflows (SHOW/DESCRIBE/catalog queries/code navigation) and creating workflows (all activity types, outcomes, boundary events, parallel splits, decisions). Includes complete example and checklist. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a2fa441 commit 5d2b9e5

2 files changed

Lines changed: 302 additions & 0 deletions

File tree

cmd/mxcli/skills/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Detailed syntax for each MDL document type:
2020
| [mdl-entities.md](mdl-entities.md) | Entity, attribute, association syntax | Creating domain models |
2121
| [write-microflows.md](write-microflows.md) | Microflow syntax reference | Writing microflow logic |
2222
| [write-oql-queries.md](write-oql-queries.md) | OQL query syntax | Creating VIEW entities |
23+
| [write-workflows.md](write-workflows.md) | Workflow syntax reference | Creating and exploring workflows |
2324
| [create-page.md](create-page.md) | Page and widget syntax | Creating pages |
2425
| [fragments.md](fragments.md) | Fragment (reusable widget group) syntax | Reusing widget patterns across pages |
2526

@@ -86,6 +87,9 @@ Load skills based on the task:
8687
| "Change widgets in bulk" | `bulk-widget-updates.md` |
8788
| "Reuse widgets across pages" | `fragments.md` |
8889
| "Define a fragment" | `fragments.md` |
90+
| "Create workflow" | `write-workflows.md` |
91+
| "Show/describe workflows" | `write-workflows.md` |
92+
| "Approval process" | `write-workflows.md` |
8993

9094
### For Error Recovery
9195

Lines changed: 298 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,298 @@
1+
# Workflows
2+
3+
## When to Use This Skill
4+
5+
Use this skill when the user wants to:
6+
- Explore existing workflows in a Mendix project
7+
- Create new workflows with user tasks, decisions, and microflow calls
8+
- Understand workflow structure and activity types
9+
- Navigate workflow cross-references (callers, callees, impact)
10+
11+
## Exploring Workflows
12+
13+
### List All Workflows
14+
15+
```sql
16+
SHOW WORKFLOWS;
17+
SHOW WORKFLOWS IN MyModule;
18+
```
19+
20+
### Describe a Workflow
21+
22+
```sql
23+
DESCRIBE WORKFLOW Module.WorkflowName;
24+
```
25+
26+
Shows the full workflow definition: parameter entity, activities, outcomes, user targeting, boundary events.
27+
28+
### Catalog Queries
29+
30+
```sql
31+
REFRESH CATALOG FULL;
32+
33+
-- All workflows
34+
SELECT * FROM CATALOG.WORKFLOWS;
35+
36+
-- Workflows with user tasks
37+
SELECT QualifiedName, ActivityCount, UserTaskCount, DecisionCount
38+
FROM CATALOG.WORKFLOWS WHERE UserTaskCount > 0;
39+
40+
-- Workflows in a specific module
41+
SELECT QualifiedName, ParameterEntity
42+
FROM CATALOG.WORKFLOWS WHERE ModuleName = 'MyModule';
43+
```
44+
45+
### Code Navigation
46+
47+
```sql
48+
-- What calls this workflow
49+
SHOW CALLERS OF Module.WorkflowName;
50+
51+
-- All references to this workflow
52+
SHOW REFERENCES TO Module.WorkflowName;
53+
54+
-- Impact analysis (what would break if changed)
55+
SHOW IMPACT OF Module.WorkflowName;
56+
57+
-- Full context for analysis
58+
SHOW CONTEXT OF Module.WorkflowName;
59+
```
60+
61+
## Creating Workflows
62+
63+
### Basic Structure
64+
65+
```sql
66+
CREATE WORKFLOW Module.ApprovalFlow
67+
PARAMETER $WorkflowContext: Module.Request
68+
OVERVIEW PAGE Module.ApprovalOverview
69+
DUE DATE 'addDays([%CurrentDateTime%], 7)'
70+
BEGIN
71+
<activities>
72+
END WORKFLOW;
73+
```
74+
75+
Use `CREATE OR REPLACE` to overwrite an existing workflow.
76+
77+
### Activity Types
78+
79+
#### User Task
80+
81+
Assigns work to a user with a task page and outcomes.
82+
83+
```sql
84+
USER TASK ReviewTask 'Review the request'
85+
PAGE Module.ReviewPage
86+
TARGETING MICROFLOW Module.DS_GetReviewers
87+
ENTITY Module.ReviewTask
88+
DUE DATE 'addDays([%CurrentDateTime%], 3)'
89+
OUTCOMES
90+
'Approve' { }
91+
'Reject' { };
92+
```
93+
94+
- `PAGE` — the task page shown to the assigned user
95+
- `TARGETING MICROFLOW` — microflow that returns the list of candidate users
96+
- `TARGETING XPATH` — XPath constraint to select candidate users
97+
- `ENTITY` — optional task-specific entity (for task-level data)
98+
- `OUTCOMES` — each outcome can contain nested activities in `{ }`
99+
100+
For multi-user tasks (all assignees must complete):
101+
102+
```sql
103+
MULTI USER TASK ParallelReview 'All reviewers must approve'
104+
PAGE Module.ReviewPage
105+
TARGETING MICROFLOW Module.DS_GetAllReviewers
106+
OUTCOMES
107+
'Approve' { }
108+
'Reject' { };
109+
```
110+
111+
#### Call Microflow
112+
113+
Executes a microflow as an automated step. Parameters are auto-bound to `$WorkflowContext`.
114+
115+
```sql
116+
CALL MICROFLOW Module.ACT_ProcessRequest;
117+
```
118+
119+
With explicit parameter mappings:
120+
121+
```sql
122+
CALL MICROFLOW Module.ACT_SendNotification
123+
WITH (Module.ACT_SendNotification.Recipient = '$WorkflowContext/Module.Request_Recipient');
124+
```
125+
126+
With conditional outcomes (when the microflow returns Boolean or Enumeration):
127+
128+
```sql
129+
CALL MICROFLOW Module.ACT_ValidateRequest
130+
OUTCOMES
131+
'True' { }
132+
'False' { };
133+
```
134+
135+
#### Call Workflow (Sub-workflow)
136+
137+
Calls another workflow. The `$WorkflowContext` parameter is auto-bound.
138+
139+
```sql
140+
CALL WORKFLOW Module.SubApproval;
141+
```
142+
143+
#### Decision (Exclusive Split)
144+
145+
Branch based on a Boolean or Enumeration expression.
146+
147+
```sql
148+
-- Boolean decision
149+
DECISION '$WorkflowContext/Amount > 10000'
150+
OUTCOMES
151+
'True' {
152+
USER TASK ManagerApproval 'Manager approval required'
153+
PAGE Module.ApprovalPage
154+
OUTCOMES 'Approve' { } 'Reject' { };
155+
}
156+
'False' { };
157+
158+
-- Enumeration decision
159+
DECISION '$WorkflowContext/Priority'
160+
OUTCOMES
161+
'Module.Priority.High' {
162+
CALL MICROFLOW Module.ACT_EscalateRequest;
163+
}
164+
'Module.Priority.Low' { }
165+
'Default' { };
166+
```
167+
168+
#### Parallel Split
169+
170+
Execute multiple paths concurrently. All paths must complete before continuing.
171+
172+
```sql
173+
PARALLEL SPLIT
174+
PATH 1 {
175+
USER TASK LegalReview 'Legal review'
176+
PAGE Module.LegalReviewPage
177+
OUTCOMES 'Approve' { } 'Reject' { };
178+
}
179+
PATH 2 {
180+
USER TASK FinanceReview 'Finance review'
181+
PAGE Module.FinanceReviewPage
182+
OUTCOMES 'Approve' { } 'Reject' { };
183+
};
184+
```
185+
186+
#### Wait Activities
187+
188+
```sql
189+
-- Wait for a timer expression
190+
WAIT FOR TIMER 'addDays([%CurrentDateTime%], 1)';
191+
192+
-- Wait for an external notification
193+
WAIT FOR NOTIFICATION;
194+
```
195+
196+
#### Boundary Events
197+
198+
Attach timer-based interrupts to user tasks, call activities, or wait activities.
199+
200+
```sql
201+
USER TASK ReviewTask 'Review request'
202+
PAGE Module.ReviewPage
203+
OUTCOMES 'Approve' { } 'Reject' { }
204+
BOUNDARY EVENT INTERRUPTING TIMER 'addDays([%CurrentDateTime%], 3)' {
205+
CALL MICROFLOW Module.ACT_EscalateOverdue;
206+
};
207+
```
208+
209+
Event types: `INTERRUPTING TIMER`, `NON INTERRUPTING TIMER`.
210+
211+
#### Jump To
212+
213+
Jump back to a named activity (for loops/retries).
214+
215+
```sql
216+
JUMP TO ReviewTask;
217+
```
218+
219+
#### End
220+
221+
Explicitly end a path (implicit at workflow end, but useful in branches).
222+
223+
```sql
224+
END;
225+
```
226+
227+
#### Annotation
228+
229+
Add a sticky-note comment to the workflow canvas.
230+
231+
```sql
232+
ANNOTATION 'This section handles escalation logic';
233+
```
234+
235+
### Drop a Workflow
236+
237+
```sql
238+
DROP WORKFLOW Module.ApprovalFlow;
239+
```
240+
241+
## Complete Example
242+
243+
```sql
244+
CREATE WORKFLOW HR.OnboardingWorkflow
245+
PARAMETER $WorkflowContext: HR.OnboardingRequest
246+
OVERVIEW PAGE HR.OnboardingOverview
247+
DUE DATE 'addDays([%CurrentDateTime%], 30)'
248+
BEGIN
249+
CALL MICROFLOW HR.ACT_PrepareOnboarding;
250+
251+
PARALLEL SPLIT
252+
PATH 1 {
253+
USER TASK ITSetup 'Set up IT accounts'
254+
PAGE HR.ITSetupPage
255+
TARGETING MICROFLOW HR.DS_GetITTeam
256+
OUTCOMES 'Done' { };
257+
}
258+
PATH 2 {
259+
USER TASK HRPaperwork 'Complete HR paperwork'
260+
PAGE HR.PaperworkPage
261+
TARGETING MICROFLOW HR.DS_GetHRTeam
262+
OUTCOMES 'Done' { };
263+
};
264+
265+
DECISION '$WorkflowContext/RequiresTraining'
266+
OUTCOMES
267+
'True' {
268+
USER TASK ScheduleTraining 'Schedule training'
269+
PAGE HR.TrainingPage
270+
OUTCOMES 'Scheduled' { };
271+
}
272+
'False' { };
273+
274+
CALL MICROFLOW HR.ACT_CompleteOnboarding;
275+
END WORKFLOW;
276+
```
277+
278+
## Common Mistakes
279+
280+
| Mistake | Fix |
281+
|---------|-----|
282+
| Duplicate activity names | Names are auto-deduplicated (CE0495), but use unique names for clarity |
283+
| Missing parameter entity | Always specify `PARAMETER $WorkflowContext: Module.Entity` |
284+
| Bare entity in TARGETING | Use qualified name: `TARGETING MICROFLOW Module.MicroflowName` |
285+
| Forgetting outcomes on user tasks | Every user task needs at least one outcome |
286+
| Using `'Approve'`/`'Reject'` as decision outcomes | Decision outcomes must be `'True'`/`'False'` for Boolean, or enum values |
287+
288+
## Checklist
289+
290+
- [ ] Parameter entity exists in the domain model
291+
- [ ] Overview page exists (if specified)
292+
- [ ] All referenced microflows exist
293+
- [ ] All referenced pages exist
294+
- [ ] User task pages exist and are configured for the task entity
295+
- [ ] Targeting microflows return a list of `System.User`
296+
- [ ] Each user task has at least one outcome
297+
- [ ] Decision expressions match the outcome type (Boolean → True/False, Enum → values)
298+
- [ ] Use `DESCRIBE WORKFLOW` to verify the created workflow

0 commit comments

Comments
 (0)