Atomic force microscopy (AFM) mechanical-based lithography attracts much attention in nanomanufacturing due to its advantages of low cost, high precision and high resolution. However, debris effects during mechanical lithography often lead to an unstable machining process and inaccurate results, which limits further applications of AFM-based lithography. There is a lack of a real-time debris detection approach, which is the prerequisite to eventually eliminating the influence of the debris, and of a method that can solve the above problems well. The ultrasonic vibration (USV)-assisted AFM has the ability to sense the machining depth in real time by detecting the phase shifting of cantilever. However, whether the pile-up of debris affect the phase response of cantilever is still lack of investigation. Therefore, we analyzed the mechanism of the debris effect on force control mode and investigated the relationship between phase shifting and pile-up of debris. Theoretical analysis and experimental results reveal that the pile-up of debris have negligible effect on phase shifting of cantilever. Therefore, the phase shifting-based method can detect the debris effect on machining depth in force control mode of AFM machining.