A method for planning a minimally invasive robotic insertion of an intervertebral rod into rod clamping vertebral screws attachable to vertebrae of a patient, comprising: using a preoperative surgical plan defining positions and orientations for inserting screws into a plurality of vertebrae of a subject's spine as well as a target curvature profile, each of the screws having a head; calculating a shape of the rod that will connect the heads of the screws; determining whether one or more osteotomies are required to permit percutaneous insertion of the rod, such that manipulation of a proximal end of the rod having the calculated shape enables a distal end of the rod to pass sequentially through the heads of the screws; when no osteotomy is required: providing instructions for insertion of the screws in the defined positions and orientations, providing information for forming the rod having the calculated shape, and providing instructions for robotic insertion of the rod; or when one or more osteotomies are required: adjusting the plan by updating at least one of the position and orientation of at least one of the screws to yield an updated screw configuration; recalculating the shape of the rod to match the updated screw configuration; determining whether each of the one or more osteotomies is still required to permit percutaneous insertion of the rod have the recalculated rod shape; and repeating the steps of adjusting the plan and recalculating the rod shape until fewer than all of the one or more osteotomies are required to permit percutaneous insertion of the rod having the recalculated rod shape. using a preoperative surgical plan defining positions and orientations for inserting screws into a plurality of vertebrae of a subject's spine as well as a target curvature profile, each of the screws having a head; calculating a shape of the rod that will connect the heads of the screws; determining whether one or more osteotomies are required to permit percutaneous insertion of the rod, such that manipulation of a proximal end of the rod having the calculated shape enables a distal end of the rod to pass sequentially through the heads of the screws; when no osteotomy is required: providing instructions for insertion of the screws in the defined positions and orientations, providing information for forming the rod having the calculated shape, and providing instructions for robotic insertion of the rod; or providing instructions for insertion of the screws in the defined positions and orientations, providing information for forming the rod having the calculated shape, and providing instructions for robotic insertion of the rod; or when one or more osteotomies are required: adjusting the plan by updating at least one of the position and orientation of at least one of the screws to yield an updated screw configuration; recalculating the shape of the rod to match the updated screw configuration; determining whether each of the one or more osteotomies is still required to permit percutaneous insertion of the rod have the recalculated rod shape; and repeating the steps of adjusting the plan and recalculating the rod shape until fewer than all of the one or more osteotomies are required to permit percutaneous insertion of the rod having the recalculated rod shape. adjusting the plan by updating at least one of the position and orientation of at least one of the screws to yield an updated screw configuration; recalculating the shape of the rod to match the updated screw configuration; determining whether each of the one or more osteotomies is still required to permit percutaneous insertion of the rod have the recalculated rod shape; and repeating the steps of adjusting the plan and recalculating the rod shape until fewer than all of the one or more osteotomies are required to permit percutaneous insertion of the rod having the recalculated rod shape.