Nobody knows yet what Donald Trump is going to do to immigration enforcement. Only a month has passed since the election, and the president-elect is no different from the candidate: erratic, self-contradictory, hazy on principles and policies.

But states and cities that value immigrants, including the undocumented, do not have the luxury of waiting and hoping for the best. They are girding for a confrontation, building defenses to protect families and workers from the next administration.

They fear that Mr. Trump, who ran on a pledge of mass deportation, dehumanizing immigrants and refugees, will remove humane discretion from immigration enforcement. They understand that not all unauthorized immigrants are criminals, that not all should be detained or deported and that the country cannot enforce its way out of its failure to reform unjust immigration laws.

But they know that the nativist ideologues and white nationalists around Mr. Trump are itching for him to be merciless. They know that if he does anything close to what he has repeatedly vowed to do — set dragnets for millions of unauthorized immigrants, triple the number of enforcement officers, immediately revoke President Obama’s administrative actions shielding young people from deportation and pull federal funds from cities that defend immigrants — their prudence will have been justified.

Mr. Trump has reportedly chosen a retired Marine general, John Kelly, to run the Department of Homeland Security. He seems to fit the Trump pattern of seeing immigrants not as a resource to be tapped, but as a threat to be neutralized, beginning at the border. General Kelly, who led the United States Southern Command, warned Congress last year of the danger of terrorists and “weapons of mass destruction” coming in from Mexico. He admitted he had no evidence, but was clanging the alarm all the same.

In immigrant-rich communities across America, there are more legitimate fears for the immigrants. Bills introduced this week in the California State Legislature confront them directly. One would create a program to finance legal services for immigrants fighting deportation. Another would provide training and advice on immigration law to public defenders’ offices. Come the purge — and Mr. Trump has said he is going after two million to three million people immediately — many will need lawyers.

The third bill, potentially the most consequential, seeks to ensure that California will never be an accomplice to mass deportation. Its sponsor, Kevin de León, the California Senate president pro tempore, calls it the California Values Act, befitting a state that is nearly 40 percent Latino, and where one in four residents is foreign-born. It would bar state or local resources from being used for immigration enforcement, a strictly federal duty. No state or local law enforcement agency would be allowed to detain or transfer anyone for deportation without a judicial warrant.

Nothing in the bill would obstruct the federal government. This is not a nullification of federal laws or a rebellion against the Constitution. It’s upholding the Fourth Amendment, preventing unreasonable search and seizure, so mothers and fathers can go to work and children go to school without fear of losing one another. It's upholding the First Amendment, so day laborers can solicit work on a sidewalk. It's allowing the local police to keep the trust and cooperation of crime victims and witnesses, who will not fear avery ecounter as a prelude of deportation.
“Nobody wants bad people in our communities or neighborhoods or in our streets,” Mr. de León said, particularly the local and state police. “They’ll always go after the rapist, the violent criminal drug dealer; we’ve made that abundantly clear.”

Expect Mr. Trump and his immigration brain trust, led by the Senate hard-liner Jeff Sessions and ideologues like Kris Kobach, the secretary of state of Kansas, to denounce all such efforts as providing sanctuary to dangerous criminals.

But the opposite is true: By drawing a bright line between federal immigration enforcement and local policing, the California Values Act would promote smarter, more effective law enforcement. Local officers would continue to keep the peace, and in the face of criminal threats — as validated by a warrant from a judge — would cooperate with federal agents. But if the Trump administration begins roundups of those who pose no danger, of minor offenders and noncriminals, staking out schools, churches, businesses and homes — they will not do its job for it.

“We’re not looking for a fight with the president-elect and his administration,” said Mr. de León. “We’re guided by the principles of justice and dignity for all people.”