Shi Kefa took the imperial examination and obtained a jinshi degree in 1628. He was appointed as an official in Xi'an, before subsequently serving as a yuanwailang and langzhong in the Ministry of Revenue. In 1635 he followed the general Lu Xiangsheng to suppress peasant revolts throughout the land. Two years later, he was promoted to yushi on the recommendation of the minister Zhang Guowei, and was also appointed as xunfu of Anqing, Luzhou, Taiping, Chizhou, and various counties in Henan, Jiangxi and Huguang provinces. In 1641, he was put in charge of the Caoyun system. In the seventh month of 1643, he was appointed as Grand Secretary of the Ministry of War in Nanjing.
In the third lunar month of 1644, rebel forces led by Li Zicheng captured the Ming capital Beijing and the Chongzhen Emperorcommitted suicide. The following month, Wu Sangui defected to the Qing dynasty and opened Shanhai Pass, allowing the Qing armies to seize control of Beijing from Li Zicheng's rebel forces and overrun most of northern China. When news of the Chongzhen Emperor's death reached Nanjing, there was much debate on who would be the new Ming emperor. Even though Shi Kefa was effectively the leader of the Ming loyalists in Nanjing, he was unable to make a decision on the issue. In the fifth lunar month, Fengyang's Viceroy, Ma Shiying, and others supported the prince Zhu Yousong to take the throne, and Zhu became the Hongguang Emperor of the Southern Ming dynasty. For his effort, Ma Shiying won the appreciation of Hongguang and replaced Shi Kefa as the effective head of government. In the face of Li Zicheng's rebel forces and the Qing armies, Shi Kefa advocated the policy of allying with Qing to eliminate the rebels first, then drive the Qing forces back north. However, the officials in the Southern Ming imperial court were disunited as they were more interested in pursuing their personal interests. The Southern Ming dynasty gradually weakened under the pressure of internal political struggle and the resignation of several officials. After losing his influence in the imperial court, Shi Kefa requested to be dispatched north to supervise defenses on the northern border. Due to internal conflict among the Ming generals along the border, Shi Kefa was unable to establish a strong defense. In the fourth lunar month of 1645, Zuo Liangyu led an army from Wuhan to attack Ma Shiying and Ruan Dacheng. Ma Shiying ordered Shi Kefa to set up defenses at the northern border to resist Zuo Liangyu from the east. Zuo Liangyu was eventually defeated by Huang Degong while his army surrendered. Xuyi also surrendered to Qing and Sizhou fell to Qing. Shi Kefa moved back to Yangzhou and continued resisting the Qing invaders there.
Defence of Yangzhou
In the fifth lunar month of 1645, Qing forces led by the Manchu prince Dodo besieged Yangzhou. Shi Kefa sent a messenger to request reinforcements. His subordinate Liu Zeqing escaped north to Huai'an, while only Liu Zhaoji came to Shi Kefa's aid. The Qing regent Dorgon wrote to Shi Kefa, asking for his surrender, but Shi declined. Shi Kefa's response, titled Reply to Dorgon's letter, was noted for its neither servile nor overbearing tone, and was circulated among later generations. Subsequently, Shi Kefa entrusted his subordinate Shi Dewei, whom he had adopted as a godson, with his funeral arrangements, saying that he wished to be buried at Plum Blossom Ridge after his death. On the 24th day, Qing armies bombarded Yangzhou with cannon fire and the city fell that night. Shi Kefa attempted suicide by slitting his throat but failed. He then ordered Shi Dewei to kill him but Shi Dewei tearfully refused and did not dare to look up at his godfather. Shi Kefa then shouted "I'm Military Inspector Shi. Quickly kill me!" and was captured as a prisoner-of-war. Dodo tried to persuade Shi Kefa to surrender and serve him, saying, "Previously we sent you a letter politely asking for your surrender, but you refused. Now that you've fulfilled your loyalty and righteousness, you should take on a new important responsibility – help me conquer Jiangnan." Shi Kefa replied, "I fall together with the city. My decision will not change. Even if I'm torn to pieces, my feelings will be as sweet as maltose. But do not harm the thousands of lives in Yangzhou!" Shi Kefa was then executed. Dodo was infuriated by the heavy casualties sustained by his army in conquering Yangzhou so he ordered that the entire city be put to the sword. Twelve days after Shi Kefa's death, his remains could not be found. A year later in 1646, Shi Dewei buried Shi Kefa's headdress and garments at Plum Blossom Ridge outside the Tianning Gate of Yangzhou. The Qing writer Quan Zuwang later wrote the Tale of Plum Blossom Ridge to describe the event. The Shi Kefa Memorial, a shrine devoted to the memory of Shi Kefa, is located in present-day Yangzhou.
Calligraphy
Shi Kefa was said to have been an individual of great energy and integrity, qualities reflected in his calligraphy, frequently in cursive and semi-cursive style. Shi Kefa's calligraphy is of the late Ming period style among other Ming literati, with a preference for long compositions in a flourishing manner.