It is not known when Yuwen Shiji was born. He was a son of the Sui Dynasty general and official Yuwen Shu, and he had at least two older brothers, Yuwen Huaji and Yuwen Zhiji (宇文智及). During the reign of Sui's founder Emperor Wen, Yuwen Shiji was, on account of his father's contributions to Sui, created the Duke of Xincheng County (新城县公). On one occasion, Emperor Wen took Yuwen Shiji into his bedroom to converse with him privately, and he was impressed by Yuwen Shiji sufficiently that he gave his granddaughter the Princess Nanyang (南陽公主) (the daughter of his son Yang Guang the Crown Prince, later Emperor Yang who was killed by Yuwen Huaji in a coup) to Yuwen Shiji in marriage. They had one son, Yuwen Chanshi (宇文禪師). Because he married a princess, he looked down at his brother Yuwen Zhiji, but appeared to have a cordial relationship with Yuwen Huaji.
In 604, Emperor Wen died and was succeeded by Yang Guang (as Emperor Yang). Yuwen Shiji's activities early in Emperor Yang's reign were unclear. He was friendly with the general Li Yuan the Duke of Tang, and was said to have discussed much about military matters with Li Yuan.
By the middle of Emperor Yang's reign, Yuwen Shiji was the director of imperial transportation. When Emperor Yang went from the eastern capital Luoyang to Jiangdu (江都, in modern Yangzhou, Jiangsu) in 616, Yuwen Shiji followed him there. When Yuwen Shu, who also followed Emperor Yang to Jiangdu, fell ill and died later in the year, Yuwen Shiji briefly resigned to observe a mourning period for his father, but was soon returned to imperial service as the deputy minister of imperial supplies.
In spring 618, Yuwen Huaji and Yuwen Zhiji, along with a number of high-level officers in Emperor Yang's elite Xiaoguo Army (驍果), were plotting a coup, but they, fearing that Yuwen Shiji, as Emperor Yang's son-in-law, would reveal the plot, did not reveal the plot to Yuwen Shiji. They soon launched the coup and killed Emperor Yang, declaring Emperor Yang's nephew Yang Hao the Prince of Qin emperor.
Yuwen Huaji retained power as regent, and he made Yuwen Shiji Neishi Ling (內史令), the head of the legislative bureau of the government. Yuwen Huaji soon abandoned Jiangdu and led the Xiaoguo Army back north, toward Luoyang. His army battled those of another rebel leader, Li Mi the Duke of Wei, but was repeatedly defeated by Li Mi. During this time, Li Yuan, who has himself taken the throne at Chang'an, establishing Tang Dynasty as its Emperor Gaozu, sent secret messengers to Yuwen Shiji, then at Liyang (黎陽, in modern Hebi, Henan), and Yuwen Shiji secretly sent messengers to him as well, offering him golden bracelets—using bracelets (環, huan, a homophone to 還, meaning "return") to show that he intended to support Tang at some point. Later, Yuwen Huaji, unable to prevail over Li Mi, crossed the Yellow River north to Wei (魏縣, in modern Handan), Yuwen Shiji suggested that he head west and submit to Tang. Yuwen Huaji refused, and instead poisoned Yang Hao and declared himself emperor of a new state of Xu. He created Yuwen Shiji the Prince of Shu (蜀王).
Subsequently, when Yuwen Huaji was further forced to retreat to Liaocheng (聊城, in modern Liaocheng, Shandong), Yuwen Shiji and Feng Deyi requested permission to leave Liaocheng to collect food supplies, and the supplies he obtained allowed Yuwen Huaji to withstand attacks from the Tang general Li Shentong (李神通, Emperor Gaozu's cousin). Later, however, Yuwen Huaji was attacked by another rebel ruler, Dou Jiande the Prince of Xia, and Dou captured Liaocheng in spring 619, executing Yuwen Huaji and Yuwen Zhiji. (Initially, Dou offered to spare Yuwen Shiji's son Yuwen Chanshi, but the Princess Nanyang, reasoning that the Sui laws required that the nephews of treasonous individuals, allowed Yuwen Chanshi to be executed.)
At the time Liaocheng fell, Yuwen Shiji and Feng were at Jibei (濟北, also in modern Liaocheng). Some of Yuwen Shiji's followers suggested that he gather his troops and attack Dou and try to take over the land north of the Yellow River. Yuwen Shiji refused, but instead headed to Chang'an with Feng and surrendered to Tang.
When Emperor Gaozu received Yuwen Shiji, he initially rebuked him, but Yuwen Shiji was able to point out that they had previously been friends and that he had offered to submit earlier. Further, Yuwen Shiji's sister was by this point Emperor Gaozu's concubine, and so Emperor Gaozu made Yuwen Shiji an official. He later served under Emperor Gaozu's son Li Shimin the Prince of Qin in defeating Liu Wuzhou the Dingyang Khan, and as a result was created his old title of Duke of Xincheng County, and was given the Princess of Shouguang County (寿光县主, a relative of Emperor Gaozu, although the relationship is not clear) as his wife. Later, in 620 and 621, he followed Li Shimin in his campaign against Wang Shichong the Emperor of Zheng, at the end of which Li Shimin defeated not only Wang, but Dou Jiande as well. After Dou's defeat, the Princess Nanyang, who had become a Buddhist nun, headed back from the Xia capital Ming Prefecture (洺州, in modern Handan) to Chang'an, and she happened to encounter Yuwen Shiji at Luoyang. Yuwen Shiji wanted her back as his wife, but she refused, stating to him, "My clan and yours have great enmity. The only reason why I am not killing you by my own hand is that you did not participate in the treasonous plot." She nevertheless ordered Yuwen Shiji to leave. Yuwen Shiji initially persisted, but she then stated, "You can see me again if you want death." Yuwen Shiji knew that she would not yield, and therefore left her.
For Yuwen Shiji's contributions in the campaign against Zheng and Xia, he was created the Duke of Ying. He was also made the Zhongshu Shilang (中書侍郎), the deputy head of the legislative bureau (中書省, Zhongshu Sheng). In 625, he was made acting Shizhong (侍中), the head of the examination bureau (門下省, Menxia Sheng), a post considered one for a chancellor, as well as the head of the household at the palace of Emperor Gaozu's crown prince Li Jiancheng. (By this point, there was an intense rivalry between Li Jiancheng and Li Shimin, although whether Yuwen Shiji participated in either of their factions is not known.)
In summer 626, Li Shimin, fearful that Li Jiancheng was about to kill him, laid an ambush for Li Jiancheng and another brother, Li Yuanji the Prince of Qi, who had supported Li Jiancheng, at Xuanwu Gate and killed them. He then effectively forced Emperor Gaozu to first create him crown prince and then yield the throne to him (as Emperor Taizong). He reorganized the government, and as part of the reorganization, Yuwen Shiji was made the Zhongshu Ling (中書令), the head of the legislative bureau and clearly a chancellor.
In 627, while Yuwen Shiji retained the title of Zhongshu Ling, he was no longer actually chancellor, as he was made the commandant at Liang Prefecture (涼州, roughly modern Wuwei, Gansu). It was said that he impressed the people of Liang Prefecture with his dignity and grace, and was able to fend off attacks from Eastern Tujue. Subsequently, he was recalled to Chang'an to serve as Dianzhong Jian (殿中監), the head of the palace affairs bureau (殿中省) – a high-level post, but one not bestowed with great powers. Later, on account of illness, he was made the prefect of Pu Prefecture (蒲州, roughly modern Yuncheng, Shanxi), but was then recalled back to Chang'an to be a minor general. He was often invited to attend Emperor Taizong's feasts, but rarely spoke of what were happening at the feasts, not even to his wife. When Emperor Taizong reviewed the contributions of the officials to the founding of Tang Dynasty, he rewarded Yuwen Shiji by creating his son the Duke of Xincheng County. In or around 635, he was again Dianzhong Jian. He died in 642 and was bestowed posthumous honors and buried near the tomb of Emperor Taizong's wife Empress Zhangsun, which later would become Emperor Taizong's tomb as well.
Yuwen Shiji was praised for his kindness and care for his younger brother or brothers, and his nephews. He was also generous to his relatives, particularly the ones who were poor. However, he was also said to live luxuriously and wastefully. There was also an incident in which Emperor Taizong showed his favor for a tree, and subsequently, Yuwen repeatedly praised the tree, drawing a rebuke from Emperor Taizong:Wei Zheng often told me to stay away from flatterers. I did not know whom he was referring to, and I thought it might be you. This proves it.
Yuwen Shiji apologized, but defended his position by stating that emperors did not often have people who would agree with them, and that he only wanted to make the emperor happy. Emperor Taizong did not punish him.
Initially, the officials in charge of considering posthumous names recommended that he be given the posthumous name Gong (恭, "alert"). The official Liu Ji, citing Yuwen's wastefulness, rejected "Gong," instead suggesting "Zong" (縱, "unvirtuous"), and that became Yuwen's posthumous name.Father: Yuwen Shu (宇文述), general of Northern Zhou, and later Sui
Princess Nanyang (南陽公主), daughter of Emperor Yang of Sui, separated after the coup d'état of his brothers in 616
Princess of Shouguang County (寿光县主), cousin of Emperor Gaozu of Tang
Yuwen Huaji (宇文化及), older half-brother
Yuwen Zhiji (宇文智及), older half-brother
Yuwen Huiji (宇文惠及), younger half-brother
Consort Yuwen (宇文昭仪), a zhaoyi-ranked concubine of Tang Gaozu's