Zhaijing 宅經 "Classic of houses" is China's oldest surviving book on geomancy. Authorship was traditionally attributed to the Yellow Emperor 黃帝, so that it is also known under the title of Huangdi zhaijing 黃帝宅經.
The imperial bibliography Jingji zhi 經籍志 in the official dynastic history Suishu 隋書 lists the books Zhai jixiong lun 宅吉兇論 and Xiangzhaitu 相宅圖, and the bibliography in the history Jiutangshu 舊唐書 mentions the book Wuxing zhaijing 五姓宅經. All these texts are said to have been written by the Yellow Emperor. There are in total 29 books called Zhajing listed in ancient book catalogues. Some of them were allegedly written by well-known persons as the astronomer and mathmatician Li Chunfeng 李淳風 (602-670) or the musician Lü Cai 呂才 (606-665) which shows that there was no need to refer to the Yellow Emperor. Nevertheless, it was custom in the realm of divination and mantics to see the highly venerated ancestor of Chinese culture as a writer.
The identity of the 2-juan-long transmitted Zhaijing is not wholly clear, but it seems that the book Xiangzhaijing 相宅經 listed in the bibliography in the history Songshi 宋史 was the precursor of the received text.
The Zhaijing describes the method to find out an ideal place for a house with the help of the power of the forces Yin and Yang 陰陽, the Heavenly Stems 天干 and Earthly Branches 地支, as well as the Eight Trigrams 八卦. The Eight Trigrams determine the exact position and directly point at auspicious or non-auspicious spots.
The book begins with a preface (xu 序) stressing the importance of geomancy. The general discussion (zonglun 總論) describes the influence of twenty-four so-called "ways" (lu 路) that reflect the influence of Yin and Yang. It also gives a short overview over other books on the divinatory art of geomancy. The chapter Xiuzhai cidi fa 修宅次第法 explains the arrangement and sequence of steps to determine the place and structure of a building, as well as which factors are to be avoided. The last part of the book includes explained illustrations on the influence of Yang and Yin on building sites.
The Zhaijing is included in the series Siku quanshu 四庫全書, Xuejin taoyuan 學津討原, Shuofu 說郛, Yimen guangdu 夷門廣牘, Jindai mishu 津逮秘書, the Daoist Canon Daozang 道藏 and collection Chongwen shuju huike shu 崇文書局匯刻書. Among the original texts discovered in Dunhuang 敦煌, a book called Zhaijing 宅經 is included, which is not identical to the transmitted text.