Let $M$ be a Riemannian manifold. Then I wish to define a vector field $Z=\operatorname{tr}((X,Y)\mapsto\nabla_X Y)$, or in coordinates, $$Z = g^{ij}\nabla_{\partial_i}\partial_j.$$ However, it doesn't seem obvious to me that this thing should be well-defined. Is there any reason that it would?
Edit: we define $g_{ij}(x)=g(\partial_i,\partial_j)$ and we define $g^{ij}$ to be the inverse matrix.
No, it's not well defined. For example, suppose $g$ is the Euclidean metric on $\mathbb R^2$. If you use the standard coordinate frame $(\partial_1,\partial_2)$, then $Z\equiv 0$ because $\nabla_{\partial_i}\partial_j =0$ for all $i,j$. But if you switch to, say, the polar coordinate frame $(\partial_r,\partial_\theta)$, then (if I haven't made a computational mistake) you have \begin{gather*} \nabla_{\partial_r}\partial_r=0, \quad \nabla_{\partial_\theta}{\partial_\theta} = -\frac{1}{r}\partial_r;\\ g^{rr} = 1, \quad g^{r\theta}=g^{\theta r}=0, \quad g^{\theta\theta} = \frac{1}{r^2}, \end{gather*} and therefore $$ g^{ij}\nabla_{\partial_i}\partial_j = -\frac{1}{r^3}\partial_r \ne 0. $$
A bilinear bundle map from $TM\times TM$ to some vector bundle has a well-defined trace (assuming we're on a Riemannian manifold). For example, if $M$ is a Riemannian submanifold of a larger Riemannian manifold $\widetilde M$, the second fundamental form is a bilinear bundle map from $TM\times TM$ to $NM$ (the normal bundle of $M$ in $\widetilde M$), and its trace is (up to a constant) the mean curvature vector field. Also, the torsion tensor of a connection is a bilinear bundle map from $TM\times TM$ to $TM$ (although its trace is always zero because it's skew-symmetric).
However, in the current situation, the connection is not a bundle map because it's not bilinear over $C^\infty(M)$.