The short answer
A Texas real estate inspection is not a code inspection. TREC's general limitations say the inspector is not required to determine compliance with codes, regulations or manufacturer installation instructions, and the REI 7-6 preamble states that the inspection is not a code-compliance inspection. A Deficient box means the inspector reported a deficiency under TREC's definition, which turns on performance and on hazards specified by the standards. That overlaps with building codes in many places, but it is not the same test, and a report should not be read as a list of code violations or as a certificate of compliance.
Two different yardsticks
The building code is adopted by a city or county, edition by edition, and enforced by its building official through permits and inspections during construction. It governs how work must be done when it is permitted.
TREC's standards of practice govern what a licensed inspector must inspect and report for a buyer or seller. A deficiency is a condition that adversely and materially affects performance, measured against accepted industry standard practice with age and wear considered, or that constitutes a hazard as the standards specify.
Many deficiencies the standards list echo modern code requirements, such as GFCI and AFCI protection, smoke alarms and tamper-resistant receptacles. But the standards apply them to every house regardless of when it was built, without deciding whether the house complied with the code in force at the time. See conditions not required to be updated.
When a report mentions "code"
Some inspectors write that a condition "does not meet current code" or cite a code section as context. TREC's published answers address this. TREC does not require inspectors to apply building codes; if a report states that something is a code violation, the client can ask the inspector for the basis of that statement, or contact local code enforcement. TREC also says that whether a condition is a hazard is left to the inspector's reasonable judgment.
So a code reference in a report is the inspector's explanation, not a finding by the authority that enforces the code.
What a report cannot tell you about codes
Whether work was permitted. The general limitations say inspectors are not required to review historical records. Permit history is held by the local building department.
Whether the house complied when built. That depends on the code edition and local amendments in force at the time, which the inspection does not establish.
Whether a later addition was approved. Again, a permit question.
Whether an item meets the manufacturer's installation instructions. Outside the inspection except where the standards specify it.
Where codes do matter to a buyer
Unpermitted work can matter for insurance, for a lender, and for future permits. The inspection report does not imply insurability, as the preamble states. A buyer with concerns about an addition, a garage conversion or significant remodeling can ask the seller about permits, check the seller's disclosure, and ask the local building department for the permit record.
Code requirements also matter when repairs are done. Paragraph 7F of the TREC resale contract requires the seller to obtain any required permits for agreed repairs and to use licensed persons where a license is required. A repair request can reasonably ask for work to be permitted where the law requires it.
Common mistakes
Treating Deficient as "fails code". The definitions differ.
Treating no Deficient as "meets code". The inspection does not determine compliance.
Demanding that a seller bring an older house up to current code. The form says conditions acceptable when built are not necessarily required to be updated; whether to correct them is a matter for the parties.
Relying on an inspector's code citation without asking its basis. TREC itself suggests asking.
What to do
Read code references in a report as explanations. For anything that turns on permits or compliance, ask the seller and check with the local building department. For hazards, focus on the condition and its correction rather than on whether it violates a code edition. If a condition matters to your lender or insurer, ask them early in the option period.
Where the rules come from
The general limitation on code compliance is in 22 TAC 535.227. The preamble statement is on form REI 7-6. TREC's answers on code violations and hazards are on its inspector questions page. The permit requirement for agreed repairs is in paragraph 7F of TREC form 20-19.