I have a specific question about defining the composition in (locally) ringed spaces.
The definition I had formulated myself while reading Hartshorne, since he conveniently neglected to suggest any such definition, was identical to
https://math.stackexchange.com/a/611617/299525
The $g_* (f^\#)$ is somewhat strange at first, but when one writes down all the domains and codomains and tries to draw the arrows, it works out very nicely. However, I just now observed that the Stacks Project has what I would have guessed would be the correct definition initially, namely $f^\# \circ g^\#$. Yet attempting to draw the arrows has a clear mismatch.
$$g^\# : \mathcal{O}_Z \to g_* \mathcal{O}_Y$$
while
$$f ^\#: \mathcal{O}_X \to f_* \mathcal{O}_X$$
Can one somehow identify $g_* \mathcal{O}_Y$ or is the Stacks Project assuming that its reader will identify $f^\# \circ g^\#$ as $g_* (f^\#) \circ g^\#$?
Let $(X,\mathcal{O}_X)$, $(Y,\mathcal{O}_Y)$ and $(Z,\mathcal{O}_Z)$ be locally ringed spaces, let $(f,f^{\sharp}):X\to Y$ and $(g,g^{\sharp}):Y\to Z$ be morphisms of locally ringed spaces.
One can define $f^{\sharp}\circ g^{\sharp}=(g\circ f)^{\sharp}$ as the unique morphism of sheaves such that: \begin{equation*} \forall x\in X,\,(g\circ f)^{\sharp}_x=(f^{\sharp}\circ g^{\sharp})_x=f_x^{\sharp}\circ g_{f(x)}^{\sharp} \end{equation*} where $f^{\sharp}_x:\mathcal{O}_{Y,f(x)}\to\mathcal{O}_{X,x}$ and $g^{\sharp}_{f(x)}:\mathcal{O}_{Z,g(f(x))}\to\mathcal{O}_{Y,f(x)}$ are the morphisms of local rings induced, respectively, from $f^{\sharp}$ and $g^{\sharp}$ between the stalks of $\mathcal{O}_X$, $\mathcal{O}_Y$ and $\mathcal{O}_Z$.