Cult-deity of southern Sichuan, tutelary god of scholarly examinations, moral reform, and the fate of officials. Originally a local plague-god of the Zǐtóng 梓潼 district (centred on Qīqūshān 七曲山, modern Zǐtóng county, Sichuan), euhemerised in the late Táng and Sòng through identification with the legendary Jìn-era official Zhāng Yàzǐ 張惡子 (var. Zhāng Yà, Zhāng Yù), and progressively merged from the Sòng onward with the astral deity of the stellar lodge Wénchāng gōng 文昌宮 (“Palace of the Flourishing of Letters,” six stars near Ursa Major). From the late twelfth century the cult expanded, via planchette-writing (扶鸞 / 降筆) revelation and print transmission, to trans-regional status throughout southern China, becoming in the Yuán and Míng the principal deity invoked by examination candidates.
Canonically styled 更生永命天尊 Gèngshēng yǒngmìng tiānzūn in the Daoist pantheon and fully titled 九天開化主宰澄真正觀寶光慈應更生永命天尊 in the received Dàozàng texts of his cult. In the catalog of the Kanripo corpus the deity is credited as the revealing author of Tàishàng wújí zǒngzhēn Wénchāng dàdòng xiānjīng 太上無極總真文昌大洞仙經 (DZ 5), revealed in 1168 to the spirit-writer Liú Ānshèng 劉安勝, revised in 1264 and supplemented in 1302. The cult’s foundational hagiography, the ninety-four-transformations Zǐtóng dìjūn huàshū 梓潼帝君化書 (DZ 170), is the standard narrative source; for a full critical study and translation see Terry F. Kleeman, A God’s Own Tale (SUNY Press, 1994). No CBDB or DILA authority record exists for Wénchāng dìjūn, who is a cult-deity rather than a historically attested human individual.