Skip to main content
Glama

Generate Rego test skeleton

rego_generate_test_skeleton
Read-onlyIdempotent

Generate stub Rego tests for every production rule in a policy, using inferred input shapes as placeholders and optional table-driven cases for multiple scenarios.

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 production rules get stubs, and a value rule whose head is computed gets a todo_test_ stub, which opa test reports as skipped until its expected value is filled in and it is renamed test_. 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.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.1.13
  2. Removedv0.1.5
  3. Addedv0.1.2
  4. Removedv0.1.1
  5. First observedv0.1.0

TDQS

A4.7/5.0
Behavior5/5

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

The description goes well beyond the readOnly/idempotent annotations by disclosing that existing test_* and todo_test_* rules are skipped, that computed value rules get todo_test_ stubs, that opa test reports these as skipped, and how tableStyle changes the generated loop. It also explains AST-driven input-shape inference and the inferredInputShape response field.

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

Conciseness5/5

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

The description is dense but purposeful. Every sentence adds a distinct behavioral or usage detail, and the core purpose is front-loaded before implementation specifics.

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

Completeness5/5

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

With no output schema, the description still covers the key return information by naming the inferredInputShape response field and describing what the generated stubs look like. The tool has only two simple parameters, and the description gives enough detail for an agent to call it correctly.

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?

The input schema already documents both parameters at 100% coverage. The description adds practical value by explaining the benefit of tableStyle (adding multiple input/expected pairs without duplicating assertion code) and by reinforcing that source is policy source. This is a slight but meaningful improvement over the schema alone.

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 opens with a specific verb and resource: "Generate a `*_test.rego` skeleton from a policy." It then explains the process (parse AST, find non-test rules, emit one stub per rule), which clearly distinguishes this tool from siblings like rego_test that run tests rather than generate them.

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?

The intended context is clear from the first sentence: use this when you need a test skeleton for a Rego policy. It does not explicitly name alternatives or state when not to use it, but the generation behavior is distinct enough that no exclusion is necessary.

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