Check the differentiability of the following function $$f(x)=(x+1)|x^2-1|$$ at points $x=1$ and $x=-1$.
My approach
I have written the function in the following form:
$$f(x)=\begin{cases} x^3-x+x^2-1 & \text{ if } x\leq-1,x\geq1 \\ x-x^3+1-x^2 & \text{ if } -1<x<1 \end{cases}$$
Now, taking derivative:
$$f'(x)=\begin{cases} 3x^2-1+2x & \text{ if } x\leq-1,x\geq1 \\ 1-3x^2-2x & \text{ if } -1<x<1 \end{cases}$$
Clearly, the above derivative is continuous at $x=-1$ and discontinuous at $x=1$, hence function will be differentiable at $x=-1$ and $x=1$.
Did I do everything correctly? I am not sure about this and answer has not been provided in the answer manual.

This is not correct. From the equality$$f(x)=\begin{cases} x^3-x+x^2-1 & \text{ if } x\leqslant-1,x\geqslant1 \\ x-x^3+1-x^2 & \text{ if } -1<x<1 , \end{cases}$$all you can deduce automatically is that$$f'(x)=\begin{cases} 3x^2-1+2x & \text{ if } x<-1,x>1 \\ 1-3x^2-2x & \text{ if } -1<x<1 \end{cases}$$(the inequalities became strict). Since $\lim_{x\to-1^\pm}f'(x)=0$, you can deduce that $f'(-1)=0$. On the other hand, from the fact that $\lim_{x\to1^+}f'(x)\neq\lim_{x\to1^-}f'(x)$ (and both limits exist), you can deduce that $f'(1)$ does not exist.
Another way of proving that it is differentiable at $-1$ is:\begin{align}\lim_{x\to-1}\frac{f(x)-f(-1)}{x+1}&=\lim_{x\to-1}\frac{(x+1)|x^2-1|}{x+1}\\&=\lim_{x\to-1}|x^2-1|\\&=0.\end{align}