Define the commutator

Commutator[λ_,i_,j_]:=λ[i].λ[j]-λ[j].λ[i]

Define the Algebra components table

Clear[AlgebraTable]
Options[AlgebraTable]={Treatment->PositionNonZero}
AlgebraTable[τ_,opt:OptionsPattern[]]:=Table[
OptionValue[Treatment][
Table[Tr[
  Commutator[τ, i, j].ConjugateTranspose[τ[k]]
  ], {k, 1, FunctionLength[τ]}
]], {i, 1, FunctionLength[τ]}, {j, 1, FunctionLength[τ]}]

Clear[AlgebraTable]
Options[AlgebraTable]={Treatment->PositionNonZero}
AlgebraTable[τ_]:=Table[
Tr[
  Commutator[τ, i, j].ConjugateTranspose[τ[k]]
  ], 
{k, 1, FunctionLength[τ]},{i, 1, FunctionLength[τ]}, {j, 1, FunctionLength[τ]}]

Position

PositionNonZero[list_]:=Position[list, x_ /; ! TrueQ[x == 0], {1}, Heads -> False]

Unit vectors n-dim

ϕ[n_]:=SparseArray[{i_,j_}->KroneckerDelta[i,j],n]

Table[ϕ[3][[i]]//MatrixForm,{i,1,3}]

utils

FunctionLength[τ_]:=Block[{$i},
For[$i=1,Head[Tr[τ[$i]]]==Integer||Head[τ[$i]]==SparseArray,$i++];$i-1]

FunctionLength[τ]