Best practice for creating process programmatically

There exists two community projects that allow you to create diagrams using higher level APIs:

Both use the core modeling facilities @philippfromme mentioned under the hood.

You can use the Modeling API without abstractions, too:

var bpmnModeler = new BpmnModeler(...);

var modeling = bpmnModeler.get('modeling');
var elementRegistry = bpmnModeler.get('elementRegistry');

// remove shape with ID 'some
modeling.removeElements([ elementRegistry.get('someTask') ]);