The NYPD ought to know better than to go after a reporter’s sources — especially when it’s invoking an anti-terrorism law to do it.

On Dec. 9, the department served Twitter with a subpoena demanding data on the account of Post Police Bureau Chief Tina Moore. A lot of info: all device and contact information associated with the user handle, plus the handle’s complete connection history from Oct. 9 to Oct. 14.

Twitter alerted The Post, and our lawyers contacted the NYPD — which promptly dropped the request.

When asked about the subpoena, an NYPD official said, “We are conducting an investigation of a person who leaked crime scene photos.”

It looks like the cops wanted to figure out how Moore got pictures from a deadly Brooklyn dice-game shooting. But that has nothing to do with terrorism or national security — though the subpoena cited the post-9/11, anti-terror Patriot Act as well as city administrative law. It’s only about intimidating NYPD officers and a free press.

We’ve been firm supporters of the Patriot Act from the start, even as its critics have warned that law enforcement would seek to abuse such extraordinary powers by applying it to cases that have nothing to do with national security.

Now the NYPD — or its lawyers — has just given those critics some powerful fodder, undermining a law that helps keep this terror-target city safe.

Police Commissioner Dermot Shea has a duty to make this right, by publicly disciplining whoever made the call to abuse the Patriot Act and so endanger the public.