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 158 rules, 25 knowledge articles, and 25 prompt templates across security, performance, architecture, and quality.

158 rules

Do Not Mix Controlled and Uncontrolled Input Patterns

MEDIUM

Switching between controlled (value prop) and uncontrolled (defaultValue/no value) patterns on the same input causes React warnings and unpredictable behavior.

controlled-componentsforms
beforemerge-react-review

Avoid Inline Object/Array/Function Creation in JSX Props

HIGH

Creating new objects, arrays, or functions inline in JSX causes child components to re-render on every parent render due to referential inequality.

usecallbackReact
beforemerge-react-review

Virtualize Large Lists Instead of Rendering All Items

HIGH

Rendering thousands of DOM nodes for long lists causes slow initial render, high memory usage, and scroll jank. Use virtualization (react-window, TanStack Virtual).

tanstack-virtualReact
beforemerge-react-review

Memoize Expensive Computations with useMemo

HIGH

Running expensive calculations (sorting, filtering, transforming large datasets) on every render wastes CPU cycles. Use useMemo to cache results.

computationReact
beforemerge-react-review

Split Large Contexts to Prevent Unnecessary Consumer Re-renders

HIGH

Putting too much state in a single React Context causes all consumers to re-render when any value changes. Split into focused contexts.

State ManagementReact
beforemerge-react-review

Colocate State with the Components That Use It

MEDIUM

Lifting state higher than necessary causes unnecessary re-renders in the parent and all siblings. Keep state as close as possible to where it is consumed.

State ManagementReact
beforemerge-react-review

Eliminate Prop Drilling Through 3+ Component Levels

MEDIUM

Passing props through 3+ levels of intermediate components that don't use them creates tight coupling and maintenance burden. Use context, composition, or state management.

ReactContext
beforemerge-react-review

Extract Duplicated Stateful Logic into Custom Hooks

MEDIUM

Duplicating stateful logic (useState + useEffect patterns) across multiple components leads to inconsistency and maintenance burden. Extract into reusable custom hooks.

Reactarchitecture
beforemerge-react-review

Prefer Composition Over Monolithic Conditional Rendering

MEDIUM

Monolithic components with deeply nested ternaries and conditionals are hard to read, test, and extend. Use composition patterns (children, render props, compound components).

compound-componentsReact
beforemerge-react-review

Sanitize All HTML Before Using dangerouslySetInnerHTML

CRITICAL

dangerouslySetInnerHTML bypasses React's XSS protection. Always sanitize HTML from external sources with DOMPurify before rendering. [CWE-79 · A03:2021]

Sanitizationnextjs
beforemerge-nextjs-review

Never Build Database Queries with String Concatenation

CRITICAL

String concatenation in database queries creates injection vulnerabilities. Always use parameterized queries or ORM query builders. [CWE-89 · A03:2021]

drizzlenextjs
beforemerge-nextjs-review

Validate All Server Action Inputs at the Boundary

CRITICAL

Server Action arguments are deserialized from untrusted HTTP requests. Validate every input with Zod to prevent type confusion and injection attacks. [CWE-20, CWE-502 · A08:2021]

nextjsinput-validation
beforemerge-nextjs-review

Authenticate Server Actions Like API Routes

CRITICAL

Server Actions are public HTTP endpoints not protected by middleware or layout guards. Always verify authentication inside each action. [CWE-862 · A01:2021]

nextjsauthentication
beforemerge-nextjs-review

Authenticate Route Handlers Like Server Actions

CRITICAL

App Router route handlers (GET, POST, PUT, DELETE) are public HTTP endpoints. Every exported function must independently verify auth — middleware alone is insufficient. [CWE-862 · A01:2021]

nextjsauthentication
beforemerge-nextjs-review

Implement Rate Limiting on Sensitive Endpoints

HIGH

Next.js has no built-in rate limiting. Without it, login, signup, password reset, and Server Actions are vulnerable to brute force and credential stuffing. [CWE-799, CWE-307 · A04:2021]

nextjsauthentication
beforemerge-nextjs-review

Prevent Path Traversal in API Routes and File Operations

CRITICAL

API routes that construct file paths from user input without sanitization allow attackers to read or write arbitrary files using ../ sequences. [CWE-22 · A01:2021]

nextjspath-traversal
beforemerge-nextjs-review

Validate All Redirect URLs

CRITICAL

Unvalidated redirect URLs enable phishing attacks via your domain. Always validate against an allowlist or restrict to relative paths. [CWE-601 · A01:2021]

middlewarenextjs
beforemerge-nextjs-review

Never Rely Solely on Middleware for Authorization

CRITICAL

Next.js middleware can be bypassed (CVE-2025-29927). Always enforce auth checks inside route handlers and Server Actions as defense-in-depth. [CWE-287 · A01:2021]

middlewarenextjs
beforemerge-nextjs-review

Set Secure Cookie Attributes (HttpOnly, Secure, SameSite)

HIGH

Session cookies without HttpOnly, Secure, and SameSite are vulnerable to XSS theft and CSRF. The Next.js cookies() API does not enforce secure defaults. [CWE-614, CWE-1004 · A05:2021]

sessionnextjs
beforemerge-nextjs-review

Validate File Uploads (Type, Size, Name, Content)

HIGH

Accepting file uploads without validating MIME type, size, extension, and filename sanitization enables code execution, storage abuse, and path traversal. [CWE-434 · A04:2021]

nextjsfile-upload
beforemerge-nextjs-review

Understand CSRF Limitations in Server Actions

HIGH

Next.js Server Actions rely on Origin header checks, not CSRF tokens. Reverse proxies and misconfigured allowedOrigins can bypass this protection. [CWE-352 · A01:2021]

nextjsauthentication
beforemerge-nextjs-review

Restrict CORS to Specific Allowed Origins

HIGH

Setting Access-Control-Allow-Origin to wildcard or reflecting the request Origin lets any website make authenticated requests to your API. [CWE-942 · A05:2021]

nextjscors
beforemerge-nextjs-review

Never Pass Secrets or Sensitive Data to Client Components

CRITICAL

Props passed to Client Components are visible in the browser. Never pass API keys, tokens, or full database records to client code. [CWE-200 · A01:2021]

nextjsdata-exposure
beforemerge-nextjs-review

Prevent Cache Poisoning in ISR and SSR Routes

HIGH

Misconfigured caching of Next.js ISR/SSR responses allows attackers to poison cached pages with blank or malicious content, causing DoS for all users. [CWE-444 · A05:2021]

nextjsisr
beforemerge-nextjs-review

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:
Previous1234567Next