If $f$ and $g$ are separated, then this is a special case of Lemma \ref{lemma-f-shriek-composition}. If $g$ is separated, then this is a special case of Lemma \ref{lemma-lqf-separated-shriek-composition} which moreover agrees with the case where $f$ and $g$ are separated. \medskip\noindent Construction in the general case. Choose an open covering $Y = \bigcup Y_i$ such that the restriction $g_i : Y_i \to Z$ of $g$ is separated. Set $X_i = f^{-1}(Y_i)$ and denote $f_i : X_i \to Y_i$ the restriction of $f$. Also denote $h = g \circ f$ and $h_i : X_i \to Z$ the restriction of $h$. Consider the following diagram $$ \xymatrix{ \bigoplus\nolimits_{i_0, i_1} h_{i_0i_1, !}\mathcal{F}|_{X_{i_0i_1}} \ar[r] \ar[d] & \bigoplus\nolimits_{i_0} h_{i_0, !}\mathcal{F}|_{X_{i_0}} \ar[r] \ar[d] & h_!\mathcal{F} \ar[r] \ar@{..>}[dd] & 0 \\ \bigoplus\nolimits_{i_0, i_1} g_{i_0i_1, !} f_{i_0i_1, !}\mathcal{F}|_{X_{i_0i_1}} \ar[r] \ar[d] & \bigoplus\nolimits_{i_0} g_{i_0, !} f_{i_0, !}\mathcal{F}|_{X_{i_0}} \ar[d] \\ \bigoplus\nolimits_{i_0, i_1} g_{i_0i_1, !} (f_!\mathcal{F})|_{Y_{i_0i_1}} \ar[r] & \bigoplus\nolimits_{i_0} g_{i_0, !} (f_!\mathcal{F})|_{Y_{i_0}} \ar[r] & g_!f_!\mathcal{F} \ar[r] & 0 } $$ By Lemma \ref{lemma-lqf-colimit-f-shriek} the top and bottom row in the diagram are exact. By Lemma \ref{lemma-lqf-separated-shriek-composition} the top left square commutes. The vertical arrows in the lower left square come about because $(f_!\mathcal{F})|_{Y_{i_0i_1}} = f_{i_0i_1, !}\mathcal{F}|_{X_{i_0i_1}}$ and $(f_!\mathcal{F})|_{Y_{i_0}} = f_{i_0, !}\mathcal{F}|_{X_{i_0}}$ as the construction of $f_!$ is local on the base. Moreover, these equalities are (of course) compatible with the identifications $((f_!\mathcal{F})|_{Y_{i_0}})|_{Y_{i_0i_1}} = (f_!\mathcal{F})|_{Y_{i_0i_1}}$ and $(f_{i_0, !}\mathcal{F}|_{X_{i_0}})|_{Y_{i_0i_1}} = f_{i_0i_1, !}\mathcal{F}|_{X_{i_0i_1}}$ which are used (together with the covariance for open embeddings for $Y_{i_0i_1} \subset Y_{i_0}$) to define the horizontal maps of the lower left square. Thus this square commutes as well. In this way we conclude there is a unique dotted arrow as indicated in the diagram and moreover this arrow is an isomorphism. \medskip\noindent Proof of properties (1) -- (5). Fix the open covering $Y = \bigcup Y_i$. Observe that if $Y \to Z$ happens to be separated, then we get a dotted arrow fitting into the huge diagram above by using the map of Lemma \ref{lemma-lqf-separated-shriek-composition} (by the very properties of that lemma). This proves (2) and hence also (1) by the compatibility of the maps of Lemma \ref{lemma-lqf-separated-shriek-composition} and Lemma \ref{lemma-f-shriek-composition}. Next, for any scheme $Z'$ over $Z$, we obtain the compatibility in (5) for the map $(g' \circ f')_! \to g'_! \circ f'_!$ constructed using the open covering $Y' = \bigcup b^{-1}(Y_i)$. This is clear from the corresponding compatibility of the maps constructed in Lemma \ref{lemma-lqf-separated-shriek-composition}. In particular, we can consider a geometric point $\overline{z} : \Spec(k) \to Z$. Since $X_{\overline{z}} \to Y_{\overline{z}} \to \Spec(k)$ are separated maps, we find that the base change of $(g \circ f)_!\mathcal{F} \to g_! f_! \mathcal{F}$ by $\overline{z}$ is equal to the map of Lemma \ref{lemma-f-shriek-composition}. The reader then immediately sees that we obtain property (3). Of course, property (3) guarantees that our transformation of functors $(g \circ f)_! \to g_! \circ f_!$ constructed using the open covering $Y = \bigcup Y_i$ doesn't depend on the choice of this open covering. Finally, property (4) follows by looking at what happens on stalks using the already proven property (3).