Secretary of State Rex Tillerson was in China this week meeting with President Xi Jinping to discuss ways to increase pressure on North Korea to dismantle its nuclear program.

And there were signs it was going well: “We are probing, so stay tuned,” Tillerson told the New York Times when asked about the possibility of direct diplomatic engagement with Kim Jong Un, the North Korean leader.

But almost as soon as Tillerson’s trip was over, President Donald Trump swiftly undermined his secretary of state’s outreach. From his golf resort in Bedminster, New Jersey, Trump tweeted the following Sunday morning:

...Save your energy Rex, we'll do what has to be done! — Donald J. Trump (@realDonaldTrump) October 1, 2017

It’s not unusual for Trump to undercut his own officials on Twitter, but this was extreme even by his standards. As the Atlantic’s editor Jeffrey Goldberg pointed out, Trump’s brazen defiance of Tillerson is both dangerous and unprecedented.

This seems unprecedented, a president undermining his own secretary of state's diplomatic efforts so bluntly:https://t.co/YEjnwHIjfY — Jeffrey Goldberg (@JeffreyGoldberg) October 1, 2017

As the New York Times’s David Sanger reported, Tillerson was in China with the explicit goal of “lowering the temperature of the threats being exchanged in recent days between Mr. Kim and President Trump” (read: avoiding war).

But Trump’s impulsive tweeting is certain to have the opposite effect. As is often the case, Trump is likely posturing on Twitter to save face and influence media coverage.

Jeffrey Lewis, director of the East Asia Nonproliferation Program at the Middlebury Institute of International Studies, made the crucial point:

I think Trump is worried about how he looks on cable news. But he doesn't grasp his words have consequences off screen. https://t.co/lOticmyjxg — Jeffrey Lewis (@ArmsControlWonk) October 1, 2017

The stinging Sunday tweets capped yet another devastating weekend of Twitter attacks, which began early Saturday with a string of snipes at San Juan’s mayor, Carmen Yulín Cruz, who criticized the administration’s lagging response to the humanitarian crisis underway in Puerto Rico in the aftermath of Hurricane Maria.