The very first thing you did wrong was substituting $x=\tan y$. How can you do that when $y$ is itself a function of $x$?
Secondly, when you apply the chain rule, you should get it's derivative as $y'=-\dfrac{1}{1+x^2}$.
Now if you want to proceed via a substitution, substitute $x=\tan \theta$ and since $x \in \mathbb{R}-\{1\}$, we have $\theta \in \left(-\dfrac{\pi}{2},\dfrac{\pi}{2}\right)-\{\dfrac{\pi}{4}\}$ so that you finally get $$y=\cot ^{-1}\left(\cot\left(\dfrac{\pi}{4}-\theta\right)\right)=\begin{cases}\dfrac{\pi}{4}-\theta~~~~ \text{for} ~\theta\in \left(-\dfrac{\pi}{2},\dfrac{\pi}{4}\right) \\
\dfrac{5\pi}{4}-\theta ~~~~\text{for} ~\theta \in \left(\dfrac{\pi}{4},\dfrac{\pi}{2}\right)\end{cases}$$ and since we have $\dfrac{\mathrm d y}{\mathrm d \theta}=-1$ for both situations and we had from $x=\tan \theta$, $\dfrac{\mathrm{d}x}{\mathrm{d}\theta}=1+x^2$, we get $y'=-\dfrac{1}{1+x^2}$.