President Trump watched on television, increasingly angry as House Speaker Paul D. Ryan criticized his handling of the deadly white supremacist rally in Charlottesville. He held the remote control “like a pistol” and yelled for an assistant to get the Republican leader on the phone.

“Paul, do you know why Democrats have been kicking your a-- for decades? Because they know a little word called ‘loyalty,’ ” Trump told Ryan, then a Wisconsin congressman. “Why do you think Nancy [Pelosi] has held on this long? Have you seen her? She’s a disaster. Every time she opens her mouth another Republican gets elected. But they stick with her . . . Why can’t you be loyal to your president, Paul?”

The tormenting continued. Trump recalled Ryan distancing himself from Trump in October 2016, in the days after the “Access Hollywood” video in which he bragged of fondling women first surfaced in The Washington Post.

“I remember being in Wisconsin and your own people were booing you,” Trump told him, according to former West Wing communications aide Cliff Sims. “You were out there dying like a dog, Paul. Like a dog! And what’d I do? I saved your a--.”

The browbeating of the top Republican on Capitol Hill was one of the vivid snapshots of life inside the Trump White House told by one of its original inhabitants, Cliff Sims, in his 384-page tell-all, “Team of Vipers,” which goes on sale next week and was obtained in advance by The Post. The White House did not respond to a request for comment.

Sims, who enjoyed uncommon personal access to Trump, recounts expletive-filled scenes of chaos, dysfunction and duplicity among the president, his family members and administration officials.

Unlike memoirs of other Trump officials, Sims’s book is neither a sycophantic portrayal of the president nor a blistering account written to settle scores. The author presents himself as a true believer in Trump and his agenda, and even writes whimsically of the president, but still is critical of him, especially his morality. Sims also finds fault in himself, a rarity in Trump World, writing that at times he was “selfish,” “nakedly ambitious” and “a coward.”

The author reconstructs in comic detail the Trump team’s first day at work, when the president sat in the residence raging about news coverage of the relatively small size of his inauguration crowds, and White House press secretary Sean Spicer scrambled to address it.

Spicer had worked the team “into a frenzy,” and it fell to Sims to write the script for his first statement to the media. Nervously chewing gum, Spicer dictated “a torrent of expletives with a few salient points scattered in between.” At one point, Sims’s computer crashed and he lost the draft, so it had to be rewritten. And in their rush to satisfy the impatient president, nobody checked the facts. Spicer, he writes, was “walking into his own execution.”

“It’s impossible to deny how absolutely out of control the White House staff — again, myself included — was at times,” Sims writes. The book’s scenes are consistent with news reporting at the time from inside the White House.

Sims depicts Trump as deeply suspicious of his own staff. He recalls a private huddle in which he and Keith Schiller, the president’s longtime bodyguard and confidant, helped Trump draw up an enemies list with a Sharpie on White House stationery. “We’re going to get rid of all the snakes, even the bottom-feeders,” Trump told them.

White House Chief of Staff John F. Kelly told the staff that he viewed his job as serving the “country first, POTUS second,” which Sims interpreted as potentially hostile to Trump’s agenda.

Sims recounts that Kelly once confided to him in a moment of exasperation: “This is the worst [expletive] job I’ve ever had. People apparently think that I care when they write that I might be fired. If that ever happened, it would be the best day I’ve had since I walked into this place.”

A conservative media figure in Alabama, Sims came to work on Trump’s 2016 campaign and cultivated a personal relationship with the candidate-turned-president. Sims writes rich, extended dialogue from his conversations with Trump and others in the administration.

As White House director of message strategy, Sims regularly met Trump at the private elevator of the residence and accompanied him to video tapings — carrying a can of Tresemmé Tres Two hair spray, extra hold, for the boss. At one such taping, about an hour after Trump had tweeted that he saw MSNBC host Mika Brzezinski “bleeding badly from a face-lift,” the president sought feedback from Sims and Spicer.

“They’re going to say it’s not presidential,” Trump said, referring to the media. “But you know what? It’s modern-day presidential.” The president then raged about the “Morning Joe” program on which Brzezinski appears and instructed Spicer, “Don’t you dare say I watch that show.”

Sims also recounts a meeting with Attorney General Jeff Sessions, a longtime friend, and former chief strategist Stephen K. Bannon at which Sessions suggested a polygraph test of national security officials to root out “leakers” after The Post reported the transcripts of Trump’s phone calls with the Mexican president and Australian prime minister.

At times, Trump evinced less rage than a lack of interest. Sims recounts one time when Ryan was in the Oval Office explaining the ins and outs of the Republican health-care bill to the president. As Ryan droned on for 15 minutes, Trump sipped on a glass of Diet Coke, peered out at the Rose Garden, stared aimlessly at the walls and, finally, walked out.

Ryan kept talking as the president wandered down the hall to his private dining room, where he flicked on his giant flat-screen TV. Apparently, he had had enough of Ryan’s talk. It fell to Vice President Pence to retrieve Trump and convince him to return to the Oval Office so they could continue their strategy session.

Sims reconstructs moments of crisis for the West Wing communications team in play-by-play detail, including the domestic abuse allegations against former staff secretary Rob Porter and the firing of James B. Comey as FBI director.

He paints Spicer, counselor Kellyanne Conway and communications adviser Mercedes Schlapp in an especially negative light, calling Conway “the American Sniper of West Wing marksmen” and describing her agenda as “survival over all others, including the president.”

Sims writes that former aide Omarosa Manigault cursed members of the Congressional Black Caucus when they asked for a moment of privacy in the West Wing after meeting with Trump and before addressing the media.

“Privacy?!” Manigault said. “You think you can come up in our house and demand [expletive] privacy? Hell, no! You must be outta your . . . mind.”

Perhaps the book’s most cinematic chapter of chaos is “The Mooch Is Loose,” a reconstruction of Anthony Scaramucci’s 11 days as White House communications director.

Sims was Scaramucci’s right-hand man and describes the flamboyant aide’s hunt for “leakers,” which began with his own staff. Scaramucci assembled the 40-odd media aides and threatened to fire them all, Sims writes, as if he were a “fire-breathing dragon that had just returned from laying waste to the unsuspecting peasants in the village.”

Sims writes that Scaramucci ordered them to reply to anyone in the White House instructing them to leak information to a reporter, including then-Chief of Staff Reince Priebus, by saying: “I cannot do that. I only report to Anthony Scaramucci and he reports directly to the president of the United States.”

Even Trump was amused.

“Can you believe this guy?” the president told Sims. “He’s completely out of his mind — like, on drugs or something — totally out of his mind. We’ll figure it out, but the guy is crazy.”