In response to the escalating demand for precise shape metrology of complex optical surfaces, this study unveils a unified geometric error compensation and trajectory planning framework tailored for high-accuracy five-axis scanning metrology systems, which remains a notably underexplored field compared to error compensation in machine tools. Founded on a unified geometric model, the proposed framework seamlessly integrates a versatile shape-adaptive trajectory planning strategy, a thorough global error sensitivity analysis approach, and an exhaustive geometric error compensation scheme. Leveraging inverse kinematics, an innovative shape-adaptive scanning trajectory generation strategy is mathematically formulated, thereby facilitating adaptable measurement trajectory generation for diverse surface geometries. Employing forward kinematics, an exhaustive geometric error model is established to extensively address the 53 distinct geometric errors in the metrology system. This proposed error model fundamentally augments conventional geometric error models in machine tool by managing not only the geometric errors from the motion system, but also those from the probe and workpiece. To streamline the error compensation procedure, a novel global error sensitivity analysis approach is introduced, identifying both system-oriented and process-oriented sensitive geometric errors for targeted compensation. Experimental validation using a standard ball, which achieved an exceptional 89.35% reduction in the root mean square (RMS) of the measurement errors, further confirms the feasibility and effectiveness of the proposed framework. By offering an universal trajectory planning, sensitivity analysis and error compensation trinity for five-axis scanning metrology systems, this study sets the stage for precision advancements and design optimization across diverse configurations of metrology systems.