Michael Hayden, former CIA director and former NSA director, speaks at The Washington Post’s Cybersecurity Summit on Oct. 3, 2013. (Jeffrey MacMillan for The Washington Post)

As President Trump sharply condemned North Korea’s overnight nuclear test, he also tweeted a jab at an American ally, South Korea, that only added to building tensions, a former top national security official said Sunday.

Gen. Michael Hayden, a former National Security Agency and CIA director who has been critical of Trump, stressed that the president’s tweets may foul up an otherwise respectable plan to get tough on North Korea.

“You gotta watch the tweets, and I think we had an unforced error over the weekend when we brought up the free trade agreement with our South Korea friends on whom we have to cooperate…it’s wrong on the merits and its certainly not integrated into a broader approach to northeast Asia,” Hayden said on CNN’s “State of the Union.”

Hayden served as NSA director from 1999 to 2005 and led the CIA from 2006 until 2009.

The slap at South Korea was among five Sunday morning tweets from the president related to North Korea’s claim that it had detonated a hydrogen bomb.

“South Korea is finding, as I have told them, that their talk of appeasement with North Korea will not work, they only understand one thing!” he said.

North Korea said that it had detonated its most powerful nuclear device yet, a hydrogen bomb that could be attached to a missile capable of reaching the mainland United States.

Rep. Adam Schiff (D-Calif.), the top Democrat on the House Intelligence Committee, questioned Trump’s decision to admonish South Korea when the nation appears to be facing a growing threat.

“We need to be working hand in hand with South Korea, and with Japan,” he said on CNN. “Why we would want to show divisions with South Korea makes no sense at all.”

Schiff also said that there is “some skepticism” in the intelligence community about North Korea’s claim that it could put a weapon like this on an intercontinental ballistic missile. But Schiff said that “even if that’s not true today,” experts believe it is only a matter of time before Pyongyang can make good on its threat.

Trump also has said he is considering withdrawing from a free-trade agreement with South Korea, a long-standing economic and diplomatic partner of the United States.

Asked by Fox anchor Chris Wallace whether Trump would pull the United States out of the agreement with South Korea, even amid a nuclear threat,, Treasury Secretary Steven Mnuchin said, “The president has made clear that where we have trade deficits with countries, we’re going to renegotiate those deals.”

He added that there have been “no decisions” yet with regard to the trade accord with South Korea.

As tensions rise between the US and North Korea, the Trump administration has not ruled out possible military action. Trump is convening a meeting of his national security team later Sunday to discuss the U.S. strategy, while Mnuchin said he is drawing up tough new economic sanctions to further isolate North Korea.