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).
Define performance budgets for critical paths
Set explicit thresholds for latency, bundle size, and CLS so regressions are caught before they reach users.
Bad example
| 1 | // No performance targets; regressions slip in unnoticed |
| 2 | export async function renderHomepage() { |
| 3 | const html = await render(); |
| 4 | return Response.json({ html }); |
| 5 | } |
Explanation (EN)
Without budgets, regressions go unnoticed until users complain. Teams cannot tell if a change is acceptable.
Objašnjenje (HR)
Bez budžeta regresije prolaze nezapaženo dok se korisnici ne požale. Tim ne zna je li promjena prihvatljiva.
Good example
| 1 | // Example: enforce a server latency budget in CI |
| 2 | const MAX_P95_MS = 300; |
| 3 |
|
| 4 | const result = await measureEndpoint("/"); |
| 5 | if (result.p95 > MAX_P95_MS) { |
| 6 | throw new Error("Performance budget exceeded"); |
| 7 | } |
Explanation (EN)
Budgets make performance a first‑class requirement. CI catches regressions before they reach production.
Objašnjenje (HR)
Budžeti čine performanse prvoklasnim zahtjevom. CI hvata regresije prije produkcije.
Notes (EN)
Budgets can target TTFB, CLS, LCP, bundle size, or p95 latency—pick what matters to the product.
Bilješke (HR)
Budžeti mogu ciljati TTFB, CLS, LCP, veličinu bundla ili p95 latenciju — odaberi što je bitno za proizvod.
Exceptions / Tradeoffs (EN)
Early prototypes can skip budgets, but add them before public launch.
Iznimke / Tradeoffi (HR)
Rani prototipi mogu preskočiti budžete, ali ih dodaj prije javnog lansiranja.