Fenmen gujin leishi 分門古今類事 is an encyclopaedia about extraordinary matters (zhiguai 志怪) compiled during the Song period 宋 (960-1279) by an unknown person. A paragraph in fascicle 8 hints at the son of Song Ruzhi 宋如璋, who obtained a government post in 1117. The son might have been the compiler. The preface names a certain Weixinzi 委心子 as the person responsible for the book.
It has a length of 20 juan and is divided into 20 chapters, namely Portents of imperial Fate (Diwang yunzhao 帝王運兆), Portents of strange events (Yizhao 異兆), Portents from dreams (Mengzhao 夢兆), Portents from physiognomy (Xiangzhao 相兆), Portents from divination (Buzhao 卜兆), Portents from prophecies (Chenzhao 讖兆), Auspicious portents (Xiangzhao 祥兆), Marriage portents (Hunzhao 婚兆), Miscellaneous records of grave portents (Muzhao zazhi 墓兆雜志), Increases from doing good (Wei shan er zeng 為善而增), and Losses from doing evil (Wei wu er sun 為惡而損).
Most of the material is drawn from historical works as well as Tang- 唐 (618-907) and Song-period unofficial histories and anecdotal fiction, to which are added some stale and far-fetched commentaries. The book's aim is to demonstrate that the rise and fall, success and failure of all things are predetermined, asserting that a person's prosperity or decline, wealth or poverty, lifespan, marriage, and so forth are all fated, and that these are revealed through certain portents. These superstitious elements are pointless and should be discarded.
Nonetheless, the book draws on a wealth of sources, referencing more than 160 works. It also includes a significant number of Tang and Song tales, which can serve as material for the study of ancient fiction. Furthermore, the book preserves some lost writings, which are of considerable reference value for the study of Northern Song fiction. Examples of lost texts include Chengdu guangji 成都廣記, Gaiwenlu 該聞錄, Guangde shenyi lu 廣德神異錄, Tang-Song yishi 唐宋遺史, Binxianlu 賓仙傳, or Shuyiji 蜀異記.
Its circulation has been limited, and it is not recorded in the bibliographical treatise of the official dynastic history Songshi 宋史. The text is included in the series Shiwanjuanlou congshu 十萬卷樓叢書 (titled Xinbian fenmen gujin leishi 新編分門古今類事), Siku quanshu 四庫全書 and Congshu jicheng chubian 叢書集成初編. In 1987, the Zhonghua Shuju 中華書局 published a modern, commented edition.