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:
Previous1234...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

Prefer union string literals (or `as const`) over `enum`

MEDIUM

Use union string literals instead of `enum` for simpler types, better inference, and zero runtime cost.

QualityTypeScript

Enable `noUncheckedIndexedAccess`

MEDIUM

Turn on `noUncheckedIndexedAccess` so index access includes `undefined` and forces a presence check.

QualityTypeScript

Prefer `readonly`/immutable types where possible

MEDIUM

Mark properties and arrays `readonly` so accidental mutation is a compile error.

QualityTypeScript

Brand primitive IDs to prevent mix-ups

MEDIUM

Give string/number IDs a branded type so a `UserId` can't be passed where an `OrderId` is expected.

QualityTypeScript

Use `satisfies` to validate without widening

MEDIUM

Use `satisfies` to check a value against a type while keeping its precise inferred literal type.

QualityTypeScript

Use exhaustive `switch` with a `never` default

MEDIUM

Add a `default` branch that assigns to `never` so adding a union member becomes a compile error until handled.

QualityTypeScript

Lean on inference, annotate public API boundaries

MEDIUM

Let TypeScript infer local types; add explicit annotations on exported functions and module boundaries.

QualityTypeScript

Don't use non-null assertions (`!`) — handle null explicitly

HIGH

The `!` operator lies to the compiler about null/undefined. Check and handle the empty case explicitly.

QualityTypeScript

Scan dependencies and images for vulnerabilities in CI

HIGH

Run dependency and container-image vulnerability scans in the pipeline and fail on critical findings.

SecurityCI/CD & DevOps

Fail the build fast on any error

MEDIUM

Pipelines must stop immediately on the first error instead of masking failures and continuing.

Architecture

Cache dependencies and build layers to speed pipelines

MEDIUM

Restore dependency and build-layer caches keyed on the lockfile to avoid redundant work each run.

Architecture

Keep environments separate and configure via env, not code

MEDIUM

Maintain distinct dev/staging/prod environments and drive their differences through configuration, not branching code paths.

Architecture

Build the artifact once and promote it across environments

MEDIUM

Produce one immutable build artifact and promote that same artifact through staging to production.

Architecture

Store secrets in the CI secret store, never in code or logs

HIGH

Inject secrets from the CI secret manager at runtime; never commit them or print them to logs.

SecurityCI/CD & DevOps

Use reviewed, version-controlled infrastructure-as-code

MEDIUM

Define infrastructure as code in version control and change it through reviewed, auditable commits.

Architecture

Run lint and tests on every PR and block merge on failure

HIGH

Every pull request must run linting and the test suite, and merging must be blocked when they fail.

Architecture

Automate deployments and provide a fast rollback

MEDIUM

Deploy through an automated pipeline and keep a one-step rollback to the previous known-good release.

Architecture

Require green CI before deploy

MEDIUM

Gate deployments on a passing CI run so only verified commits can be promoted to an environment.

Architecture

Run database migrations as a controlled, gated step

MEDIUM

Apply schema migrations through a dedicated, version-controlled, gated pipeline step — not ad hoc or implicitly on deploy.

Architecture

Make pipelines deterministic and idempotent

MEDIUM

Design pipeline steps to produce the same result on re-run, with no reliance on hidden state or run order.

Architecture

Clean up resources in a finally block

MEDIUM

Release connections, timers, locks, and file handles in finally so they are freed on both success and error paths. Cleanup in the try body alone leaks on failure.

QualityError Handling

Use Result-style returns for expected failures

MEDIUM

Model predictable outcomes (validation, not-found, parse failures) as typed return values; reserve throwing for truly exceptional conditions. This makes failure paths explicit and type-checked.

Quality

Retry transient failures with exponential backoff

MEDIUM

Retry idempotent operations that fail transiently (network blips, rate limits) using exponential backoff with jitter and a max attempt cap — but never retry non-idempotent or permanent failures.

Quality

Handle async errors and promise rejections

MEDIUM

Await promises inside try/catch and never leave a promise unhandled. An unhandled rejection can crash the process or silently drop a failure.

QualityError Handling
CI/CD & DevOps
CI/CD & DevOps
CI/CD & DevOps
CI/CD & DevOps
CI/CD & DevOps
CI/CD & DevOps
CI/CD & DevOps
CI/CD & DevOps
CI/CD & DevOps
CI/CD & DevOps
Error Handling
Error Handling