Add a cli when parent container is configured

container parent {
  <enter into a submode>
   leaf child1 {
      type empty;
   }

   container child2 {
      container child3 {
         leaf grandchild {
            type empty;
         }
      }
   }
} 

when "parent child1 " is added, I want “child2 child3 grandchild” to be added automatically.

If human-to-machine CLI tinkering is your focus, then you can use hooks.

If your use case is also NETCONF RESTCONF and service automation, when “automagically” changing the config that you expose to northbound interfaces for service deployment you will cause managers that are doing automation using machine-to-machine communication over, for example, NETCONF or RESTCONF, to get out-of-sync all the way to their service. That’s often difficult to resolve for a manager.

See ConfD UG, chapter “Transformations, Hooks, Hidden Data and Symlinks” and examples.confd/intro/11-c_hooks