could anyone please explain or show some simple steps how using matter action: $S = \int d^4x \sqrt{-g} L(X, \phi)$, where $X = \frac{1}{2} g^{\mu \nu} \nabla_\mu \phi \nabla_\nu \phi$
We can derive energy-momentum tensor: $T_{\mu \nu} = \frac{2}{\sqrt{-g}} \frac{\delta S}{\delta g^{\mu \nu}}$
I understand that we should take variation of action $\delta S$ with respect to $g^{\mu \nu}$ , but I don't understand how to fit X into $L(X, \phi)$ Can I just put instead of $L(X, \phi)$, $X = \frac{1}{2} g^{\mu \nu} \nabla_\mu \phi \nabla_\nu \phi$, into action and take variation or there is anything more in the process ? Am I wrong about my variant of just putting X into action ?