Errors and nulls Required
Never pass null into a function
Never call a function with null to mean "use the default" or "skip this". Give the function a clear variant or an options object instead.
How to do it
Split a function that takes an optional flag into two named functions. For many optional settings, take one object whose fields have defaults. Reject null at the start of public functions.
Example
// Bad: what does null mean here?
sendInvoice(order, null, null, true);
// Good: the call says what it does
sendInvoice(order, { copyTo: accountsEmail });
sendInvoiceReminder(order);
How to check
Strict types reject null for parameters that do not allow it. Examples are TypeScript strict, PHP native types without ?, and mypy --strict. Reviewers fail calls that pass a literal null.
For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers architecture playbook: https://agentwranglers.se/playbook/architecture/errors-and-nulls/never-pass-null.