Rules Hub
Coding Rules Library
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Keep dev, staging, and prod as similar as possible
Avoid environment-only behavior; differences should be config and data, not code paths.
Bad example
| 1 | // ❌ Environment-specific logic changes behavior |
| 2 | export function getCacheTtlMs() { |
| 3 | if (process.env.NODE_ENV === "development") return 0; |
| 4 | // prod behaves completely differently |
| 5 | return 1000 * 60 * 10; |
| 6 | } |
Explanation (EN)
When dev behaves fundamentally differently, you can’t trust staging results and you ship surprises to production.
Objašnjenje (HR)
Kad se dev ponaša bitno drugačije, ne možeš vjerovati stagingu i iznenađenja završe u produkciji.
Good example
| 1 | // ✅ Same behavior; only config differs per deploy |
| 2 | import { z } from "zod"; |
| 3 |
|
| 4 | const EnvSchema = z.object({ |
| 5 | CACHE_TTL_MS: z.coerce.number().int().nonnegative() |
| 6 | }); |
| 7 |
|
| 8 | const env = EnvSchema.parse(process.env); |
| 9 |
|
| 10 | export function getCacheTtlMs() { |
| 11 | return env.CACHE_TTL_MS; |
| 12 | } |
Explanation (EN)
Keeping environments similar makes testing meaningful. You tune behavior through config rather than shipping different code paths.
Objašnjenje (HR)
Slična okruženja čine testiranje smislenim. Ponašanje se podešava konfiguracijom umjesto različitim code pathovima.
Notes (EN)
This comes from the 12-Factor recommendation to keep dev/staging/prod as similar as possible.
Bilješke (HR)
Ovo dolazi iz 12-Factor preporuke da dev/staging/prod budu što sličniji.
Exceptions / Tradeoffs (EN)
Development-only tooling is OK (debug logs, hot reload), but business logic must remain consistent.
Iznimke / Tradeoffi (HR)
Dev-only tooling je OK (debug logovi, hot reload), ali business logika mora ostati ista.