- Use `local` for all variables by default — global variables in Lua are accessible from any file and cause hard-to-trace bugs.
- Use `snake_case` for variables and functions, `PascalCase` for class-like table constructors, and `UPPER_SNAKE_CASE` for module-level constants.
- Return a module table at the end of each file (`local M = {}; ... return M`) — the caller assigns it to a local via `local mod = require('mod')`.
- Use `local function name()` instead of `name = function()` — the local form is visible to recursive calls and is slightly faster.
- Use `#t` only on sequence tables (integer keys 1..n with no holes) — for sparse or mixed tables, track length manually or use `table.maxn` (Lua 5.1).
- Prefer `ipairs` for sequential array iteration and `pairs` for hash-table iteration — never rely on `pairs` for ordered output.
- Add a `---@param` and `---@return` LuaDoc comment above public functions for IDE type inference and documentation.