Counter Term Feynman Rules
A counter term in a Lagrangian is interpreted as an interaction, and the Feynman rules may be derived by the Feynman path integral in the standard way. This accounts for the factor of $i$ and the functional derivatives will take care of the factor of $\frac12$.
Just like in $\frac{\lambda}{4!}\phi^4$ theory we have a $-i\lambda$ Feynman rule, with $\frac{\delta_m}{2}\phi^2$ we have a $-i\delta_m$ Feynman rule. In addition, derivatives of fields give rise to momenta: $(\partial \phi)^2 \mapsto p^2$. So the overall counter term is,
$$i(p^2\delta_Z-\delta_m).$$
The key is, if in doubt, always check things explicitly by treating the terms as interactions in the Feynman path integral.
Alternative Method
I highly recommend Collins' book on renormalisation for a method of renormalisation which dispenses with a Lagrangian and is ideal for systematically computing diagrams. This involves a combination of the BPHZ method and dimensional regularisation.
Essentially, the Zimmermann forest formula generates all the counter term graphs. Then instead of inserting Feynman rules, you insert a particular 'subtraction' operator to remove the divergences.
Of course, this can be related back to a Lagrangian by considering what the Feynman rules would read, and equating the two results to find the counter terms to whatever order you need.