2020 Democratic presidential candidate Sen. Bernie Sanders speaks to a rally at the Iowa state fairgrounds in Des Moines earlier this month. (Matthew Putney/AP)

Journalist David Sirota has spent the past few months trashing Democratic candidates not named Bernie Sanders, as well as those who support anyone other than Sanders. “Positively unhinged,” he tweeted in response to those who disagreed with one of his takes. His critics, he said at another point, are “mentally incapacitated.”

Among other targets, Sirota has gone after Sens. Kamala D. Harris (Calif.) and Cory Booker (N.J.), former vice president Joe Biden and former congressman Beto O’Rourke (Tex.), all of whom are expected to contend for the Democratic presidential nomination against Sanders (I-Vt.).

But what Sirota, who wrote for a variety of publications, didn’t reveal was where he was coming from: essentially, from inside Sanders’s campaign.

Unmentioned to his 125,000 Twitter followers and readers of his articles, Sirota has been advising Sanders while publicly attacking the candidate’s critics and rivals. On Tuesday, the relationship became official — Sirota was hired as a speechwriter and senior adviser to Sanders — just as the Atlantic magazine called out what could be the journalist’s conflict of interest.

A reporter’s undisclosed connection to a political candidate would constitute a breach of journalistic ethics. The basic rule is that journalists are supposed to be free of any personal or financial relationship with those they cover or comment on, even an “informal” relationship. Alternatively, reporters are obligated to at least disclose such relationships so that readers or viewers can evaluate the integrity of the reporting for themselves.

Sirota, 43, not only didn’t mention his relationship with Sanders’s campaign but apparently sought to erase his long history of attacks against Sanders’s opponents, according to the Atlantic. Just hours before his hiring by Sanders was announced, Sirota deleted about 20,000 or so of his tweets. He suggested that the timing of the mass deletion was coincidental, telling the Atlantic that his account was scrubbed by an “autodeleter” that periodically and automatically removes his posts.

It remains unclear how long Sirota advised the Sanders camp before his hiring. Neither Sirota nor Sanders’s representatives responded to multiple requests for comment on Wednesday.

Sirota’s vitriolic tweets and blog posts also appear to be at odds with the ethos of the Sanders’s campaign, which has stressed that it will “respectfully engage” other Democratic candidates. His hiring as a speechwriter also appears to be an acknowledgment that Sanders, whose extemporaneous public remarks have been a sign of his authenticity, will at times be scripted like other politicians.

Sirota has never hidden his political leanings; he has described himself as an “advocacy” journalist who reports and opines from a liberal perspective. He served as Sanders’s press secretary 20 years ago, although he has maintained that their association did not color his subsequent work as a journalist.

Sirota has written for news outlets including the International Business Times, Pando Daily and the Guardian.

Before officially joining the Sanders campaign, he regularly wrote for Capital & Main, a nonprofit news site that covers income inequality, climate change, race and criminal justice, among other topics.

His discussions with Sanders weren’t disclosed in his recent work for the site, which included a favorable stories about the Democratic-backed New Green Deal, and interviews with Washington Gov. Jay Inslee, a Democratic presidential candidate; New York Mayor Bill DeBlasio (D) and filmmaker Adam McKay about his film, “Vice,” a scathing drama about former vice president Richard B. Cheney (R).

In a statement on Wednesday, the site’s publisher, Danny Feingold, said, “Without commenting on the accuracy of [the Atlantic’s] report, Capital & Main wishes to be clear that we didn’t know that Mr. Sirota was engaged in any activity that aided Mr. Sanders. When we became aware of Mr. Sirota’s interest in working for Mr. Sanders, he wrote no further stories for us.”

Feingold said Sirota told him during the second week of February that he was interested in working for the Sanders campaign. He said he didn’t have “enough facts” to conclude that Sirota was simultaneously advising Sanders while working for Capital & Main but that the site would notify readers if it determined that was the case. He added, “If we determine that Mr. Sirota was advising the Sanders campaign while working for Capital & Main, we would be very unlikely to publish his work in the future.”

Among his many critiques, Sirota went after Ashley Pratte, the author of an NBCNews.com op-ed that called Biden “the Democrats’ best chance to beat Trump.” Sirota noted that Pratte had been a spokeswoman for the conservative American Legislative Exchange Council and said Biden had just been endorsed by a former representative of “the group that pushes right-wing legislation in state capitals across the country,” according to a tweet reviewed by the Atlantic.

He also attacked presidential candidate Sen. Kirsten Gillibrand (D-N.Y.) by tweeting “Welcome to the oligarchy” in response to a CNBC article in February about Gillibrand’s outreach to big-money donors. And, according to the Atlantic, he criticized her for working for a law firm that represented tobacco company Philip Morris.

At one point, the magazine said, Sirota also tweeted that he was not engaged in “some sort of secretive political conspiracy for a particular candidate.”