This paper introduces a facile strategy to fabricate trifunctional electocatalysts through one pool treatment on MOFs to obtain carbon nanotube coated ultrafine CoNi alloy (CoNi@NCNTs) nanocomposites with N-doped rich-defect and abundant cavity structure. During the pyrolysis process, volatile CNx species from dicyandiamide were trapped by ZIF-67@Ni-ZIF nanosheets, simultaneously introducing nitrogen atom into carbon matrix to achieve the rich-defect porous nanotubes and abundant cavity structure. The as-prepared nanomaterials can simultaneously boost the ORR, OER and HER catalytic activity with strong durability. Significantly, the CoNi@NCNTs-700 exhibits excellent electrocatalytic activity including half-wave potential (EORR, 1/2) of 0.80 V, lower operating voltage (EOER, 10) of 1.60 V at 10 mA cm−2 and potential difference (ΔE) of 0.80 V between EOER, 10 to EORR, 1/2 in 0.1 M KOH, and low overpotential (EHER, 10) of −0.130 V reaching 10 mA cm−2 in acidic medium. The remarkable activity is ascribed to defect-rich porous carbon nanotubes structure and the synergistic effect between CoNi alloy nanoparticles, N-dope carbon and CoNi-Nx. And hollow structure facilitates to improve conductivity and stability. This work offers a useful archetypical template to design and construct efficient and stable trifunctional electrocatalysts, illustrating its viability for practical applications of energy conversion and storage devices.