The rule of thumb for determining the number of covalent bonds an atom can perform is to look at the number of valence electrons the atom has. Valence electrons are the electrons in the outermost shell of an atom, and they are the electrons that participate in chemical bonding. The number of covalent bonds an atom can form is usually equal to the number of valence electrons it has. For example, carbon has four valence electrons, so it can form four covalent bonds. Nitrogen has five valence electrons, so it can form five covalent bonds. Oxygen has six valence electrons, so it can form six covalent bonds.
There are some exceptions to this rule of thumb. For example, hydrogen can only form one covalent bond, even though it has one valence electron. This is because hydrogen has only one electron shell, and the electron in this shell is not shared with any other atom. Also, some atoms can form more covalent bonds than they have valence electrons by using their d-orbitals. This is called "hybridization." For example, carbon can form four covalent bonds using its four valence electrons, but it can also form five covalent bonds by using its d-orbitals.