Skip to main content
Glama

Generate Rego test skeleton

rego_generate_test_skeleton
Read-onlyIdempotent

Generate test stubs for Rego policies by parsing the AST and inferring input fields to create placeholder test cases, with optional table-driven style.

Instructions

Generate a *_test.rego skeleton from a policy. Parses the AST, finds each non-test rule, and emits one stub test per rule. Existing test_* and todo_test_* rules are skipped automatically -- only testable production rules get stubs. The AST is walked to infer which input.* fields the policy accesses; the inferred shape is used as the placeholder with input as {...} in each stub, so the developer only needs to fill in realistic values rather than guess the structure. With tableStyle: true, each stub uses an every tc in cases { ... } loop so you can add multiple input/expected pairs without duplicating assertion code. The inferredInputShape field in the response shows the detected shape for reference.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceYesRego source to generate tests for.
tableStyleNoGenerate table-driven test stubs instead of single-case stubs. Each rule gets a `cases` array and an `every tc in cases { ... }` assertion loop. Pair with `rego_test varValues: true` to see which case failed.
Behavior4/5

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

Annotations already declare readOnlyHint=true, destructiveHint=false, idempotentHint=true. The description adds behavioral context: it skips existing test rules, infers input shape from AST, and with tableStyle generates array-based stubs. 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?

The description is well-structured with clear first sentence stating purpose, followed by process details. It is moderately concise; every sentence contributes value (AST parsing, skipping rules, input inference, tableStyle behavior). Could potentially trim some elaboration but not wasteful.

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?

No output schema exists, but description covers the output: stub tests, inferredInputShape response field, and behavior for tableStyle. For a 2-parameter tool with no enums, this is sufficient. Explains what the agent can expect from the tool.

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

Parameters3/5

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

Schema coverage is 100%, so baseline is 3. Description adds meaning to tableStyle (explains table-driven stubs with 'every tc in cases') and source (mentions AST parsing), but the schema already adequately describes each parameter. Description provides useful context but not essential beyond schema.

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?

The description clearly states it generates a '*_test.rego' skeleton from a policy, with specific verb 'Generate' and resource 'Rego test skeleton'. It details the process: parsing AST, finding non-test rules, emitting stubs. This distinguishes it from sibling tools like rego_test (testing) and rego_format (formatting).

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

Usage Guidelines3/5

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

The description implies usage for generating test skeletons from policy source, but does not explicitly state when to use vs alternatives, when not to use, or prerequisites. No guidance on choosing this over other code generation or testing tools.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/OrygnsCode/opa-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server