Sima Qian was born around 145 BCE into the office he would make immortal: his father Sima Tan held the post of taishi at the Han court, Grand Historian, a position combining the keeping of records with astronomy and the calendar. The father conceived the project of a complete history of the known world from the Yellow Emperor to the present, and on his deathbed, by the son's own account, charged him to finish it. Sima Qian traveled widely in his youth, visiting the sites and gathering the local traditions he would later weave into the book, and succeeded to the office around 108 BCE.
In 99 BCE he ruined himself by speaking in defense of Li Ling, a general who had surrendered to the Xiongnu after a doomed campaign. Condemned to death, he accepted the alternative of castration, an option normally taken as more shameful than dying, and explained why in his letter to his friend Ren An: the Shiji was unfinished, and a death that left it incomplete would make his life weightless, while the book, once done, would be worth the disgrace. He finished it, roughly 130 chapters spanning dynastic annals, chronological tables, treatises on subjects from rites and music to the calendar and the Yellow River, hereditary houses and collected biographies, and died around 86 BCE. Every subsequent dynastic history in China took its structure from his.