A software developer employed by the Brooklyn District Attorney’s Office was arrested Monday morning after he was caught by cops waving a gun, law enforcement sources said.

Matthew Barton was busted after midnight when police officers from Brooklyn’s 88 precinct happened to come across him wielding the weapon, sources said.

Barton, a Missouri native, reviews NYPD body camera footage for the DA’s office, the sources said.

Charges against him are pending, according to sources.