As a Black woman working as a criminal prosecutor, Laura Coates said she often felt judgment standing in the role where many people expected a white man to stand.

Coates, a CNN legal analyst, spoke with Jim Braude on Greater Boston Thursday about her new book, "Just Pursuit," which details her experiences as a Black prosecutor and how racism seeps into every corner of the justice system.

"The perception was that there was no opportunity to really be, at the one hand, a civil rights proponent — and also a prosecutor,” she said. “The idea of having this fallacy, that Black and brown people must occupy but one role in a criminal courtroom — as a defendent or perhaps a defense counsel — I think needs to be disrupted."

In one difficult anecdote in her book, Coates recalls the victim of a car theft who reported the crime to her office. She learned that he was an undocumented immigrant and was required to report him to the authorities, and he was deported. With his choice, Coates argued, he was put in an impossible position of either staying silent about the theft or speaking up and risking deportation.

“My moral compass sometimes pointed one direction but the directives pointed another,” she said. “And that’s why I often say — which is very counterintuitive to those who don’t know the system — sometimes the pursuit of justice can create injustice.”

Ever the optimist, Coates said she is hopeful that biases and racism can be rooted from U.S. systems.

“Nothing in our country has gotten done because we turned a blind eye to an issue, or because it was overwhelming,” she said. “We really have to make sure that the optimism is not just pie in the sky, but actually boots on the ground.”

Watch: Laura Coates on her time as a federal prosecutor