If $f\in C^1$, how can we determine the weak derivative of $x\mapsto\min(1,f(x))$? Let $f\in C^1(\mathbb R)$ and $$g(x):=\min(1,f(x))\;\;\;\text{for }x\in\mathbb R.$$

How can we determine the weak derivative of $g$?

Let $\varphi\in C_c^\infty(\mathbb R)$ and $r\ge0$ with $$\varphi(x)=\varphi'(x)=0\;\;\;\text{for all }x\in\mathbb R\setminus B_r(0)\tag1.$$ By partial integration, $$\int\varphi'(x)f(x)\:{\rm d}x=\int_{-r}^r\varphi'(x)f(x)\:{\rm d}x=\int_{-r}^r-\varphi(x)f'(x)\:{\rm d}x=-\int\varphi(x)f'(x)\:{\rm d}x\tag2.$$ Now, I guess the trick is to write $$\int\varphi'g\:{\rm d}\lambda=\int_{\left\{\:f\:<\:1\:\right\}}\varphi'f\:{\rm d}\lambda+\int_{\left\{\:f\:\ge\:1\:\right\}}\varphi'\:{\rm d}\lambda,\tag3$$ where $\lambda$ is the Lebesgue measure on $\mathcal B(\mathbb R)$.
However, I don't know how to proceed from here. For the first integral on the right-hand side of $(3)$, we may need to write $\left\{f<1\right\}$ as a countable union of pairwise disjoint open intervals.
 A: Intuitively, if you take a generic $C^1$ function $f$ and think about $g(x) = \min(1,f(x))$, then the "derivative" of $g$ should be $0$ wherever $f(x) > 1$ (since $g(x)$ is constant on such a set) and $f'(x)$ wherever $f(x) < 1$ (since $g(x) = f(x)$ there). Such a function can be written in the form $f'1_{\{f < 1\}}$, where $1_E$ denotes the indicator function of $E$. The task at hand is to verify this intuition.
You are basically almost there with (3) (which holds for an arbitrary test function $\varphi$, not just those satisfying your hypotheses). You are correct in that you essentially want to identify $\{f < 1\}$ as a countable union of open intervals (which can be done since $f\in C^1$). So say that $\{f < 1\} = \bigcup_i (a_i,b_i)$.  If you now integrate by parts (which is pretty much always what you should try when finding weak derivatives), you see that
$$
\int_{\{f < 1\}} \varphi'g = \sum_i \int_{a_i}^{b_i} \varphi'f = \sum_i \varphi(x)\bigg|_{a_i}^{b_i} - \int_{a_i}^{b_i} \varphi f'
$$
where we have used that $f(a_i) = f(b_i) = 1$. Since $\{f > 1\}$ is the complement of $\{f < 1\}$, it must be equal to $\bigcup_i [b_i,a_{i+1}]$. By the fundamental theorem of calculus,
$$
\int_{\{f \geq 1\}} \varphi'g = \sum_i \int_{b_i}^{a_{i+1}} \varphi' = \sum_i \varphi(x)\bigg|_{b_i}^{a_{i+1}}.
$$
Now note that if we add these two together, then the sums $\sum_i \varphi(x)\big|_{a_i}^{b_i}$ and $\sum_i \varphi(x)\big|_{b_i}^{a_{i+1}}$ cancel exactly. Therefore you are left with
$$
\int \varphi'g = -\sum_i \int_{a_i}^{b_i} \varphi f' = -\int \varphi f'1_{\{f < 1\}},
$$
which shows that $g' = f'1_{\{f<1\}}$ in the sense of weak derivatives, as claimed.
