What is the inverse $z$-transform of $\frac{z}{z+1}$?

When it's $$\frac z{z-1}$$ the answer in the discrete domain can be found in the general tables = $$u[n]$$, but for $$\frac z{z+1}$$ I can't find the rule. Some examples say it's $$(−1)^nu[n]$$ or $$a^k\cos(k\pi)$$, which one is it and why?

To be well defined, the $z$ transform must include the ROC (radius of convergence). You can see that in this example.

You can write:

$$\frac{z}{z+1}=\frac{1}{1+z^{-1}}=\sum_{n=0}^{\infty}(-z^{-1})^n \tag{1}$$

which is the $Z$ transform of $(−1)^nu[n]$

but also you can write

$$\frac{z}{z+1}=z \frac{1}{1+z}=z \sum_{m=0}^{\infty}(-z)^m = \sum_{m=0}^{\infty} (-1)^m z^{m+1} \tag{2}$$

which, setting $n=-(m+1)$ gives $$\sum_{n=-\infty}^{-1} (-1)^{n+1} z^{-n}$$

which is is $Z$ transform of $(-1)^{n+1}u(-n+1)$

So which one is the correct inverse transform? It depends on the ROC. Eq $(1)$ only converges when $|z^{-1}|<1$ or $|z|>1$ (outside the unit circle), while eq $(2)$ only converges for $|z|<1$

Hence, to do the anti-transform it's not enough to have the $Z$ transform as a mere formula, you need to have also the ROC. Or at least the data of the original sequence being causal or anticausal.

$$\frac{z}{z+1}=\frac{1}{1-(-z^{-1})}=\sum_{n=0}^{\infty}(-z^{-1})^n=\sum_{n=0}^{\infty}(-1)^nz^{-n}=\mathcal{Z}\{(-1)^nu[n]\},\quad |z|>1$$