The below code snippet can be used to only load CommandUI for a specific user ID (1
here).
/**
* Disable CommandUI for all users, unless they have a specific user ID.
*/
add_filter('commandui/load-js', function () {
// CHANGE HERE
return get_current_user_id() === 1; // <-- Change this to the user ID you want to allow
});