Skip to content

casen generate

casen generate bpmn produces BPMN 2.0 files without the interactive TUI. It has three operating modes: template, definition (full JSON), and modify-existing (patch). Auto-layout is applied in all modes.

casen generate
└── bpmn — generate or modify a BPMN file

Pick a built-in template by name. Use --process-id and --name to customise the identifiers.

Terminal window
casen generate bpmn --template minimal --process-id order --name "Order Processing"
casen generate bpmn --template approval --process-id leave-request
casen generate bpmn --template parallel --process-id enrichment --name Enrichment
casen generate bpmn --template timer-start --process-id nightly-sync
TemplatePattern
emptyStart event only — bare skeleton
minimalStart → service task → end
user-taskStart → user task → end
call-activityStart → call activity → end
business-ruleStart → business rule task → end
approvalStart → user task → XOR gateway → approve/reject paths
parallelStart → parallel fork → 2 service tasks → join → end
inclusiveStart → inclusive gateway → 2 conditional tasks → merge → end
timer-startTimer start event → service task → end
message-startMessage start event → service task → end
error-boundaryService task with error boundary → two end events
subprocessStart → embedded sub-process → end
event-subprocessProcess with a non-interrupting error event sub-process
FlagShortDescriptionDefault
--templateTemplate name (see table above)minimal
--process-id-iProcess element IDprocess
--name-nProcess display name
--output-oOutput file path (- for stdout)<process-id>.bpmn

Pass a full CompactDiagram JSON object directly. This covers all 23 BPMN element types, all event definition types, boundary events, sub-processes, and Zeebe extensions.

Terminal window
# Inline JSON
casen generate bpmn --definition '{"id":"Definitions_order","processes":[...]}'
# Pipe from a file or AI output
cat definition.json | casen generate bpmn --output order.bpmn
# Write to stdout
echo '{"id":"Defs","processes":[...]}' | casen generate bpmn --output -

Run --help-schema to print the full CompactDiagram reference — element types, event types, field descriptions, and a worked example — formatted for quick AI consumption:

Terminal window
casen generate bpmn --help-schema
{
"id": "Definitions_my-process",
"processes": [{
"id": "my-process",
"name": "My Process",
"elements": [
{ "id": "start", "type": "startEvent", "name": "Start" },
{ "id": "task1", "type": "serviceTask", "name": "Do Work", "jobType": "my-worker" },
{ "id": "gw", "type": "exclusiveGateway", "name": "OK?" },
{ "id": "end-ok", "type": "endEvent", "name": "Done" },
{ "id": "end-err","type": "endEvent", "name": "Failed", "eventType": "error" }
],
"flows": [
{ "id": "f1", "from": "start", "to": "task1" },
{ "id": "f2", "from": "task1", "to": "gw" },
{ "id": "f3", "from": "gw", "to": "end-ok", "condition": "= ok", "name": "Yes" },
{ "id": "f4", "from": "gw", "to": "end-err", "condition": "= not ok", "name": "No" }
]
}]
}

Element types — all 23 BPMN types supported:

  • Tasks: serviceTask userTask scriptTask businessRuleTask callActivity sendTask receiveTask manualTask task
  • Events: startEvent endEvent intermediateCatchEvent intermediateThrowEvent boundaryEvent
  • Gateways: exclusiveGateway parallelGateway inclusiveGateway eventBasedGateway complexGateway
  • Containers: subProcess adHocSubProcess eventSubProcess transaction

Event types (eventType field on event elements): timer message signal error escalation terminate cancel conditional link compensate

Zeebe extensions:

FieldApplies toEffect
jobTypeserviceTask, sendTaskSets zeebe:taskDefinition.type
taskHeadersserviceTask, sendTaskSets zeebe:taskHeaders key/value pairs
resultVariableserviceTask, businessRuleTaskMaps connector response to a variable
calledProcesscallActivitySets zeebe:calledElement.processId
formIduserTaskSets zeebe:formDefinition.formId
decisionIdbusinessRuleTaskSets zeebe:calledDecision.decisionId

HTTP connector shorthand:

{
"id": "http1",
"type": "serviceTask",
"name": "Call API",
"jobType": "io.camunda:http-json:1",
"taskHeaders": {
"url": "https://api.example.com/orders",
"method": "POST"
},
"resultVariable": "apiResponse"
}

Load an existing .bpmn file and patch it — add elements and flows, then re-apply auto-layout. The default output overwrites the input file.

Use --dump-compact to print the file’s CompactDiagram JSON. Use this to discover existing element IDs before writing a patch.

Terminal window
casen generate bpmn --input order.bpmn --dump-compact

Output is a CompactDiagram JSON object — the same format accepted by --definition.

Terminal window
# Add a rejection path to an existing gateway with id "gw"
casen generate bpmn --input order.bpmn \
--patch '{"elements":[
{"id":"notify", "type":"serviceTask","name":"Notify Customer","jobType":"notify-worker"},
{"id":"end-reject", "type":"endEvent", "name":"Rejected"}
],"flows":[
{"id":"fn1","from":"gw", "to":"notify", "condition":"= not approved","name":"No"},
{"id":"fn2","from":"notify", "to":"end-reject"}
]}'

Patch mode appends to the first process in the file. Flows in the patch can reference existing element IDs — they are not required to be new.

Terminal window
# AI generates the patch JSON, pipe it in
echo '{"elements":[...],"flows":[...]}' | casen generate bpmn --input order.bpmn

Run --input without --patch to re-apply auto-layout without changing the process model:

Terminal window
casen generate bpmn --input messy.bpmn --output clean.bpmn
FlagDescriptionDefault
--input / -fExisting .bpmn file to load
--patchJSON patch: {"elements":[...],"flows":[...]}
--dump-compactPrint CompactDiagram JSON of --input and exit
--output / -oOutput path (- for stdout)Overwrites --input file
Terminal window
# 1. Inspect the existing file — AI learns element IDs
casen generate bpmn --input order.bpmn --dump-compact
# 2. Check the schema if needed
casen generate bpmn --help-schema
# 3. AI generates patch JSON and pipes it in
echo '{"elements":[...],"flows":[...]}' | casen generate bpmn --input order.bpmn
# 4. Verify the result
casen view bpmn order.bpmn