Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP1universalStack: node
performancecachingfeature-flagsdatabase
Cache or pass through feature-flag values instead of a DB lookup per request
A flag checked on every request should be cached (short TTL) or resolved once and passed through the call chain, not re-fetched from the DB each invocation.
PR: hegnar-journalist-boost · org-mining-deep-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | async function handleAiRequest(req) { |
| 2 | // hits the DB on every single AI request |
| 3 | const on = await FlagsService.isFeatureEnabled('x'); |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | // resolve once, pass down |
| 2 | const flagOn = await flags.isEnabledCached('x', { ttlMs: 30_000 }); |
| 3 | async function handleAiRequest(req, flagOn: boolean) { /* use flagOn */ } |
Explanation (EN)
Objašnjenje (HR)