While proving $\operatorname{cos}(x+y)=\operatorname{cos}(x)\operatorname{cos}(y)-\operatorname{sin}(x)\operatorname{sin}(y)$
by this $$\operatorname{sin}(x+y)=\operatorname{sin}(x)\operatorname{cos}(y)+\operatorname{cos}(x)\operatorname{sin}(y) \\ \text{differentiating both sides w.r.t } x \\ \operatorname{cos}(x+y) \left(1+\frac{dy}{dx}\right)=(\operatorname{cos}(x)\operatorname{cos}(y)-\operatorname{sin}(x)\operatorname{sin}(y))\left(1+\frac{dy}{dx}\right)\\ \text{for $\frac{dy}{dx} \neq -1$}\\\operatorname{cos}(x+y)=\operatorname{cos}(x)\operatorname{cos}(y)-\operatorname{sin}(x)\operatorname{sin}(y) $$ Now I am confused what happens when$\frac{dy}{dx} = -1$
If all you want to do is derive $$\cos(x+y)=\cos(x)\cos(y)-\sin(x)\sin(y)$$ from $$\sin(x+y)=\sin(x)\cos(y)+\cos(x)\sin(y)$$ then you actually don't really care about the case where $\frac{dy}{dx}=-1$ - the implication only uses any single evaluation of this general derivative. You could get the same result by differentiating treating $x$ as constant or $y$ as constant or taking $y=x+c$. The only case that wouldn't work is if you tried to derive this taking $x+y$ to be constant.
A bit more justified would be to take a total derivative of this expression; you would get: $$d\sin(x+y) = \cos(x+y)\,dx + \cos(x+y)\,dy$$ and $$d(\sin(x)\cos(y)+\cos(x)\sin(y))=\cos(x)\cos(y)\,dx-\sin(x)\sin(y)\,dy-\sin(x)\sin(y)\,dx+\cos(x)\cos(y)\,dy$$ which tells you how the expression must change no matter which direction you move in - geometrically, this tells you about the tangent plane to the bivariate function $\sin(x+y)$. Since these tangent planes are equal, you can actually just set the coefficient of $dx$ (or, equally well, $dy$) on either to be equal to get: $$\cos(x+y)=\cos(x)\cos(y)-\sin(x)\sin(y).$$ In more elementary terms, this is just the derivative of the given expression with respect to $x$ taking $y$ to be constant - but it's a bit more insightful to see that this is just half of an expression where the change in the given terms is written as a weighted sum of the change in $x$ and $y$.