BeforeMerge

AI-native code review knowledge base. Structured rules that catch what linters miss.

Product

  • Features
  • Explore
  • Pricing
  • Docs
  • GitHub

Company

  • About
  • Blog
  • Contributors
  • Contributing

Legal

  • Privacy Policy
  • Terms of Service
  • MIT License

© 2026 BeforeMerge. Built by Peter Krzyzek

BeforeMerge
Features
Explore
PricingBlogContributorsInstall Guide
2Sign In
FeaturesExplore
RulesSkillsKnowledgePrompts
PricingBlogContributorsInstall Guide
Sign In

Explore

Browse 225 rules, 42 knowledge articles, and 28 prompt templates across security, performance, architecture, and quality.

225 rules

Prevent Unnecessary Re-renders from Unstable References

HIGH

Inline objects, arrays, and functions as props create new references every render, defeating React.memo and causing cascading re-renders across the tree.

usecallbacknextjs
Next.js

Avoid Stale Closure Bugs in Hooks and Callbacks

MEDIUM

Event handlers and effects that capture state in closures can reference outdated values, causing silent data corruption and missed updates.

useeffectnextjs
Next.js

Prefer Server Components — Only Add 'use client' When Necessary

HIGH

Adding 'use client' unnecessarily ships component JS to the browser. Only use it when you need hooks, event handlers, or browser APIs.

nextjsbundle-size
Next.js

Parallelize Independent Async Operations

CRITICAL

Sequential await calls on independent operations create request waterfalls. Use Promise.all or Suspense boundaries to parallelize.

nextjsasync
Next.js

Eliminate N+1 Database Queries

CRITICAL

Fetching related data inside loops creates N+1 queries that scale linearly with data size. Use eager loading or batch queries instead. [CWE-400]

drizzlenextjs
Next.js

Use Stable, Unique Keys for List Items (Never Index)

MEDIUM

Using array indices as key props causes incorrect state preservation, UI corruption, and degraded performance when lists are reordered or filtered.

nextjsReact
Next.js

Use next/image Instead of Raw img Tags

HIGH

Raw <img> tags skip automatic optimization, lazy loading, and responsive sizing. next/image provides WebP/AVIF conversion, blur placeholders, and CLS prevention.

Imagesnextjs
Next.js

Use next/font Instead of External Font Loading

MEDIUM

External font loading from Google Fonts or CDNs causes layout shift and render-blocking requests. next/font self-hosts fonts with zero layout shift.

nextjsfonts
Next.js

Use Dynamic Imports for Heavy Client Components

HIGH

Large client libraries loaded synchronously block the initial page load. Use next/dynamic or React.lazy to code-split and load them on demand.

nextjsdynamic-imports
Next.js

Avoid Barrel File Imports in Client Components

HIGH

Barrel file imports in Client Components force bundlers to load entire libraries. Use direct imports or Next.js optimizePackageImports.

nextjsimports
Next.js

Implement loading.tsx and error.tsx at Every Route Segment

MEDIUM

Missing loading.tsx causes full-page spinners instead of granular streaming. Missing error.tsx lets errors crash parent layouts instead of being contained.

nextjssuspense
Next.js

Break Up God Components Into Focused, Composable Units

MEDIUM

Components handling data fetching, business logic, state, and rendering are hard to test and maintain. Decompose by responsibility.

single-responsibilitycomponents
Next.js

Add Error Boundaries Around Unreliable Content

MEDIUM

Without error boundaries, a single component failure crashes the entire page. Use error.tsx and granular ErrorBoundary wrappers.

nextjsresilience
Next.js

Keep API Route Handlers Thin — Delegate to Services

CRITICAL

API routes with business logic are hard to test, audit, and secure. Keep route handlers under 100 lines by delegating to service classes. [CWE-1064]

single-responsibilitythin-controllers
Architecture

Rate Limit Every API Route with Appropriate Buckets

HIGH

API routes without rate limiting enable brute force, DDoS, and credit exhaustion attacks. Apply tiered rate limits as the first middleware. [CWE-770 · A04:2021]

middlewarenextjs
Architecture

Never Expose Raw Errors or Stack Traces to Clients

MEDIUM

Returning raw error messages or stack traces leaks implementation details. Return generic messages with a requestId for server-side debugging. [CWE-209]

nextjsinformation-disclosure
Architecture

Validate CSRF Tokens on All State-Changing Requests

HIGH

State-changing API routes without CSRF validation allow cross-site request forgery. Validate tokens on POST/PUT/PATCH/DELETE with known exemptions. [CWE-352 · A01:2021]

middlewarenextjs
Architecture

Use Consistent ServiceResult Type for All Service Returns

MEDIUM

Inconsistent error handling with thrown exceptions, returned nulls, and ad-hoc error objects makes callers fragile. Use a discriminated union ServiceResult type.

discriminated-unionservice-result
Architecture

Search Existing Code Before Creating New Utilities

MEDIUM

Creating new components or utilities without checking if one already exists leads to duplicated logic and inconsistency. Search existing code first.

discoverabilitycode-reuse
Architecture

Use Scoped Loggers with Structured Context

MEDIUM

Bare console.log statements with no context make production debugging impossible. Use scoped loggers with errorId, userId, and structured metadata.

productionquality
Architecture

Extract Duplicated Logic After the Third Occurrence

HIGH

Same logic duplicated in 3+ places creates consistency bugs and maintenance burden. Extract to the appropriate layer after the third occurrence.

qualityrefactoring
Architecture

Prefer Server Components Over useEffect + Fetch for Data Loading

HIGH

Using useEffect + useState for data fetching creates waterfalls, loading spinners, and unnecessary API routes. Use async Server Components instead.

useeffectnextjs
Architecture

Stream Slow Content with Suspense Boundaries

MEDIUM

Pages that block until all data loads show nothing until everything is ready. Wrap slow components in Suspense to stream content progressively.

nextjsloading-states
Architecture

Use Promise.all for Independent Data Fetches

HIGH

Serial await statements for independent data fetches create request waterfalls. Use Promise.all to parallelize and cut load times by 2-5x.

promise-allnextjs
Architecture

Automate these checks on every PR

BeforeMerge scans your pull requests against these rules automatically. Get actionable feedback before code ships to production.

Join WaitlistLearn More
Sort:
Previous1...678...10Next