I started with evaluating the following derivative with respect to a general element of an $n\times n$ matrix,
$$\frac{\partial}{\partial X_{ab}}\left(\mathrm{Tr}{(XX)}\right)$$
I wrote out the trace in index notation in order to get a sense of how I might take the derivative term-by-term:
$$\mathrm{Tr}{(XX)} = X_{ij}X_{ji} = \sum_{j=1}^n X_{1j}X_{j1} + \sum_{j=1}^n X_{2j}X_{j2} + \dotsm + \sum_{j=1}^n X_{nj}X_{jn}$$
From this, it appears to me that
$$\frac{\partial}{\partial X_{ab}}\left(\mathrm{Tr}{(XX)}\right) = 2X_{ba}$$
I am struggling with a more complicated case, the following derivative, $$\frac{\partial}{\partial X_{ab}}\left(\mathrm{Tr}{\left([X,Y]^2\right)}\right).$$
First I aimed to simplify using the properties of the trace over a product, i.e.
\begin{align} \mathrm{Tr}{\left([X,Y]^2\right)} &= \mathrm{Tr}{\left(\left(XY-YX\right)^2\right)} = \mathrm{Tr}{\left(XYXY-XYYX-YXXY+YXYX\right)}\\ &= 2\mathrm{Tr}{\left(XYXY-XYYX\right)} \end{align}
where in the last line I've used the cyclic property of the trace. Now I express this in index notation,
\begin{align} \mathrm{Tr}{\left([X,Y]^2\right)} &= 2\mathrm{Tr}{\left(X_{ik}Y_{km}X_{ml}Y_{lj}-X_{ik}Y_{km}Y_{ml}X_{lj}\right)}\\ &= 2\left(X_{ik}Y_{km}X_{ml}Y_{li}-X_{ik}Y_{km}Y_{ml}X_{li}\right) \end{align}
Now to evaluate the derivative,
\begin{align} \frac{\partial}{\partial X_{ab}}\left(2\left(X_{ik}Y_{km}X_{ml}Y_{li}-X_{ik}Y_{km}Y_{ml}X_{li}\right)\right) &= 2\frac{\partial}{\partial X_{ab}}\left(X_{ik}Y_{km}\left(X_{ml}Y_{li}-Y_{ml}X_{li}\right)\right)\\ &= 2\frac{\partial}{\partial X_{ab}}\left(X_{ik}Y_{km}\left[X,Y\right]_{mi}\right)\\ &= 2Y_{km}\left(\left(\frac{\partial}{\partial X_{ab}}X_{ik}\right)\left[X,Y\right]_{mi} + X_{ik}\left(\frac{\partial}{\partial X_{ab}}\left[X,Y\right]_{mi}\right) \right) \end{align}
At this point I'm a bit stuck. I don't feel confident with the last few steps. Alternatively I've tried looking at these terms as explicit summations, but I get a bit bogged down by the fact that there are four summation variables in each term. I think there is a more efficient way of thinking about these terms, but it has escaped me so far.