I'm not sure I totally understand your use case completely, if the users can develop whatever they want then why use a CMS? Why not give them access to the code directly?
However, if you want to add the functionality you've described you can follow the guide here: