Proton exchange membrane (PEM) water electrolysis is considered as a promising and sustainable solution for energy storage and hydrogen production. The dynamic behaviors of gas bubble in microchannels have an important impact on the gas/liquid two-phase transport process during electrochemical reaction, consequently affect the performance and efficiency of PEM water electrolyzers. This paper aims to investigate and understand the phenomena of bubble detachment in microchannels during the operation of PEM water electrolyzers. The detachment process is captured in-situ/operando, and the four stages of bubble detachment are qualitatively analyzed. Three-dimensional numerical simulation is conducted to study the dynamics of bubble detachment in a Poiseuille flow of microchannel. A strategy of determine the critical flow velocity, pressure drop, and power consumption of bubble detachment in a microchannel with consideration of main forces acting on a bubble during detaching process is developed. The simulation results reveal that various factors, including the contact angle, microchannel size, and the shape and parameters of the upper wavy wall, significantly influence the behavior of bubble detachment and the associated power consumption. Based on these findings, a design strategy is proposed to enhance bubble detachment efficiency in microchannels. The suggested approach involves the implementation of a rectangular upper wavy wall with appropriate wavelength and amplitude, resulting in the lowest power consumption during the bubble detachment process. The present analysis results provide a better understanding of bubble dynamics behaviors and offer practical insights for optimizing the design of microchannels in PEM water electrolyzers.