Caotangji 草堂記 "Records on a thatched cottage" is an essay written during the Tang period 唐 (618-907) by the writer Bai Juyi 白居易 (772-846). It is included in Bai's collected writings Baishi Changqing ji 白氏長慶集 and the series Sibu congkan 四部叢刊.
In 815, the Chancellor-in-chief, Wu Zhiheng 武之衡 (758-815) was killed by bandits. Bai Juyi, having submitted a forceful memorial demanding the capture of the culprits, offended the powerful and was impeached. He was demoted to the post of vice prefect (sima 司馬) of Jiangzhou 江州 (present-day Jiujiang 九江, Jiangxi) and temporarily resided at Mount Lu 廬山. In 817, Bai wrote to Yuan Zhen 元稹 (779-831) that he had visited Mount Lu and was profoundly moved by the clouds, waters, springs, and rocks. He adored it so much that he could not part from it, and thus constructed where he built a garden residence called the Thatched Cottage (Caotang 草堂). At that occasion, he wrote the Caotangji.
The essay initially describes the geographical location and topography of the cottage, then portrays its architectural and garden features along with the surrounding atmosphere, and finally recounts the poet's own life there—his dwelling, wanderings, and reflections. The work mainly highlights two aspects of Bai Juyi's garden philosophy. It encompasses the pursuit of a simple, elegant aesthetic in garden architecture and landscaping, and the realisation of artistic and philosophical principles of Chinese garden design, expressed as "things invite the spirit (wu you qi sui 物誘氣隨), the exterior harmonises with the interior (wai shi nei he 外適內和), and the body is tranquil while the mind is serene" (ti ning xin tian 體寧心恬). This idea holds a significant place in the history of Chinese garden thought. Chinese garden art and aesthetics did not achieve full maturity until the publication of the book Yuanye 園冶 in the Ming period 明 (1368-1644). Bai Juyi's insights can therefore be seen as a historical forerunner to later developments in Chinese garden art and aesthetic theory.
Later, in 829, Bai Juyi requested leave due to illness and returned to Luoyang 洛陽, where he built a garden commonly called Lüdaoli 履道里. He wrote the poem Chishang pian 池上篇 "On the pond" with a preface describing the construction of the garden, its landscapes, and his personal reflections. The garden design ideas expressed there are similar to those in the Caotangji.