“Courthouses should not be used as bait in the enforcement of our country’s immigration law,” Cantil-Sakauye wrote.
Trump has vowed to increase deportations and has widened the net of illegal immigrants prioritised for detention.
“We will review the letter and have no comment at this time,” said Peter Carr, a spokesman for the US Department of Justice.
Immigrant rights groups said federal agents had entered courthouses with increased frequency this year, including in California, Massachusetts, Maryland and Texas.
Cantil-Sakauye stopped short of questioning the legal right of federal agents to enter courthouses to locate and detain unauthorised immigrants.
Her letter said the presence of immigration agents in California courthouses could undermine “public trust and confidence in our state court system”, which serves “millions of the most vulnerable Californians”. Reuters