Format Rego files in place
rego_format_writeCanonically format Rego files or directories in place with version-specific options. Preview changes using dry run to avoid unintended modifications.
Instructions
Run opa fmt --write to canonically format one or more Rego files or directories in place. Use dryRun: true to preview which files would change without modifying them. Returns a list of files that were (or would be) reformatted. Unlike rego_format which returns formatted source as a string, this tool writes directly to disk. Supports regoV1, v0Compatible, and v1Compatible flags for version-specific formatting. If any file cannot be parsed, the operation is aborted and no files are written.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| paths | Yes | Policy files or directories to format in place. Each must be inside an allowed root (OPA_MCP_ALLOWED_PATHS). | |
| dryRun | No | Preview which files would be reformatted without modifying them. Recommended before the first real run. | |
| regoV1 | No | Format module(s) to be compatible with both Rego v1 and the current OPA version. Adds `import rego.v1` where missing. | |
| v0Compatible | No | Use OPA behaviors and syntax prior to the v1.0 release. | |
| v1Compatible | No | Use OPA v1.0-compatible behaviors. |