Open Policy Agent
$ opa Foundation Low RiskThe opa CLI evaluates Rego policy queries against arbitrary JSON/YAML inputs, runs unit test suites (opa test), formats .rego files, and compiles policy bundles. Because JSON is OPA's native data model, opa eval --format json and opa test --format json integrate seamlessly with agents.
brew install opa Deterministic local Rego evaluator and test runner; direct CLI invocation gives exact JSON decision payloads without MCP latency.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Native JSON data model across opa eval --format json, opa test --format json, and opa check --format json with zero interactive prompts.
- Consistent
--format jsonacrosseval,test, andcheck - Supports
--fail/--fail-definedflags for CI exit codes
Sandboxed Rego evaluation cannot mutate host or cloud state; file writes are opt-in via opa fmt -w or opa build -o.
- Pure local policy evaluation with zero side effects
Single static Go binary available on macOS, Linux, and Windows via Homebrew, Go, Docker, and releases.
- Zero runtime dependencies; single cross-platform binary
Covers policy linting, unit testing, REPL, Wasm compilation, and bundle building in one fast binary.
- All-in-one toolchain (
eval,test,check,fmt,build)
CNCF Graduated project (open-policy-agent/opa) under Apache-2.0 with enterprise-grade maintenance.
- CNCF Graduated project under Apache-2.0
Extensive official docs, Rego playground references, and clear per-subcommand --help.
- Comprehensive CLI and Rego docs at openpolicyagent.org
Security, Auth & Guardrails
Local policy evaluation requires zero credentials; remote bundle servers use optional bearer tokens configured via OPA config YAML or env vars.
CNCF graduated Apache-2.0 open-source project; completely free.
# opa Agent Rules - Always pass `--format json` on `opa eval` and `opa test`. - Run `opa check` before `opa eval` to catch syntax/type errors cleanly. - Preview `opa fmt -d` before using `opa fmt -w` on policy directories.
Agent-Ready Command Recipes
Safe Read-Only Queries
opa eval -d policy/ -i input.json --format json 'data.authz.allow'
Evaluates the query locally and returns structured JSON bindings and decision values.
opa test policy/ --format json
Executes all test_* Rego rules and outputs pass/fail results in JSON.
Controlled Writes & Previews
opa fmt -w policy/
Reformats .rego files deterministically; run opa fmt -d policy/ first to preview diffs.
Strengths for Agents
- + JSON-native engine with
--format jsononeval,test, andcheck. - + Zero-risk local policy evaluation with
--fail/--fail-definedexit-code controls. - + CNCF Graduated single static binary with fast startup.
Caveats & Pitfalls
- ! Rego syntax has a learning curve for agents writing new policies from scratch.
- !
opa evalreturns exit code0even when a policy evaluates tofalseunless--fail-definedor--failis passed.