Trajectory design of sidetrack horizontal well is faced with bypassing obstacles in cluster wells which makes the design process more complicated. The obstacle is assumed to be drilled trajectory sections such as vertical section and directional section, then they are described as a part of cylinder and annulus. Trajectory type for bypassing obstacle is classified based on geometrical relationship between tangent line of sidetrack point, tangent line of target point and axis of obstacle. The objective function is minimizing the total trajectory energy and the constraints include the safety distance to obstacle and the maximum build rate and maximum turn rate. Teaching-learning Cuckoo Search algorithm has been proposed to solve the established model. Case studies have been carried out according to different trajectory type, the results indicate that the proposed method can obtain sidetrack trajectory with minimum trajectory energy, in the meanwhile, the trajectory can avoid collision with obstacle and the wellbore curvatures are appropriate, the new method avoid trial calculation, it is also applicable to other types of sidetrack well trajectory for bypassing obstacles.