custom-builtin-functions

Create a custom builtin function to be used in the Rego policy engine.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/chainloop-dev/chainloop/custom-builtin-functions
Any agent
npx skills add chainloop-dev/chainloop --skill custom-builtin-functions
Clone the repo
git clone --depth 1 https://github.com/chainloop-dev/chainloop

Made for: Claude Code, Codex.

Per session 19 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 525 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin unknown No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00019 $0.00525
Opus 5 $0.00010 $0.00262
Sonnet 5 $0.00004 $0.00105
Haiku 4.5 $0.00002 $0.00052

Measured today against content hash 1c5a493d38d5, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

custom-builtin-functions scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured today.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/custom-builtin-functions/SKILL.md · 80 lines

What it actually says

Policy Engine Extension

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

Adding Custom Built-ins:

  1. Create Built-in Implementation (e.g., pkg/policies/engine/rego/builtins/myfeature.go):
package builtins

import (
    "github.com/open-policy-agent/opa/ast"
    "github.com/open-policy-agent/opa/topdown"
    "github.com/open-policy-agent/opa/types"
)

const myFuncName = "chainloop.my_function"

func RegisterMyBuiltins() error {
    return Register(&ast.Builtin{
        Name: myFuncName,
        Description: "Description of what this function does",
        Decl: types.NewFunction(
            types.Args(types.Named("input", types.S).Description("this is the input")),
            types.Named("result", types.S).Description("this is the result"),
        ),
    }, myFunctionImpl)
}

func myFunctionImpl(bctx topdown.BuiltinContext, operands []*ast.Term, iter func(*ast.Term) error) error {
    // Extract arguments
    input, ok := operands[0].Value.(ast.String)
    if !ok {
        return fmt.Errorf("input must be a string")
    }

    // Implement logic
    result := processInput(string(input))

    // Return result
    return iter(ast.StringTerm(result))
}

// Autoregisters on package load
func init() {
    if err := RegisterMyBuiltins(); err != nil {
        panic(fmt.Sprintf("failed to register built-ins: %v", err))
    }
}
  1. Use in Policies (*.rego):
package example
import rego.v1

result := {
    "violations": violations,
    "skipped": false
}

violations contains msg if {
    output := chainloop.my_function(input.value)
    output != "expected"
    msg := "Function returned unexpected value"
}

Guidelines:

  • Use chainloop.* namespace for all custom built-ins
  • Functions that call third party services should be marked as non-restrictive by adding the NonRestrictiveBuiltin category to the builtin definition
  • Always implement proper error handling and return meaningful error messages
  • Use context from BuiltinContext for timeout/cancellation support
  • Document function signatures and behavior in the Description field and parameter definitions
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. today First seen · 80 lines · 19 tokens per session scan A 1c5a493d38d5

Subscribe to this mod's changes

custom-builtin-functions is a skill published in the GitHub repository chainloop-dev/chainloop (583 stars, last pushed today), licensed Apache-2.0. It adds 19 tokens to every session and 525 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-01.

Related

Other skills, from other repositories

analyzing-sbom-for-supply-chain-vulnerabilities

Parses Software Bill of Materials (SBOM) in CycloneDX and SPDX JSON formats to identify supply chain vulnerabilities by correlating components against the NVD CVE database via the NVD 2.0 API. Builds dependency graphs, calculates risk scores, identifies transitive vulnerability paths, and generates compliance reports.…

adriannoes/awesome-agentic-ai · 110 tokens

SafeAI Code Scanner

Security & Compliance Guardrail for AI-Generated Code (Vibe Coding). (v5.0.0).

datht-work/safeai-global-agent · 28 tokens

ai-security

Use when building any feature that calls an LLM API, processes user input sent to a model, uses RAG or embeddings, deploys an AI agent with tool access, or makes AI-generated output visible to users or downstream systems.

Kaademos/secure-sdlc-agents · 50 tokens

compliance-and-audit

Use when a project requires a compliance framework mapping, when risks need formal documentation, when audit evidence must be collected, or when producing a compliance attestation before release. Applies to SOC 2, ISO 27001, GDPR, PCI DSS, NIST CSF, and DORA.

Kaademos/secure-sdlc-agents · 64 tokens

threat-modeling

Use when a new feature, architecture, or significant design decision is being made. Run before any code is written. Produces a structured STRIDE threat model and architecture review that feeds directly into security requirements and PR review.

Kaademos/secure-sdlc-agents · 49 tokens

security-and-hardening

Use when writing or reviewing code that handles user input, authentication, access control, cryptography, error handling, file uploads, or dependency management. Also activates when a pull request touches any security-sensitive component.

Kaademos/secure-sdlc-agents · 46 tokens