- Follow C11/C17 standard. Use `snake_case` for functions and variables, `UPPER_CASE` for macros and constants.
- Always check return values from system calls and allocations. Never ignore `malloc` returning `NULL`.
- Always free dynamically allocated memory in the reverse order of allocation — use `goto cleanup` pattern for multi-resource functions.
- Use `static` for file-scoped functions and variables to limit visibility — public API functions go in the header, everything else is `static`.
- Use `const` for parameters and variables that should not be modified.
- Initialize all variables at declaration. Uninitialized memory is undefined behavior.
- Free all allocated memory. Use a consistent allocate/free pattern — every `malloc` must have a corresponding `free`.
- Prefer `sizeof(*ptr)` over `sizeof(Type)` in allocations for type-safety.
- Use `static` for file-scoped functions and variables to limit visibility.