Good morning on this frigid Wednesday.

It’s becoming a familiar procedure in New York: Prosecutors file charges against an accused terrorist with local ties days, or even hours, after an attack.

Yesterday, it happened in the case of Akayed Ullah, who told investigators that he had built a bomb, strapped it to his chest and detonated it in a subway corridor on Monday. “I did it for the Islamic State,” he told them. It was the city’s second attack in six weeks.

In an era when attacks often spawn not from inside terrorist groups, but from people inspired or guided by them from afar, how can law enforcement keep the city safe? We asked Mike O’Neil, a former commanding officer of the New York Police Department’s counterterrorism division and the chief executive of MSA Security.

How can we prevent lone-wolf attacks in New York City?

“The scary part about a homegrown, lone-wolf radical threat is that it’s hard to deal with,” Mr. O’Neil said. Because attacks are increasingly carried out with vehicles and homemade bombs, preventing them calls for a collective effort between law enforcement and the community, he added. “The only way you can really attack it is by having an informed public who sees and reports suspicious behavior, and law enforcement that’s present on location that hopefully can engage attacks before they happen.”