[guided]We have arrived at the pointwise identity (P), namely $g(\nabla_{e_j} X_\theta, e_i) = \langle \nabla_{e_j}\theta, e_i\rangle$, valid for every pair $i, j \in \{1, \ldots, n\}$ on $U$. It remains to extract the codifferential formula. The previous step did most of the geometry; this step is a contraction.
How do we recover the codifferential $\delta\theta$, which from (V) equals $-\sum_k g(\nabla_{e_k} X_\theta, e_k)$? The sum on the right pairs the index of differentiation with the index in the metric — both are $k$. Looking at (P), this is precisely the diagonal $i = j = k$. So we set $i = j = k$ in (P) and sum over $k = 1, \ldots, n$:
\begin{align*}
\sum_{k=1}^n g(\nabla_{e_k} X_\theta, e_k) = \sum_{k=1}^n \langle \nabla_{e_k}\theta, e_k\rangle.
\end{align*}
This is identity ($\star$). Note that (P) is a stronger pointwise statement than ($\star$) — it asserts equality for *every* pair $(i, j)$, not just on the diagonal — but we only need the diagonal here, since the trace of an endomorphism in an orthonormal basis is the diagonal sum.
Why is this frame-independent, despite our use of a particular orthonormal frame $\{e_k\}$? The diagonal sum $\sum_k \langle \nabla_{e_k}\theta, e_k\rangle$ is the metric trace $\operatorname{tr}_g(\nabla\theta)$ of the $(0,2)$-tensor $\nabla\theta$. In a general frame, $\operatorname{tr}_g(\nabla\theta) = g^{kl}(\nabla_{e_k}\theta)(e_l)$ with the metric inverse $g^{kl}$ supplying the change-of-frame correction; for an orthonormal frame, $g^{kl} = \delta^{kl}$ and the formula collapses to the diagonal. Likewise for $\sum_k g(\nabla_{e_k} X_\theta, e_k) = \operatorname{tr}(\nabla X_\theta) = \operatorname{div}(X_\theta)$, which is intrinsically defined.
Substituting ($\star$) back into the divergence formula (V) from the first step,
\begin{align*}
\delta\theta = -\sum_{k=1}^n g(\nabla_{e_k} X_\theta, e_k) = -\sum_{k=1}^n \langle \nabla_{e_k}\theta, e_k\rangle.
\end{align*}
This is the asserted local formula for $\delta\theta$ on $U$. Since every point of $M$ lies in some open set $U$ admitting a local orthonormal frame, the formula holds pointwise on all of $M$.
A brief retrospective on the mechanism. The proof passed the covariant derivative across the metric duality $\theta \leftrightarrow X_\theta$ via three coordinated rules: metric compatibility ($\nabla g = 0$) on the geometric side, the tensor Leibniz rule on the analytic side, and the duality identity $g(X_\theta, V) = \langle\theta, V\rangle$ applied to $V = \nabla_{e_j} e_i$ to cancel the "extra" frame-derivative terms. This cancellation is what converts a frame-dependent computation into the frame-independent identity ($\star$). Conceptually, the metric duality $\flat: \mathfrak{X}(M) \to \Omega^1(M)$ is parallel ($\nabla\flat = 0$ as a tensor, since $\flat$ is built from $g$ and $\nabla g = 0$), so differentiation commutes with raising and lowering indices.
A sanity check: in flat $\mathbb{R}^n$ with the standard Euclidean frame $e_k = \partial_{x_k}$, the Christoffel symbols $\Gamma^l_{jk}$ vanish, so $\nabla_{e_k}\theta = \partial_{x_k}\theta$ component-wise. If $\theta = \sum_k \theta_k\, dx_k$, then $\langle \nabla_{e_k}\theta, e_k\rangle = \partial_{x_k}\theta_k$, and
\begin{align*}
\delta\theta = -\sum_k \partial_{x_k}\theta_k = -\operatorname{div}(\theta^\sharp),
\end{align*}
the familiar Euclidean divergence (up to sign) of the metric-dual vector field, in agreement with the [Codifferential and Divergence](/theorems/2755) identity invoked in the first step.[/guided]