Based on his resume alone, Rudy Giuliani — the former New York mayor and federal prosecutor — would seem to be the perfect defense attorney for any president. When President Donald Trump hired him in April to join his legal team in the ongoing federal investigation into Russian meddling in the 2016 election, Giuliani seemed a perfect fit — a combative loyalist for a president who has been described by his White House as someone who "fights fire with fire."

Giuliani has also been in front of television cameras for decades and is a veteran of countless interviews, another plus for a client who likes to see his representatives on TV.

But in light of recent headlines, it turns out that maybe the fit is less than perfect. It's hard to say now whether Giuliani's in-your-face media strategy will ultimately help his client — it may be that Giuliani is executing a plan that leads to a complete and public exoneration of his client. If so, he's taking some risks by disregarding some basic safety rules for criminal defense attorneys when talking to the media.

Don't criticize the prosecution

Occasionally, public criticism of the actions of police or law enforcement agents is warranted. If, for example, shoddy investigative work or officer error is part of the defense’s case, those are helpful points to make in an interview. If the police executed a warrant at the wrong location, or it's a case of mistaken identity, then it's possibly safe to point this out on the air.

However, a defense attorney should not criticize the prosecutors when speaking to the media. He should never tell them how to do their job or when to wrap it up, because there's no upside. Prosecutors will tell you they are above the fray, that they don't let emotional responses affect their work. They have to say that. Any prosecutor who has handled a crime against a child, for example, finds herself or himself particularly motivated to bring that defendant to justice. Plus, prosecutors don't get to respond to the media, other than announcing indictments. They have to quietly suffer the slings and arrows of outrageous public statements. When a defense attorney goes on ABC News and calls their investigation the "most corrupt he’s ever seen" — as Giuliani did Sunday, talking about the probe led by special counsel Robert Mueller — the prosecutors can't respond on Twitter. What they can do is work an extra hour at the office, to prove that defense attorney wrong.

As for giving the prosecutors a timeline to "wrap things up," as Giuliani and other Trump attorneys have done publicly? Defense attorneys never do this. Prosecutors wrap up investigations when and if they are ready. Telling prosecutors how to do their job is never good for the client.

Don't assume you know the whole story

Any defense attorney will tell you: Clients burn you. So do their friends and family. They often only tell counsel a version of the facts that places them in the best light. The problem is, the client’s version of the facts often bears little resemblance to the prosecutors’ version of the facts. Unfortunately, sometimes the client’s version doesn’t resemble the factual facts, either.

It’s not exactly "lying." Sometimes clients don't know certain facts, and they fill in with helpful assumptions — that is, assumptions helpful to their side. In some cases, the brain's survival mechanisms kick into full exoneration mode. This results in a story that the client truly believes, but is the product of the body’s biological reluctance to inflict self-harm. Think of the last argument you had with a sibling or close friend. If you both were separated and asked to give a statement about who did what, do you think the statements of these two good people would be identical? Of course not. Sometimes, it's not exactly lying, but it’s not exactly the truth, either.

That's why defense attorneys should never marry themselves to the client’s initial version of the facts without doing their own investigation.

Earlier this month, Giuliani said that, "as far as I know," Trump "did not originally know" about the payment that Michael Cohen made to Stormy Daniels, but "at some point ... the president found out and reimbursed him." It shouldn't be "as far as he knows." Giuliani should know, before he goes on the air. Otherwise, that assertion might backfire on him later. Representing a client before the media in this way makes him look like he just doesn’t know things, or is easily manipulated by the client.

Stay on message

It sounds simple, but Giuliani just needs to remember that he is on television. As the client’s representative, it’s critical to get your bullet points out there and stay on message. Michael Avenatti, the attorney for Stormy Daniels, is an example of a lawyer who stays relentlessly on message when interviewed. Every question is anticipated, and every answer is scripted for maximum effect. He deploys clever catchphrases that go viral and are easily repeated. When he's on television, he’s working. He's not hanging out with the anchors.

Giuliani, on the other hand, takes a different approach to being interviewed by television anchors: He jokes around with them. He is dismissive of their challenges. He gets into arguments with them.

That means that he cares what individual interviewers think, and also that he sees his role as trying to change the mind of the anchor. Persuading an individual is fine if you’re meeting someone for coffee, but it’s not helpful to your client if you are a defense attorney being interviewed on television. If you debate your case on the air, it can be picked apart on the air, long before you have a chance to present it. If you reveal your strategy, then it can be anticipated by the prosecution. And if you reveal previously unknown facts, those are lost to the other side forever.

In our modern media era, sometimes defense attorneys have to go on TV and act as a lone voice in the cacophony of negative publicity. If done correctly, it can get the defense’s message out there. If done incorrectly, it’s the kind of lawyering that can, to paraphrase Giuliani — talking about bad witnesses — "really destroy a whole case."

Danny Cevallos is an MSNBC legal analyst. Follow @CevallosLaw on Twitter.