Former President Barack Obama and San Francisco are made for each other: enchanting at first, but not as cool as they think they are.

OK, I loved each once. Then San Francisco, where Twitter lives, gave President Donald Trump a perfect platform. Up in a tree, Trump rages at the news media, immigrants, his Justice Department, poisoning the public well with no obligation to the truth.

There’s no fair chance to respond to rants before another shout comes down. Via Twitter, Trump told us about his “absolute right” to pardon himself.

Twitter should close his account and silence the street-fighter diatribes before it goes down in history as a key propaganda tool of a diabolical presidency.

San Francisco, do something to justify your reputation for dissent. After failing to protect former 49ers quarterback Colin Kaepernick’s protest from Trump’s winds of wrath, let’s just say you’re falling down — not kneeling — on the job.

Speaking of falling, Obama failed to burnish his legacy and secure his successor. He left his White House record undefended for Trump to tear down. So far, Obama’s notable losses are in the world’s eyes: Trump scuttled the Paris climate change agreement, the Iran nuclear deal and Obama’s immigration policy on young “Dreamers.”

None of these were legislative victories in Congress.

Obama owes the survival of Obamacare to the grace and grit of one Republican, Sen. John McCain, R-Ariz., who saved it by the skin of his teeth. On the other fronts, public persuasion is part of the president’s job. This was the flaw in the gem. Obama never nailed major achievements in the public square.

In a new book, The World As It Is, Obama adviser Ben Rhodes says his boss was shellshocked by the 2016 election. Was it a rebuke to his brand of cool? Obama was sure Democratic nominee Hillary Clinton would win. He mused, “Maybe people just want to fall back into their tribe.”

Except, sir, Trump lost the people’s vote by about 3 million.

Like fog lifting, it’s painfully clear Obama failed his best and brightest Cabinet member. The lofty Obama never was a team player, yet politics is a team sport. The giant he embraced early on, President Abraham Lincoln, even had a Cabinet “team of rivals.”

Obama always felt he could rock any house (or Senate) with words that thrilled like San Francisco’s hills. But the magic wore thin when he never did ground work, the hurly-burly of counting friends and knowing enemies. Senate Majority Leader Mitch McConnell, R-Ky., played Obama for what he was: a rookie.

“As Obama approached the fourth year of his presidency, many people considered him more of a mystery than when he was elected,” wrote discerning biographer David Maraniss in Barack Obama: The Story.

Prolonging the wars in Iraq and Afghanistan mystified many supporters. Obama’s campaign promise to close the dark jail on Guantanamo got lost in the mail. He was my generation’s president, but euphoria faded fast.

Obama’s cruelest cut — to his legacy and Clinton — was appointing FBI director James Comey, a self-serving Republican who made grave errors that cost her dearly. Comey chastised Clinton twice in public — turning the tide a week before the election — over defunct investigations into her emails.

Curiously, Comey concealed a far more ominous FBI case: Russian meddling to tip the election to Trump. Never mentioned it.

Here’s where assessing Obama feels like peeling an onion, ending in tears. Obama asked Senate leaders to join a statement on American democracy under assault. McConnell refused. So Obama surrendered the idea of fully revealing the Russian spying case to “the world as it is,” to borrow a phrase.

Overconfident Obama hurt Clinton and helped Trump because he thought the thing was in the bag. Michelle Obama put more gusto into her Clinton speeches.

Meanwhile, McConnell brazenly held a U.S. Supreme Court seat open, denying Obama’s pick, Merrick Garland, a hearing.

Had Obama’s mentor, Sen. Edward Kennedy, D-Mass., lived, he would have given Obama rough lessons on presidential power. Rein in rogues. Show no mercy to enemies. Play to win — even if you believe it’s not your election.

Because 2016 was Obama’s election, too. It made him history’s first tragically hip president.

Jamie Stiehm writes about politics, culture and history as a weekly Creators Syndicate columnist and regular contributor to U.S. News & World Report. Follow her on Twitter: @jamiestiehm. Click here to read previous columns. The opinions expressed are her own.