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...8910...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

Index All Foreign Key Columns

HIGH

Unlike PostgreSQL, MySQL/InnoDB requires indexes on foreign key columns. Missing indexes cause slow JOINs.

PerformanceMySQLMariaDBMySQL & MariaDB

Avoid SELECT * in Production Queries

MEDIUM

SELECT * fetches all columns, wasting bandwidth and preventing covering index optimization.

PerformanceMySQLQuery Optimization

Use utf8mb4 Instead of utf8

MEDIUM

MySQL's utf8 charset only supports 3-byte characters. Use utf8mb4 for full Unicode support.

ArchitectureMySQLSchema Design

Use Online DDL for ALTER TABLE

CRITICAL

ALTER TABLE in MySQL can lock the entire table. Use ALGORITHM=INPLACE or tools like gh-ost for safe migrations.

PerformanceOnline DDLMySQL

Tables Must Have Primary Keys

HIGH

Tables without primary keys cannot use logical replication and have degraded query performance.

ArchitectureSchema DesignSplinter

Escape All Output with the Correct Context Function

CRITICAL

WordPress provides context-specific escaping functions. Using the wrong one — or none — enables XSS. Match esc_html, esc_attr, esc_url, wp_kses to the output context. [CWE-79 · A07:2021]

SecuritywordpressXSS

Always Use $wpdb->prepare() for Database Queries

CRITICAL

Passing user input directly into SQL queries via $wpdb enables SQL injection. Always use $wpdb->prepare() with typed placeholders (%d, %s, %f, %i). [CWE-89 · A03:2021]

SecuritywordpressDatabase

Always Check Capabilities Before Privileged Operations

CRITICAL

WordPress capabilities (current_user_can) are the authorization layer. Missing checks in REST endpoints, admin handlers, and AJAX allow subscribers to perform admin actions. [CWE-862 · A01:2021]

Securitycapabilitieswordpress

Prevent Path Traversal in File Operations and Includes

CRITICAL

User input in include/require or file read/write paths allows attackers to read wp-config.php, delete files, or execute arbitrary PHP via ../ sequences. [CWE-22 · A01:2021]

Securitywordpresspath-traversal

Never Unserialize User-Controlled Data

CRITICAL

PHP's unserialize() instantiates arbitrary classes and triggers magic methods. Deserialization of user input enables remote code execution via gadget chains. [CWE-502 · A08:2021]

Securityobject-injectionwordpress

Use wp_handle_upload() with MIME Allowlists for File Uploads

HIGH

Direct move_uploaded_file() with only client-supplied MIME checks enables shell upload. Use wp_handle_upload() which validates both extension and file content. [CWE-434 · A04:2021]

Securitywordpressfile-upload

Guard Plugin and Theme PHP Files Against Direct Access

HIGH

PHP files without an ABSPATH guard can be accessed directly via URL, leaking paths, triggering errors, or executing partial logic without WordPress security context. [CWE-425 · A05:2021]

Securitywordpressfile-access

Verify Nonces on All State-Changing Actions

CRITICAL

WordPress nonces prevent CSRF attacks. Every form submission, AJAX call, and admin action that modifies data must verify a nonce before processing. [CWE-352 · A01:2021]

Securitywordpressforms

Secure AJAX Handlers with Nonce and Capability Checks

CRITICAL

WordPress AJAX handlers are public endpoints. wp_ajax_ fires for any logged-in user regardless of role. Always verify nonces and capabilities inside each handler. [CWE-862 · A01:2021]

Securityajaxwordpress

Use WP_Error for Error Handling — Not Exceptions or False

MEDIUM

Returning false on failure hides what went wrong. WP_Error provides structured error codes, messages, and data — matching WordPress core's error handling pattern.

Qualitywordpressquality

Sanitize All User Input with Type-Appropriate Functions

HIGH

Raw $_GET/$_POST/$_REQUEST data can contain anything. WordPress provides type-specific sanitization functions — use the right one for each data type before storage or use. [CWE-20 · A03:2021]

QualitywordpressSanitization

Make All User-Facing Strings Translatable

MEDIUM

Hardcoded English strings prevent localization. Use __(), _e(), and esc_html__() with a text domain. Always escape translated output — translators can inject HTML.

Qualitywordpresslocalization

Cache Expensive Operations with Transients

HIGH

External API calls, complex calculations, and aggregation queries should use set_transient/get_transient to avoid repeating expensive work on every page load.

Performancewordpresstransients

Keep Database Queries Out of Templates — Use pre_get_posts

HIGH

Direct $wpdb queries and query_posts() in template files create redundant queries, bypass caching, and mix data logic with presentation.

PerformanceQuerieswordpress

Enqueue Scripts and Styles Properly with Conditional Loading

HIGH

Inline script tags bypass WordPress dependency management and load on every page. Use wp_enqueue_script with conditions to load assets only where needed.

Performanceenqueuewordpress

Use Object Cache for Repeated Expensive Queries

MEDIUM

wp_cache_get/set with a persistent backend (Redis/Memcached) eliminates redundant database queries across requests. Without it, identical queries run on every page load.

Performancewordpressredis

Avoid N+1 Queries in Post Loops

HIGH

Calling get_post_meta() inside loops without cache priming generates one database query per post. Use update_post_meta_cache or meta_query to batch lookups.

PerformanceQuerieswordpress

Disable Autoload for Large or Infrequently Used Options

HIGH

All autoloaded options are loaded into memory on every page request. Large serialized arrays in autoloaded options waste memory and slow every page.

Performancewordpressoptions

Use WordPress APIs Instead of Raw PHP Functions

MEDIUM

Direct SQL, curl, file_put_contents, and mail() bypass WordPress caching, hooks, security filters, and host compatibility. Use WP_Query, wp_remote_get, WP_Filesystem, and wp_mail.

Architecturewordpress
MySQL & MariaDB
MySQL & MariaDB
MySQL & MariaDB
PostgreSQL
beforemerge-wordpress-review
beforemerge-wordpress-review
beforemerge-wordpress-review
beforemerge-wordpress-review
beforemerge-wordpress-review
beforemerge-wordpress-review
beforemerge-wordpress-review
beforemerge-wordpress-review
beforemerge-wordpress-review
beforemerge-wordpress-review
beforemerge-wordpress-review
beforemerge-wordpress-review
beforemerge-wordpress-review
beforemerge-wordpress-review
beforemerge-wordpress-review
beforemerge-wordpress-review
beforemerge-wordpress-review
beforemerge-wordpress-review
architecture
beforemerge-wordpress-review