evidence-first-agent-rules/.claude/rules/evidence-calculate-before-hardcoding.md
SHA-256 a367522b33b3ab2ad26d3605cf3fc3ce08fda33dcb8ea7c3ccabb5d184d5d742 · 1,000 bytes
Rule: loaded automatically into every session once installed.
# Calculate numbers before hardcoding them
Guessing a value (padding, offset, timeout, threshold, retry count) and nudging it until it looks right is slow and
fragile. In one mobile layout fix a guessed 32-point inset failed because the real requirement was about 84 points:
a 50-point tab bar plus a 34-point home-indicator area. Five seconds of arithmetic would have found it.
**Rule.** Before writing a hardcoded numeric value:
1. Identify the known quantities it depends on (component sizes, safe-area insets, measured latencies, limits from
documentation).
2. Write a short comment showing the calculation, for example:
```
// 50pt tab bar + 34pt home indicator = 84pt bottom inset
```
3. If a value cannot be derived, say that it is an estimate, explain where it came from, and prefer making it a named
constant that is easy to find and change.
This applies to configuration as well as code: timeouts, rate limits, cache lifetimes and batch sizes all need a
stated reason.
Shown as plain text. Invisible or direction-changing characters are displayed as <U+XXXX>.