The task is to compute the derivative
\begin{equation}
\frac{\partial\mathrm{diag}\left(\boldsymbol{A}\boldsymbol{x}+\boldsymbol{b}\right)\boldsymbol{x}}{\partial \boldsymbol{x}} \;\;\text{with} \;\; \mathrm{diag}\left(\boldsymbol{A}\boldsymbol{x}+\boldsymbol{b}\right)=
\begin{pmatrix} 
\left(\boldsymbol{A}\boldsymbol{x}+\boldsymbol{b}\right)\_1 & 0 & 0 & \dots \\
0 & \left(\boldsymbol{A}\boldsymbol{x}+\boldsymbol{b}\right)\_2 & 0 & \dots \\
0 & 0 & \left(\boldsymbol{A}\boldsymbol{x}+\boldsymbol{b}\right)\_3 & \\
\vdots & \vdots & &\ddots
\end{pmatrix}.
\end{equation}
To this end, we can use $\mathrm{diag}\left(\boldsymbol{A}\boldsymbol{x}+\boldsymbol{b}\right)\boldsymbol{x}=\left(\boldsymbol{A}\boldsymbol{x}+\boldsymbol{b}\right) \circ \boldsymbol{x}$,
where $\circ$ denotes the component-wise product/Hadamard product. Deriving the $i$-th row of this expression with respect to the $p$-th component of $\boldsymbol{x}\in\mathbb{R}^n$ results in
\begin{align}
\frac{\partial \left(\sum\_{j=1}^{n} A\_{ij}x\_j+b\_i\right)x\_i}{\partial x\_p}&=
\frac{\partial \left(\sum\_{j=1}^{n} A\_{ij}x\_j+b\_i\right)}{\partial x\_p}x\_i+
\left(\sum\_{j=1}^{n} A\_{ij}x\_j+b\_i\right)\frac{\partial x\_i}{\partial x\_p}
\\
&=
A\_{ip} x\_i + \sum\_{j=1}^n A\_{pj} x\_j + b\_p.
\end{align}
Hence, when $\boldsymbol{a}\_p^\top$ is the $p$-th row of $\boldsymbol{A}$, the full the derivative is
$$
\frac{\partial \left(\mathrm{diag}\left(\boldsymbol{A}\boldsymbol{x}+\boldsymbol{b}\right)\boldsymbol{x}\right)}{\partial \boldsymbol{x}}=\begin{pmatrix}
A\_{11}x\_1+\boldsymbol{a}\_1^\top\boldsymbol{x}+b\_1 & A\_{12} x\_1+\boldsymbol{a}\_2^\top \boldsymbol{x}+b\_2 & \dots \\
A\_{21}x\_2+\boldsymbol{a}\_1^\top\boldsymbol{x}+b\_1 & A\_{22} x\_2+ \boldsymbol{a}\_2^\top \boldsymbol{x}+b\_2 & \dots \\
\vdots & \vdots 
\end{pmatrix}.
$$

Is this correct?

======== **Correction** ========= \

Comparing with the answers, the first part $A\_{ip}x\_i$ corresponds to $\mathrm{diag}\left(\boldsymbol{x}\right)\boldsymbol{A}$. However, the second term
$$
\left(\sum\_{j=1}^{n} A\_{ij}x\_j+b\_i\right)\frac{\partial x\_i}{\partial x\_p}
$$
only makes a contribution if $i=p$, i.e, on the diagonal. Using $A\_{ij}\delta\_{ip}=A\_{pj}$ and $b\_i\delta\_{ip}=b\_p$ got rid of the $i$ and led to the error.