In situ engineering highly active and ultrastable bi-functional electrocatalysts based on metal ions from transition metal alloys that are simultaneously suitable for hydrogen evolution reaction (HER) and oxygen evolution reaction (OER) is one of the key unresolved challenges on the way to energy-efficient hydrogen fuel production by water splitting. One such novel catalyst based on polyhedron N-doped Ni-Co phosphide is burgeoned directly from the Ni-Co foam (N-NiCoP/NCF) using a facile and eco-friendly approach without involving heavy metal ions. The N-NiCoP/NCF catalyst exhibits superior activity in 1.0 M KOH for overall water splitting, evidenced by the low overpotentials of 78 mV for HER and 225 mV for OER at a current density of 10 mA cm-2. The excellent electrocatalytic activity of N-NiCoP is attributed to the increased Fermi level due to effective N-doping and the abundant exposed active crystal planes (311) of heterostructured Co2NiP4 phase. Importantly, the N-NiCoP/NCF catalyst shows ultra-stable electrocatalytic performance while retaining structural integrity in both HER and OER processes during continuous reactions for over 100 h. These results open new avenues for in situ engineering of transition-metal based electrocatalysts used for renewable energy generation.