The president began by pointing to the criminal justice reform legislation he passed last year.

“Now that it is passed, people that had virtually nothing to do with it are taking the praise,” Mr. Trump wrote. “Guys like boring musician @johnlegend, and his filthy mouthed wife, are talking now about how great it is — but I didn’t see them around when we needed help getting it passed.”

He did not name Ms. Teigen, which she noted in her response. “Tagged everyone but me,” she wrote. “An honor, mister president.” She added that she had not been mentioned in the MSNBC special that Mr. Trump appeared to have watched.

Mr. Legend also jumped into the fray, and he called on the first lady to intervene.

“Imagine being president of a whole country and spending your Sunday night hate-watching MSNBC hoping somebody — ANYBODY — will praise you,” he said. “Melania, please praise this man. He needs you.”

Mr. Trump has often boasted about his own I.Q. and questioned the intelligence of others. He also has a habit of insulting prominent people of color.

Last year’s criminal justice overhaul under the First Step Act was meant to expand job training and other programs to reduce recidivism for federal prisoners; modify sentencing laws, including mandatory minimum sentences for nonviolent drug offenders; and enlarge early release programs.