Bound on order of commutator subgroup of a $p$-group

I was reading an article where it is claimed that

If $$G$$ is a finite $$p$$-group with $$|G|=p^n$$ and nilpotency class of $$n-2$$ where $$n\ge 7$$ then $$p\le|Z(G)|\le p^2$$ and $$p^{n-3}\le |G'|\le p^{n-2}$$.

I am not sure how these follow, I tried but couldn't succeed. I know from this post that nilpotency class of $$G'$$ is at most $$n-3$$ but I can not use it to get the required bound. I am really sorry if I am missing something easy.

If anyone can help me I will be really grateful.

Thanks

You have a finite $$p$$-group $$G$$ of order $$p^{n}$$ and nilpotency class $$c=n-2$$, with $$n\geq 7$$. You are seeking to show four things, labelled 1 to 4 below: $$p \leq^{(1)} |Z(G)| \leq^{(2)} p^{2}$$ $$p^{n-3} \leq^{(3)} |G^{\prime}| \leq^{(4)} p^{n-2}$$
(1) For a finite $$p$$-group we must have $$p \leq |Z(G)|$$. One of the most important facts about finite $$p$$-groups is that their center is non trivial. As this is a standard result in basic courses I will not prove it here. For a reference see here.
(2) We wish to show that $$|Z(G)| \leq p^{2}$$. Consider the upper central series of $$G$$: $$1=Z_{0}(G) The series consists of $$c+1$$ terms and $$c$$ factors. It is clear that each factor has order at least $$p$$, or else we would have a redundant term. I claim that the last factor, $$\frac{G}{Z_{c-1}(G)}$$, must have order at least $$p^{2}$$. Suppose for contradiction that this last factor has order $$p$$. We work modulo $$Z_{c-2}(G)$$, and observe that $$\frac{Z_{c-1}(G)}{Z_{c-2}(G)}$$ is the center of $$\frac{G}{Z_{c-2}(G)}$$. Notice that $$\frac{G/Z_{c-2}(G)}{ Z_{c-1}(G)/Z_{c-2}(G)} \cong \frac{G}{Z_{c-1}(G)}$$ by the isomorphism theorems, and that by our assumption this is of order $$p$$, hence the quotient is cyclic. Thus we are taking a quotient by the center and end up with something cyclic, and so by a well known result $$G/Z_{c-2}(G)$$ must be abelian. Hence $$[G,G]\leq Z_{c-2}(G)$$. However this now means if we consider the upper central series, the term $$Z_{c-1}(G)$$ is redundant, and so we can obtain a central chain of shorter length, contradicting the assumption that the class is $$c$$. Thus we see the order of the last factor must be at least $$p^{2}$$. Now if $$|G|=p^{n}$$ the product of all the factors must equal $$n$$. Explicitly $$p^{n}=|G|=|\frac{Z_{1}(G)}{1}||\frac{Z_{2}(G)}{Z_{1}(G)}|\dots|\frac{G}{Z_{c-1}(G)}|$$. There are $$c=n-2$$ factors and each factor has order at least $$p$$ with the final factor $$\frac{G}{Z_{c-1}(G)}$$ at least $$p^{2}$$. Now by considering the order of the first factor, it is clear that $$|Z_{1}(G)| \leq p^{2}$$ or else the order of the group would be too large.
(3) Now we will show $$p^{n-3} \leq |G^{\prime}|$$. Consider the lower central series of $$G$$. $$G>\gamma_{2}(G)> \dots > \gamma_{c}(G)>1$$ where $$\gamma_{2}(G)=[G,G]$$. Each of the $$c-1$$ factors in the product below must have order at least $$p$$ and so $$|[G,G]|=|\gamma_{2}(G)|=|\frac{\gamma_{2}(G)}{\gamma_{3}(G)}|\dots |\frac{\gamma_{c}(G)}{\gamma_{c+1}(G)}| \geq p^{c-1}=p^{n-3}$$.
(4) Finally we show $$|G^{\prime}|\leq p^{n-2}$$. Consider the upper central series as in (2). We have that $$[G,G]\leq Z_{c-1}(G)$$ (this is clear from the definition of the upper central series). Given what we have shown in (2), that the factor $$\frac{G}{Z_{c-1}(G)}$$ must have order at least $$p^{2}$$, it follows that the order of $$Z_{c-1}(G)$$ is at most $$p^{n-2}$$. Hence $$|G^{\prime}| \leq |Z_{c-1}(G)| \leq p^{n-2}$$.