Skip to main content
Glama

Auto-fix Rego violations

rego_fix
Destructive

Automatically apply mechanical fixes to Rego policies using Regal, with dry-run preview and rule-specific enable/disable options.

Instructions

Run regal fix to automatically apply mechanical fixes. Regal 0.42 fixes opa-fmt, use-rego-v1, use-assignment-operator, no-whitespace-comment, directory-package-mismatch, non-raw-regex-pattern, prefer-equals-comparison, redundant-existence-check and constant-condition; older releases fix a subset. Use dryRun: true to preview changes before modifying files. NOTE: directory-package-mismatch moves files to match their package path -- use disable: ["directory-package-mismatch"] to skip it. Regal before 0.41 refuses files with uncommitted git changes unless force: true. Requires regal.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
forceNoOn Regal before 0.41, allow fixing files that have uncommitted git changes; those releases refuse them otherwise. Regal 0.41 removed that check, and the flag is not sent to it.
pathsYesPolicy files or directories to fix. Each must be inside an allowed root (OPA_MCP_ALLOWED_PATHS).
dryRunNoPreview what would be fixed without modifying any files. Recommended before the first real run.
enableNoEnable specific fix rules.
disableNoDisable specific fix rules. Useful to skip directory-package-mismatch if you do not want files moved.
configFileNoPath to a Regal config file (.regal/config.yaml).
ignoreFilesNoGlob patterns to exclude from fixing.
enableCategoryNoEnable all rules in a category.
disableCategoryNoDisable all rules in a category.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.7.0
    • changedInput schema / properties / force / description
      Previous value: -"Allow fixing files that have uncommitted git changes, or when the project is not a git repository. Without this flag regal refuses to touch uncommitted files."New value: +"On Regal before 0.41, allow fixing files that have uncommitted git changes; those releases refuse them otherwise. Regal 0.41 removed that check, and the flag is not sent to it."
  2. Addedv0.1.13

TDQS

A4.5/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already flag destructive behavior; the description adds crucial specifics: directory-package-mismatch moves files, Regal before 0.41 refuses uncommitted changes unless force:true, and regal must be installed. No contradiction with annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Dense but well-structured: main action first, then rule list, then critical safety caveats. Every sentence adds necessary information; the directory-package-mismatch warning is essential for a destructive tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive tool with 9 parameters and no output schema, the description covers the key behavioral caveats (file moves, git check, dryRun preview, regal requirement). It doesn't explain return values, but that's not critical for a fix command, and the schema handles parameter details.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema covers all 9 parameters at 100%, so baseline is 3. The description adds value by explaining the behavior behind dryRun, disable, and force in context (preview, skip file moves, version-specific git check), going beyond the schema's per-parameter descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States the exact command ('Run regal fix') and the resource ('Rego violations') with a specific list of mechanical fixes. The title and description together make it clear this applies fixes rather than just reporting them, distinguishing it from rego_lint and rego_format.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides clear operational guidance: dryRun for preview, disable for directory-package-mismatch, force for older Regal. It does not explicitly name sibling alternatives or state when not to use it, but the context is strong.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.