CHENGDU, China — With a neon-red backpack and white Adidas shoes, he looks like any other undergraduate on the campus of Sichuan University in southwestern China.

But Peng Wei, a 21-year-old chemistry major, has a special mission: He is both student and spy.

Mr. Peng is one of a growing number of “student information officers” who keep tabs on their professors’ ideological views. They are there to help root out teachers who show any sign of disloyalty to President Xi Jinping and the ruling Communist Party.

“It’s our duty to make sure that the learning environment is pure,” Mr. Peng said, “and that professors are following the rules.”

In a throwback to the Mao Zedong era, Chinese universities are deploying students as watchdogs against their teachers, part of a sweeping campaign by Mr. Xi to eliminate dissent and turn universities into party strongholds.