Ximen Bao became well known in his lifetime and posthumously for his grandiose works in hydraulic engineering during the 5th century BC. He organized a massive diversion of the Zhang River (漳河), which had formerly flowed into the Huang He River at Anyang. The new course that the river took under his diversion project brought the river to meet the Huang He further down its course at a bend near modern-day Tianjin. The Zhang River rises in the mountains of Shanxi province, flowing southeastwards, and at the time added to the burden of overflow for the Huang He. Ultimately though, the purpose of this enormous project of engineering was to irrigate a large agricultural region of Henei (in the left lower Huang He basin) by providing it with a natural contour canal.
Work on the canal system began sometime between 403 BC and 387 BC, when Marquis Wen and his successor Marquis Wu reigned over the State of Wei. Due to several setbacks (including some temporary local resistance to corvee labor service) it was not fully completed until a century later, during the time of Wen's grandson, King Xiang (襄王) (319 BC-296 BC). It was during this time that the Wei engineer Shi Chi completed the work of Ximen Bao.
In honor of the Zhang River diversion project, the local populace made a popular song about it, as recorded in the historical work of the later Han Dynasty historian Ban Gu.