  In the setting of finite-dimensional $\mathrm{RCD}(K,N)$ spaces, we
characterize the $p$-Sobolev spaces for $p\in(1,\infty)$ and the space of
functions of bounded variation in terms of the short-time behaviour of the heat
flow. Moreover, we prove that Cheeger $p$-energies and total variations can be
computed as limits of nonlocal functionals involving the heat kernel.
