/bpmn-to-code:migrate-to-bpmn-to-code-apis [path/to/scan] | [ProcessApiClassName] | --from-5xfrom bpmn-to-code
Replaces hardcoded BPMN element IDs, job types, and message names with references to the generated Process API, or rewrites 5.x API references to 6.x with --from-5x. Use when migrating code onto the Process API or upgrading bpmn-to-code.
Ships in bpmn-to-code. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Two modes over the generated Process API:
Elements, Variables, CallActivities, Timers) and to nested subprocess interiors so they point at the node-centric FlowNodes.Pick Mode B when $ARGUMENTS contains --from-5x or the scan finds references to a removed section; otherwise run Mode A.
Generated by bpmn-to-code)..bpmn) — these are source-of-truth inputs, not generated code../gradlew generateBpmnModelApi or mvn io.miragon:bpmn-to-code-maven:generate-bpmn-api).| Section | Kotlin | Java | C# | TypeScript |
|---|---|---|---|---|
| process id | Api.PROCESS_ID (ProcessId) | same | Api.ProcessId (const string) | Api.PROCESS_ID (string literal) |
| shared definitions | Messages.X (MessageName), Signals.X (SignalName), Errors.X (BpmnErrorDefinition), Escalations.X, ServiceTasks.X (const String) | same | Messages.X (const string), Errors.X.Reference / .Code, ServiceTasks.X | Messages.X, Signals.X, ServiceTasks.X (string literals), Errors.X.name / .code |
| element id | Api.FlowNodes.Node.id (ElementId) | Api.FlowNodes.node().getId() | Api.FlowNodes.Node.Id | Api.FlowNodes.Node.id |
| job type of one element | Api.FlowNodes.Node.jobType (String, HasJobType) | Api.FlowNodes.node().getJobType() | Api.FlowNodes.Node.JobType | Api.FlowNodes.Node.jobType |
| variable | Api.FlowNodes.Node.Variables.V (VariableName.Input / .Output / .InOut) | same | Api.FlowNodes.Node.Variables.V | Api.FlowNodes.Node.variables.V (VariableName) |
| call activity | Api.FlowNodes.Node.calledProcess (ProcessId), .Inputs.M / .Outputs.M (InputOutputMapping) | Api.FlowNodes.node().getCalledProcess(), Api.FlowNodes.Node.Inputs.M | Api.FlowNodes.Node.CalledProcess, .Inputs.M | Api.FlowNodes.Node.calledProcess, .Inputs.M |
| timer | Api.FlowNodes.Node.timer (BpmnTimer) | Api.FlowNodes.node().getTimer() | Api.FlowNodes.Node.Timer | Api.FlowNodes.Node.timer |
| sequence flow | Api.FlowNodes.Node.next.<target>.flow (SequenceFlows<Target>, .flows when several lead there) | Api.FlowNodes.node().getNext().<target>().getFlow() | Api.FlowNodes.Node.Next.<Target>.Flow | Api.FlowNodes.Node.next.<target> (SequenceFlows) |
Only ServiceTasks.X is a plain string constant; a node's jobType refers to it but is no compile-time constant,
so annotations (@JobWorker(type = …)) always use ServiceTasks.X — a job type can be shared by several processes.
Every other member is a typed wrapper. A wrapper is not a drop-in for a String parameter — reach the raw string with .value
(Kotlin), .getValue() (Java) or .Value (C#).
In TypeScript only variables are wrapped (.value); ids, job types, message and signal names are string literal types that replace a string directly.
**/*ProcessApi*.kt, **/*ProcessApi*.java, **/*ProcessApi*.cs and **/*ProcessApi*.ts, plus the shared definition files next to them (ServiceTasks, Messages, Signals, Errors, Escalations with .kt / .java / .cs / .ts).// Generated by bpmn-to-code; C# files start with // <auto-generated/> followed by that line).$ARGUMENTS specifies a class name, filter to only that API. Otherwise, collect all generated API files.For each generated API file, extract a lookup table of string values mapped to their fully qualified API references, recording for each entry its nesting path and its value type:
object: const val NAME: String = "value" (plain string), val NAME: ElementId = ElementId("value"), MessageName("value"), SignalName("value"), ProcessId("value"), VariableName.Input("value") / .Output / .InOut, InputOutputMapping(target = "value", …). Nodes are the nested objects directly inside FlowNodes; their Variables, Inputs, Outputs objects hang on the node.final class: public static final String NAME = "value"; (plain string), public static final ElementId NAME = new ElementId("value"); and the same wrappers; node ids sit in the constructor super(new ElementId("value"), …) of each FlowNodes node class.static class: public const string Name = "value"; (plain string), which also holds each node's ElementId; a node is reached through the property FlowNodes.<Node>, typed by its class FlowNodes.<Node>Node, and its NodeVariables refer to ProcessVariables; global::Miragon.BpmnToCode.Runtime.InputOutputMapping Name { get; } = new("value", …) inside InputMappings / OutputMappings.readonly ELEMENT_ID = "value", readonly jobType = ServiceTasks.X, readonly calledProcess = "value"; the API is export const Api = { PROCESS_ID: "value", FlowNodes: { Node: Node.INSTANCE, … } } as const; variables holds Runtime.input(ProcessVariables.X) entries, Inputs / Outputs hold { target: "value", … }; shared definitions are export const Messages = { X: "value" } as const.ServiceTasks, Messages, Signals, Errors, Escalations), with the same constant shapes.BikeLeasingProcessApi.FlowNodes.ServiceTaskSendContract.Variables.APPLICATION_ID or ServiceTasks.MIRAVELO_SEND_CONTRACT.Skip composite values (BpmnTimer, BpmnErrorDefinition, BpmnEscalationDefinition, SequenceFlow) — they carry more than one string and are not direct replacements.
$ARGUMENTS contains a directory path, use that as the scan root.src/main/ in the project root.**/*.kt, **/*.java, **/*.cs and **/*.ts for whichever exist. In a TypeScript project the default scan root is src/, and *.test.ts / *.spec.ts count as tests.src/test/) unless the user explicitly requests test migration.For each string value in the lookup table from Step 2, use Grep to search for exact occurrences in the scoped files:
"<value>" (escaped appropriately for regex)."id", "name", "type") to avoid false positives..value / .getValue() / .Value when the surrounding code expects a string).@JobWorker(type = …), [JobType(…)]) or a switch label must map to ServiceTasks.X, never to a wrapper.Group the proposed replacements by file and present a summary table:
## Migration Plan
### src/main/kotlin/com/example/MyService.kt
| Line | Current | Replacement |
|------|---------|-------------|
| 24 | "bikeLeasing" | BikeLeasingProcessApi.PROCESS_ID |
| 31 | "applicationId" | BikeLeasingProcessApi.FlowNodes.ServiceTaskSendContract.Variables.APPLICATION_ID.value |
### src/main/kotlin/com/example/AnotherService.kt
| Line | Current | Replacement |
|------|---------|-------------|
| 12 | "miravelo.contractSigned" | Messages.MIRAVELO_CONTRACT_SIGNED |
**Imports to add:**
- `MyService.kt` → `import com.example.api.BikeLeasingProcessApi`
- `AnotherService.kt` → `import com.example.api.Messages`
**Total: 3 replacements across 2 files**
If a string value matches constants from multiple API classes and the context does not make it clear which process is intended, flag it and ask the user which reference to use. If a variable name is declared on several nodes, prefer the node whose element the surrounding code handles (a worker for ServiceTasks.X uses the node with jobType == X) and otherwise ask.
If no matches are found, report that no hardcoded strings were found that match the generated API.
Ask: "Apply these replacements? (yes / skip [file-or-line] / cancel)"
For each file in the approved plan:
import <package>.<ApiClassName>, Java import <package>.<ApiClassName>;, C# using <namespace>;, TypeScript import { <ApiName> } from "<relative path>/<ApiName>.js";) after the last existing import line../gradlew compileKotlin / ./gradlew compileJava, mvn compile, dotnet build, or npx tsc --noEmit.TypeScript output is new in 6.0, so Mode B only concerns Kotlin, Java and C#.
6.0 removed the Elements, Variables, CallActivities and Timers sections, flattened Flow and renamed it to FlowNodes; their content lives on the FlowNodes nodes. Consumer code that referenced them no longer compiles.
Locate the generated API files as in Mode A Step 1 and parse the current (6.0) node names from FlowNodes. Then Grep the scan scope — including src/test/, since process tests are the main consumer of element ids — for:
\b\w*ProcessApi\w*\.(Elements|Variables|CallActivities|Timers)\.import …ProcessApi.Elements.* and friends)Flow\.(\w+)\.(\w+)\. where the inner name is a node that is now a direct child of FlowNodes| 5.x | Kotlin | Java | C# |
|---|---|---|---|
Elements.X | FlowNodes.X.id | FlowNodes.x().getId() | FlowNodes.X.Id |
Elements.X.value | FlowNodes.X.id.value | FlowNodes.x().getId().getValue() | FlowNodes.X.Id.Value |
Variables.Node.V | FlowNodes.Node.Variables.V | FlowNodes.Node.Variables.V | FlowNodes.Node.Variables.V |
CallActivities.Node.PROCESS_ID | FlowNodes.Node.calledProcess | FlowNodes.node().getCalledProcess() | FlowNodes.Node.CalledProcess |
CallActivities.Node.Inputs.M / .Outputs.M | FlowNodes.Node.Inputs.M / .Outputs.M | same | FlowNodes.Node.Inputs.M |
Timers.T | FlowNodes.T.timer | FlowNodes.t().getTimer() | FlowNodes.T.Timer |
Flow.Sub.Inner / Flow.sub().inner() | FlowNodes.Inner | FlowNodes.inner() | FlowNodes.Inner |
Flow.Sub.Inner.Next::x (method refs) | FlowNodes.Inner.Next::x | same | — |
Flow.X (any other reference) | FlowNodes.X | FlowNodes.x() | FlowNodes.X |
Elements.X was named after the element id in UPPER_SNAKE (SERVICE_TASK_SEND_MAIL); the node is the same id in PascalCase (ServiceTaskSendMail). Match the two through the string value in the 5.x file if it is still available, otherwise fold the constant name (SERVICE_TASK_SEND_MAIL → ServiceTaskSendMail).
Flag, do not auto-rewrite:
const usages: Elements.X in a switch label or attribute needs the node's constant FlowNodes.XNode.ElementId, because FlowNodes.X.Id is an instance property. Propose ServiceTasks.X where the code actually meant a job type, otherwise ask.FlowNodes, Next, Start, SequenceFlows, Variables, Instance, … now fails the reserved-element-name rule; the model must be renamed before regeneration.Present the plan grouped by file exactly as in Mode A Step 5, confirm, apply with the Edit tool, and suggest the compile command. Also suggest regenerating the API first if the found files still contain a removed section — that means the generator has not been upgraded yet.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub miragon/bpmn-to-code --plugin bpmn-to-code8 skills in this plugin
/create-process-adapterAdds one call from the application to the process engine (start a process, correlate a message, send a signal, complete a user task) as an outbound port and process adapter method. Use when code has to start or continue a BPMN process./create-workerImplements one BPMN service task as a job worker, JavaDelegate or external-task handler that calls one use case, with names from the generated Process API. Use when a service task or job type needs code that handles it./generate-rule-to-enforce-bpmn-styleguideTurns one rule of a BPMN_STYLE_GUIDE.md into a Kotlin validation rule for bpmn-to-code-testing and registers it in the model validation test. Use when a modeling convention should be enforced in the build.Other plugins' skills for the same job