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
feature-flagsenvironmentsafetyconfiguration
Guard debug/non-prod behavior behind an explicit environment check
Behavior described as dev/debug-only must be gated by an explicit environment guard (NODE_ENV or a dedicated env var), not left reachable in production just because a feature flag is on.
PR: hegnar-journalist-boost · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | if (await flags.isEnabled('dev_english_output')) { |
| 2 | applyDevEnglishExtension(); // also fires in prod if the flag is toggled |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | if (process.env.NODE_ENV !== 'production' && await flags.isEnabled('dev_english_output')) { |
| 2 | applyDevEnglishExtension(); |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)