The term ke 科 refers to legal provisions and regulations in ancient China that defined crimes and punishments. It was also known as ketiao 科條. The character 科 originally meant "measurement (斗) of grain (禾)" and later extended to mean "assessing the guilt of those who violate the law", i.e., determining crimes and sentencing criminals. Under the Qin dynasty 秦 (221-206 BCE), several legal codes were named using the term ke 課, as seen in the legal texts found among the bamboo slips of Shuihudi 睡虎地, which mention the Niuyang ke 牛羊課 "Laws related to cattle and sheep".
Beginning with the Han dynasty 漢 (206 BCE-220 CE), the term ke was used to refer to laws and regulations. A sentence in the biography of Huan Tan 桓譚 (23 BCE-56 CE; ch. 28) in the Houhanshu 後漢書 states that "Those who understand principles and are knowledgeable in law (tongyi liming falü zhe 通义理明法律者) are ordered to examine and fix the ke 科 and bi 比 provisions." The accompanying commentary defines ke as "specific provisions" (shitiao 事條). Similarly, the annotation for the phrase "golden laws and jade statutes" (jin ke yu lü 金科玉律) quoted in the anthology Wenxuan 文選 (48 Yang Xiong's 揚雄 Ju Qin mei xin 劇秦美新) explains that the term ketiao 科條 refers to laws and regulations (faling 法令).
During the reign of Emperor Wu 漢武帝 (r. 141-87 BCE) of the Han dynasty, Zhang Tang 張湯 (d. 115 BCE) and Zhao Yu 趙禹 added 409 capital punishment clauses (lüling ketiao, dabi tiao 律令科條大辟條) and 1,882 legal provisions (shi 事) to the existing code. Later, during Emperor Xuan's 漢宣帝 (r. 74-49 BCE) reign, Yu Dingguo 于定國 shortened, revised and standardised these laws and regulations.
During the Three Empires period 三國 (220~280 CE), the state of Wei 曹魏 (220-265) was the first to establish ke as an official term for legal codes, enacting codes such as the Jiazi ke 甲子科 "Provisions of the jiazi year" (see calendar) and Xin ke 新科 "New provisions". Meanwhile, the Empire of Shu 蜀漢 (221-263) formulated the Shu ke 蜀科 "Provisions of Shu". Over time, ke became one of the fundamental sources of law, alongside statutes (lü 律), decrees (ling 令), and legal precedents (bi 比). The Liang dynasty 梁 (502-557) compiled a legal code known as [Liang] Ke ([梁]科) in 30 juan. The Chen dynasty 陳 (557-589) followed the Liang system, with Fan Quan 范泉 drafting the Chen ke 陳科 in 30 juan.
In the early Northern Wei dynasty 北魏 (386-534), ke was a legal term, too, but it was replaced by the term ge 格 "regulation". As a result, the term ke gradually fell out of use.
The judicial meaning of the word ke continued in the Six Offices of Scrutiny (liuke 六科), departments of the Censorate that investigated the appropriate and legally compliant conduct of government officials.