Solution (source code)

= Solution

Write $\mathcal D=\bar N^{-1}\partial_t$, $\bar\Pi=\mathcal D\bar\phi$ and $\Delta=a^{-2}\nabla^2$. Since the background scalar has no spatial gradient,
$$
\delta\Pi=\mathcal D\delta\phi-\bar\Pi\Psi,\qquad
\boxed{\delta\rho=\bar\Pi\mathcal D\delta\phi-\bar\Pi^2\Psi+V_{,\phi}\delta\phi,
\quad u=\bar\Pi\delta\phi,\quad J_i=-\partial_i u.}
$$
Also $\delta P=\bar\Pi\mathcal D\delta\phi-\bar\Pi^2\Psi-V_{,\phi}\delta\phi$. These are the linearized <scalar-field matter projections>; gradient energy first contributes quadratically.

There is a source convention defect in the shear formula. For the stated positive shift $N_i=a^2B_{,i}$ and spatial metric with $+2E_{,ij}$, direct substitution into the <extrinsic curvature> gives the <positive-shift scalar shear convention>
$$
\chi_+=\frac{a^2}{\bar N}(B-\dot E),\qquad
K^i{}_j=-H\delta^i{}_j+(\mathcal D\Phi+H\Psi)\delta^i{}_j+\partial^i\partial_j\chi_+,
$$
$$
\boxed{\kappa=\delta K=3(\mathcal D\Phi+H\Psi)+\Delta\chi_+.}
$$
There is no extra Laplacian in the definition of $\chi_+$. Equivalently use $\chi=-\chi_+$: then the trace-free term has the printed minus sign and $\kappa=3(\mathcal D\Phi+H\Psi)-\Delta\chi$. This latter convention retains the printed momentum-constraint form. The source mixes these two choices.

At first order $\delta(K^2)=-6H\kappa$ and $\delta(K^i{}_jK^j{}_i)=-2H\kappa$. Combining their difference with $\delta{}^{(3)}R=4\Delta\Phi$ gives
$$
\boxed{\Delta\Phi-H\kappa=4\pi G\delta\rho.}
$$
For the <momentum constraint>, differentiating the tensor above gives
$$
\partial_j\delta K^j{}_i-\partial_i\delta K
=-\frac23\partial_i(\kappa-\Delta\chi_+)
=-8\pi G\partial_i u.
$$
For nonzero Fourier wavenumber, and absorbing the homogeneous integration mode into the background, \b[the consistent <momentum constraint> is]
$$
\boxed{\kappa-\Delta\chi_+=12\pi Gu,
\qquad\text{or}\qquad\kappa+\Delta\chi=12\pi Gu.}
$$

Linearizing the scalar equation, the shift-advection term and lapse-gradient times scalar-gradient term vanish at this order because the background is spatially homogeneous. The remaining equation is
$$
\mathcal D\delta\Pi-\Psi\mathcal D\bar\Pi+3H\delta\Pi-\kappa\bar\Pi-\Delta\delta\phi+V_{,\phi\phi}\delta\phi=0.
$$
Insert $\delta\Pi$, differentiate its lapse term, and use $\mathcal D\bar\Pi+3H\bar\Pi=-V_{,\phi}$. The two background-acceleration terms combine into $2\Psi V_{,\phi}+3H\bar\Pi\Psi$. Hence \b[the <perturbed Klein-Gordon equation with background lapse> is]
$$
\boxed{\frac{\delta\ddot\phi}{\bar N^2}
+\left(3H-\frac{\dot{\bar N}}{\bar N^2}\right)\frac{\delta\dot\phi}{\bar N}
-\Delta\delta\phi+V_{,\phi\phi}\delta\phi
-\frac{\dot{\bar\phi}}{\bar N}\left(\kappa+\frac{\dot\Psi}{\bar N}-3H\Psi\right)
+2\Psi V_{,\phi}=0.}
$$
This scalar evolution equation and the <Hamiltonian constraint> agree with the displayed targets after the shear conventions are repaired.