Slave Codes were originally written to define the nature of slavery and which persons should/could be held in slavery. Early slave codes determined that a newborn child was either slave or free dependent on the condition of the mother; if she were free, so was the child and vice versa. Other codes provided that Christians at the time of their arrival could not be slaves.
Restrictive slave codes came into being after the slave revolt in Santo Domingue (present day Haiti), the only successful slave revolt in North America; and the Stono Rebellion in South Carolina which was inspired by events in Haiti. Both events sent fear through the white communities in the colonies, particularly South Carolina which had a black majority. Although armed rebellion was always a great fear, a greater fear (and more successful method of revolt) was poisoning the master. Slaves' knowledge of the forests, roots, berries, etc., made this a particularly deadly method of revenge.
Colonial slave codes prevented slaves from learning to read or write, and provided punishment to the master or other person who violated the code. Any slave who struck his master and drew blood would be put to death. Any slave who taught another to read or write was lashed. Finally, any master who killed his slave was presumed guilty of no crime, because no man would willingly destroy his own property, so it must have been an accident. The link below offers more specific detail on specific slave codes.