Many of these laws existed before the Civil War, and were simply "updated" to replace the word "slave" with "freedman".
Other laws cleverly redefined common terms, introducing technical language, so that they could claim that a former slave, forced to work for little or no pay, was "serving an apprenticeship" or "being punished for vagrancy". E.g., a slave in reality, but "on paper" an apprentice, a volunteer, serving a criminal sentence, etc.
Black Codes also severely limited the ability of black citizens to gather and organize, required impossible "literacy tests" to vote, and prevented black citizens from owning any type of weapon, either outright:
Louisiana: "No freedman shall be allowed to carry firearms, or any kind of weapons."
Or via a "may issue" licensing scheme:
Alabama: "Freedmen must not carry knives or firearms unless they were licensed so to do."
[1] https://en.wikipedia.org/wiki/Black_Codes_(United_States)