Slave codes were laws enacted in the American colonies and later in the United States to control and regulate enslaved people. These codes restricted the rights and freedoms of slaves, enforcing their servitude and preventing them from gaining autonomy. They also defined the legal status of enslaved individuals and enforced punishments for various offenses.