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
PricingBlogContributorsDocs
2Sign In
FeaturesExplore
RulesSkillsKnowledgePrompts
PricingBlogContributorsDocs
Sign In

Explore

Browse 158 rules, 25 knowledge articles, and 25 prompt templates across security, performance, architecture, and quality.

158 rules

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]

wordpressXSS
beforemerge-wordpress-review

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]

wordpressDatabase
beforemerge-wordpress-review

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]

capabilitieswordpress
beforemerge-wordpress-review

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]

wordpresspath-traversal
beforemerge-wordpress-review

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]

object-injectionwordpress
beforemerge-wordpress-review

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]

wordpressfile-upload
beforemerge-wordpress-review

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]

wordpressfile-access
beforemerge-wordpress-review

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]

wordpressforms
beforemerge-wordpress-review

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]

ajaxwordpress
beforemerge-wordpress-review

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.

wordpressquality
beforemerge-wordpress-review

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]

wordpressSanitization
beforemerge-wordpress-review

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.

wordpresslocalization
beforemerge-wordpress-review

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.

wordpresstransients
beforemerge-wordpress-review

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.

Querieswordpress
beforemerge-wordpress-review

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.

enqueuewordpress
beforemerge-wordpress-review

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.

wordpressredis
beforemerge-wordpress-review

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.

Querieswordpress
beforemerge-wordpress-review

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.

wordpressoptions
beforemerge-wordpress-review

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.

wordpressarchitecture
beforemerge-wordpress-review

Use the Correct WordPress Hook for Each Operation

MEDIUM

Registering CPTs on plugins_loaded, enqueueing scripts on init, or running admin-only code on every request wastes resources and causes subtle bugs.

filterswordpress
beforemerge-wordpress-review

Use WordPress Path and URL Functions — Never Hardcode

MEDIUM

Hardcoded URLs and filesystem paths break across environments (local/staging/prod), subdirectory installs, multisite, and custom wp-content directories.

pathswordpress
beforemerge-wordpress-review

Prevent SQL Injection in Custom RPC Functions

CRITICAL

String interpolation in .rpc() calls or custom PostgreSQL functions allows attackers to inject arbitrary SQL. Always use parameterized queries. [CWE-89 · A03:2021]

rpcsupabase
beforemerge-supabase-review

Never Use Service Role Client in Auth-Context Routes

CRITICAL

createServiceRoleClient() bypasses ALL RLS policies. Using it in request handlers lets any authenticated user access or modify all data. [CWE-269 · A04:2021]

service-rolesupabase
beforemerge-supabase-review

Never Log Sensitive Data

HIGH

Logging OAuth tokens, API keys, passwords, or PII exposes secrets in log aggregation services and crash reporters. Use scoped loggers with sanitization. [CWE-532 · A09:2021]

supabaseSecrets
beforemerge-supabase-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