Policy Basics
Policies are rules that MergeGuide uses to analyze code changes. This guide covers the fundamentals of how policies work.What is a Policy?
A policy is a declarative rule that:- Identifies specific code patterns or behaviors
- Evaluates whether those patterns are acceptable
- Reports violations with actionable feedback
Policy Structure
Every policy has these components:Core Concepts
Policy ID
A unique identifier for the policy:- Lowercase with hyphens
- Must be unique within your organization
- Used in CLI commands and ignore comments
Severity Levels
| Level | Meaning | Behavior |
|---|---|---|
error | Critical violation | Blocks merges/commits |
warning | Potential issue | Reported but allowed |
info | Suggestion | Informational only |
Enabled State
Control whether a policy is active:Patterns
Patterns define what code to flag:regex- Regular expression matchingast- Abstract Syntax Tree analysissemantic- Language-aware analysis
Your First Policy
Let’s create a simple policy that detectsconsole.log statements:
Testing Your Policy
Test policies before deploying:Policy Inheritance
Policies can extend built-in policies:Next Steps
- YAML Reference - Complete configuration options
- Pattern Matching - Advanced pattern techniques
- Built-in Policies - Available default policies
- Custom Policies - Create organization-specific rules