custom-builtin-functions

Create custom Go built-in functions for OPA/Rego policy evaluation.

571|52|Updated Mar 6, 2023
One-click install
npx skills add https://github.com/chainloop-dev/chainloop --skill custom-builtin-functions
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: custom-builtin-functions
Source: https://github.com/chainloop-dev/chainloop/tree/main/.claude/skills/custom-builtin-functions
Command: npx skills add https://github.com/chainloop-dev/chainloop --skill custom-builtin-functions

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

The OPA/Rego policy engine supports custom built-in functions written in Go.

Core Features & Use Cases

  • Builtin registration: Create and register a custom builtin in Go (e.g., chainloop.my_function).
  • Policy usage: Use the builtin within Rego policies to implement domain logic.
  • Error handling & context: Ensure proper error messages and support for cancellation via BuiltinContext.

Quick Start

Add a Go implementation for your builtin, register it with the initialization code, and call chainloop.my_function(input) from your Rego policy to compute a result or enforce a rule.

Frequently Asked Questions about custom-builtin-functions

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create custom builtin functions for OPA/Rego policies?

Custom builtin functions for OPA/Rego are created by implementing a Go function with a Decl signature, registering it via init auto-registration under the chainloop namespace, and calling it from your *.rego policies. This extends Rego's policy evaluation with domain-specific logic like chainloop.my_function(input).

What's required to register a custom builtin in the Rego policy engine?

Registering a custom builtin requires a Go implementation with proper Decl signature, initialization code for auto-registration, a Description field, error handling, and BuiltinContext support for timeout and cancellation within the chainloop namespace.

Can I use custom Go functions inside Rego policy rules?

Yes. After registering a custom builtin function in Go with proper init registration, you invoke it directly in *.rego files as chainloop.my_function(input) to compute results or enforce policy rules with domain-specific logic.

Does custom builtin registration support error handling and timeouts?

Custom builtins support error handling through proper error messages and BuiltinContext, which enables timeout and cancellation mechanisms to safely manage policy evaluation and prevent runaway executions.

What's the difference between extending Rego with custom builtins vs. writing policy rules alone?

Custom builtins move complex domain logic into compiled Go functions, enabling performance-critical operations and capabilities unavailable in Rego alone. Policy rules then call these builtins to enforce rules without reimplementing logic in Rego.