The heat transfer performance and friction loss of two-pass ribbed channels are highly influenced by the combined effect of rib orientation and bend shape. This paper, for the first time, numerically investigates this effect for four rib orientations, two rib angles and eight different bend shapes at Reynolds number of 30000. The results show that rib orientation determines the rotation direction and the transverse position of secondary flow in straight passages, while bend shape determines the delivery of upstream secondary flow and the generation of local secondary flow. The key to heat transfer enhancement in the second passage is to promote local secondary flow using energy from upstream secondary flow with the same rotation direction. The upstream secondary flow with the same rotation direction should be guided to a proper position, in order to enhance the dominant secondary flow in the second passage and reduce energy loss due to the undesirable secondary flow interaction. The impact of different bend shape on the secondary flow has been summarized. The round inner corner for the bend is preferred for the significant friction loss reduction and the excellent secondary flow energy delivery capacity. Meanwhile, the secondary flow generated by the square outer corner can significantly enhance the cooling performance at the entrance of the second passage for some certain rib orientations. An optimized combination of 60-degree rib orientation and bend shape can either thermal performance factor by 10 % in the second passage or reduce the friction loss by 22.3 % in the whole channel, compared with the existing experimental design. By contrast, it is found cooling performance and pressure loss are not sensitive to bend shape for the rib angel of 45-degree. The optimized bend shape is inspired by an intuitive visualization of secondary flow evolution, which provides insight on the geometry optimization for heat and mass transfer applications.