The simplest case is when a piece of code does not have any branches or recursion, and just pushes literals and calls words.
Pushing a literal has stack effect ( -- x ). The stack effect of most words is always known statically from the declaration. Stack effects of inline words and Macros, may depend on literals pushed on the stack prior to the call, and this case is discussed in Combinator stack effects.
The stack effect of each element in a code snippet is composed. The result is then the stack effect of the snippet.