CNN national security analyst John Kirby, a retired rear admiral in the US Navy, was a spokesman for both the State and Defense departments in the Obama administration. The opinions expressed in this commentary are his own. View more opinion articles on CNN.

(CNN) President Trump's order this week to rescind medals and letters of commendation awarded to members of the prosecution team in the murder trial of Navy SEAL Eddie Gallagher reminded me of one of my favorite Harry Truman sayings:

"Never kick a fresh turd on a hot day."

And boy, does it stink around here.

Let's look at the Navy's kick first.

The Navy's prosecution team did not exactly crown itself in glory.

The team was sanctioned by the judge for violating the constitutional rights of Chief Gallagher, who was accused of killing an ISIS captive in 2017.

The judge fired the lead prosecutor, Cmdr. Christopher Czaplak, for conducting a warrantless surveillance program that tracked emails between defense attorneys and the weekly newspaper, Navy Times.

According to Navy Times , one of the lawyers who was awarded a medal, Lt. Brian John, was praised in his citation for preparing the government's "most challenging witnesses." But that witness turned out to be fellow Navy SEAL Corey Scott, who stunned everyone in the courtroom -- including Lt. John -- by admitting to the murder.

The prosecution's case fell apart and Gallagher was convicted only of appearing in an inappropriate photograph with the victim's body.

But the Navy's chief faux pas may have been the manner in which it chose to recognize the prosecution's work: a public awards ceremony attended by the judge who presided over Gallagher's case as well as the related trial of Navy Lt. Jacob Portier.

Portier was the officer in charge of Gallagher's SEAL team who was accused of various offenses, including encouraging enlisted personnel to pose for photos with the body and failing to report war crimes. On Thursday night, the Navy announced it was dismissing all charges against Portier and reviewing the conduct of the prosecution team and the Navy judge advocate leadership -- a decision that seems fitting given the circumstances.

It's important to note that one of Portier's prosecutors was one of those officers awarded a medal in the Gallagher case.

Whether or not you think that award was merited, the Navy and specifically Navy legal leadership came across as tone deaf.

The ceremony could have waited until after Portier's trial was complete, or more appropriately conducted as part of each person's end-of-tour recognition. And, given the outcome, notoriety and sensitive political nature of the Gallagher case, it could have been conducted in less public a fashion. Did no one see the perception problem of having a young prosecutor praised for his "exceptional ability, steadfast initiative, and selfless dedication to duty" right in front of the same judge who was presiding over a related case?

The Navy isn't the only one kicking up filth here. President Trump, in his order to strip honors from these lawyers, was petty, mean-spirited and small.

He made no secret of where his predilections lay in Gallagher's case. Spurred on by his base and by supporters of Chief Gallagher, Mr. Trump ordered the SEAL into less restrictive pre-trial confinement and openly praised his military service before and during the trial.

When the verdict ultimately swung his way, Mr. Trump boasted about his role.

"Congratulations to Navy Seal Eddie Gallagher," he tweeted after the acquittal on July 3rd. "Glad I could help!"

With such comments, Mr. Trump risks tainting the military justice process.

He no doubt thinks he is further helping the Gallagher family by rescinding those awards. But here, too, he takes it too far.

"The Prosecutors who lost the case against SEAL Eddie Gallagher," he tweeted yesterday, "... were ridiculously given a Navy Achievement Medal. Not only did they lose the case, they had difficulty with respect to information that may have been obtained from opposing lawyers ..."

To be sure, the President has every right to pull back the awards. He's the commander in chief, after all. Military awards and decorations fall under his writ, even at this low a level. But that he did so publicly -- and through a tweet no less -- cheapens the awards process and likely demoralizes the other men and women who have received those honors.

Navy Achievement Medals and letters of commendation are common in the service, designed to recognize relatively junior personnel for performance that doesn't rise to the level of higher awards. These accolades represent a nice bit of praise and contribute to good morale.

While it's absolutely fair to question why some of the lawyers in the Gallagher case received medals for, in effect, losing a case, it's also fair to question why everyone involved -- including junior enlisted personnel -- were denied appropriate recognition.

Two of the legal clerks had been lauded in letters of commendation now revoked for providing "exceptional and seamless pretrial litigation and logistical support." And two other sailors weren't even in the legal profession. One was a gunner's mate and the other a young seaman. They were simply helping out, following orders and doing their work commendably, honorably.

The President's blanket repudiation of all that work sends a horrible message to servicemen and women about the degree to which their sacrifices and hard work really matter to him. I cannot recall a time when a President involved himself so publicly and so viciously in military awards at this level.

Stay up to date... Sign up for our new newsletter. Join us on Twitter and Facebook

Once again, Mr. Trump risks drawing the military into his political fights and his personal grudges. Once again, he sullies himself and the office he holds.

His supporters will no doubt praise him for championing a hero and hitting back at the Navy bureaucracy. Fair enough. Navy leaders should have to answer for some of the decisions they made in this case. And they should have thought a bit more deeply about whether, how and in what way they recognized members of the prosecution. But the President, too, should have conducted himself with more dignity.

Harry Truman had it right. Lots of kicking here. And nobody comes out smelling very good.

This article was updated to reflect the news that the Navy dismissed charges against Lt. Jacob Portier.