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
3Sign In
FeaturesExplore
RulesSkillsKnowledgePrompts
PricingBlogContributorsInstall Guide
Sign In

Explore

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

Sort:
Previous1...567...15Next

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

354 rules

Return 201 Created with a Location Header on Resource Creation

HIGH

On successful creation respond with 201 Created, a Location header pointing to the new resource, and ideally its representation.

ArchitectureAPI Design

Support Filtering and Sorting via Query Parameters

MEDIUM

Expose filtering, sorting, and field selection through query parameters rather than proliferating bespoke endpoints.

Architecture

Use Consistent Naming Conventions

MEDIUM

Use plural nouns for collections and one consistent casing (e.g. snake_case or camelCase) for fields across the entire API.

Architecture

Authenticate and Authorize Every Non-Public Endpoint

CRITICAL

Require authentication on all non-public routes and enforce per-resource authorization (object-level) on every request.

SecurityAPI Design

Paginate All Collection Endpoints

HIGH

Return collections in bounded pages with a default and maximum page size, exposing next/prev cursors or links.

Architecture

Never Leak Internals or Stack Traces in Error Responses

CRITICAL

Return sanitized error messages for 4xx/5xx; log full stack traces server-side only and never expose them to clients.

SecurityAPI Design

Return a Consistent, Structured Error Body

HIGH

Every error response should share one machine-readable shape (code, message, details) so clients can parse failures uniformly.

Architecture

Make POST Creates Idempotent via Idempotency Keys

HIGH

Accept a client-supplied Idempotency-Key header on create/payment endpoints so retried requests do not create duplicate resources.

Architecture

Use HTTP Methods According to Their Semantics

HIGH

GET must be safe and idempotent, PUT/DELETE idempotent, and POST for non-idempotent creates. Never mutate state on a GET.

Architecture

Use Resource-Oriented (Noun) URLs

MEDIUM

Model endpoints as nouns representing resources, not verbs. Let HTTP methods express the action instead of encoding it in the path.

Architecture

Use three distinct Supabase client types

CRITICAL

Use createClient() for authenticated pages (RLS enforced), createAdminClient() for server-side writes (service_role), and createReadOnlyClient() for public pages (anon key).

Securitynextjssupabase

Never fetch the same data in both layout and page

MEDIUM

Supabase client calls are NOT automatically deduplicated like fetch(). Querying the same data in layout.tsx and page.tsx doubles database load.

Performancenextjssupabase

Remember the Supabase query builder is immutable

HIGH

Supabase's .eq(), .filter(), .order() return new builder objects. Calling them without reassignment does nothing.

Qualitynextjssupabase

Query Supabase directly in server components — skip API routes

HIGH

Server components can query Supabase directly. Don't create API route middlemen just to proxy Supabase queries.

Architecturenextjs

Use server components for data fetching by default

HIGH

Fetch data in async server components instead of client-side useEffect + fetch patterns.

Performancenextjssupabase

Never expose the service_role key to the client

CRITICAL

The SUPABASE_SERVICE_ROLE_KEY must never be in a NEXT_PUBLIC_ env var or imported in "use client" files.

Securitynextjssupabase

Mark server modules with import "server-only"

HIGH

Add import "server-only" to any module that uses secrets, database connections, or server-only APIs.

Securitynextjssupabase

Call auth.getUser() immediately after creating the server client in middleware

CRITICAL

Per Supabase docs: do not run code between createServerClient and supabase.auth.getUser(). A simple mistake could cause random logouts.

Securitynextjssupabase

Use moddatetime triggers for updated_at columns

MEDIUM

Use database triggers to auto-update updated_at instead of setting it in application code.

Qualitynextjssupabase

Use next/image for all images

HIGH

Use the Image component from next/image instead of raw HTML img tags. It auto-optimizes format, size, and loading.

Performancenextjssupabase

Keep .env.example in sync with actual environment variables

HIGH

Maintain a .env.example file with all required variables (no values). New developers can't set up the project without it.

Qualitynextjssupabase

Write restrictive RLS policies — deny by default

CRITICAL

RLS defaults to deny all. Only add the specific policies you need. Never use USING (true) on private tables.

Securitynextjssupabase

Add indexes on foreign keys and common query filters

MEDIUM

PostgreSQL does NOT auto-index foreign keys. Queries filtering by organization_id or repository_id will full-table-scan without explicit indexes.

Performancenextjssupabase

Return the supabaseResponse object unchanged from middleware

HIGH

Creating a new NextResponse without copying Supabase cookies breaks session management and causes random logouts.

Qualitynextjssupabase
API Design
API Design
API Design
API Design
API Design
API Design
API Design
Next.js + Supabase Standards
Next.js + Supabase Standards
Next.js + Supabase Standards
supabase
Next.js + Supabase Standards
Next.js + Supabase Standards
Next.js + Supabase Standards
Next.js + Supabase Standards
Next.js + Supabase Standards
Next.js + Supabase Standards
Next.js + Supabase Standards
Next.js + Supabase Standards
Next.js + Supabase Standards
Next.js + Supabase Standards
Next.js + Supabase Standards