A building code is the body of law governing how buildings are designed and constructed. In the United States, codes are written as model codes by the International Code Council (IBC for commercial, IRC for residential, IECC for energy) and adopted, sometimes with local amendments, by states and municipalities. The local AHJ enforces the code through plan review, permit issuance, inspections, and certificate of occupancy.
Code compliance is not optional. Work that fails to meet code can be red-tagged, ordered torn out, or denied a certificate of occupancy. The version of the code in effect on the date of permit application typically governs (older versions stay in effect on existing buildings until renovated). Contractors must verify which code edition the AHJ has adopted before bidding, since older or amended editions can change requirements significantly.