Reading CGTF basis from Basis Set Exchange site
Yes it is correct that for $p$-type basis functions that you have all three $p$-functions, i.e. $p_x$, $p_y$, $p_z$.

For basis functions of larger angular momentum, you are also correct that there is two "different" conventions. The cartisean coordinate and the spherical coordinate convention.

In many electronic-structure programs both conventions are used, since the integrals are calculated in cartisean coordinates and then afterwards transformed to spherical coordinates, i.e. as you stated for $d$-type functions going from 6 basis functions to 5 basis functions.

In regard to make you own electronic-structure code, I would recommend keeping everything in cartisean coordinates, because this will make your life simpler. (Keep in mind that if you compare you energy with from a Hartree-Fock calculation with other programs you will have a slightly lower energy, because you have 1 more $d$-type basis function).

For a simple electronic-structure program a very nice guide for molecular integrals can be found here, http://joshuagoings.com/2017/04/28/integrals/