Skip to main content
This feature is only available on Chainloop’s platform paid plans.

Overview

Chainloop supports a GitOps workflow for its configuration. You don’t create policies, frameworks, contracts, and workflow templates one by one in the UI. Instead, you define them as YAML files in a Git repository and apply them with the chainloop apply command. The repository is the source of truth, and Chainloop follows it. This means you can:
  • Version-control every change, with its history and author
  • Review changes through pull requests before they take effect
  • Automate the rollout from CI/CD when a change merges
  • Reproduce the same configuration across organizations and environments
All resources follow a Kubernetes-style schema with apiVersion, kind, metadata, and spec fields. Apply operations are idempotent: if a resource with the same name already exists, Chainloop updates it. Otherwise, Chainloop creates it. Applying an unchanged file changes nothing.

What You Can Manage

chainloop apply manages the resources below. They fall into two groups that you can use together or on their own: the compliance resources (policies, policy groups, requirements, and frameworks), and the resources that define how your workflows attest (contracts and workflow templates). You don’t need a framework to manage contracts as code. chainloop apply doesn’t manage other resources, such as projects and workflows. Create a workflow with chainloop workflow create --contract <name> to use a contract that you manage as code.

Example Repository Layout

Keep your resources in a dedicated folder of a Git repository, one folder per kind. The layout below is a good starting point:
Apply the whole folder with one command:
Some conventions keep a repository like this easy to review:
  • One folder per policy. Keep the Rego code in .rego files next to the policy YAML and reference them with path, which is relative to the policy file. chainloop policy develop init --directory policies/<name> --name <name> creates this layout for you. See How to write custom policies. You can then test the Rego with opa test in CI before you apply it.
  • One resource per file, named after the resource. Name each file after its metadata.name, for example contracts/build-contract.yaml for the contract build-contract. A framework and its requirements can share one multi-document file.
  • Any folder structure works. chainloop apply reads every YAML file under the path that you give it and applies the resources in dependency order. The folders are only for people. chainloop apply skips files that are not YAML, and YAML files without a kind, such as CI configuration.

Prerequisites

Before you begin, make sure you have:
  • Chainloop CLI Enterprise Edition installed - see the CLI installation guide
  • Authenticated to your organization - run chainloop auth login

Walkthrough: Compliance as Code

This walkthrough builds a complete compliance-as-code setup from scratch around an SBOM license-compliance use case. Each step builds on the previous one. By the end, you’ll have a policy, a policy group, a requirement, a framework, and a contract that all work together. The steps below apply each resource individually so you can verify as you go. In practice, you can place all your YAML files in a single directory and apply them at once with chainloop apply -f ./chainloop/ - Chainloop resolves dependencies automatically. See Applying Resources at Scale.

Step 1 - Write a Policy

A policy contains the Rego rules that Chainloop evaluates against your attestation materials. Start by defining one that checks CycloneDX SBOMs for components missing license information. Create cyclonedx-licenses.yaml:
Apply and verify:
For the full Rego development workflow - scaffolding, linting, testing, and iterating on policies - see How to write custom policies.

Step 2 - Group Policies Together

A policy group bundles related policies into a reusable unit. Let’s create one that groups the cyclonedx-licenses policy from Step 1 with another SBOM policy to form a complete SBOM quality check. Create sbom-quality-group.yaml:
The group includes the cyclonedx-licenses policy you just created alongside sbom-banned-licenses, a built-in policy that ships with Chainloop. The attestation section checks that an SBOM was included in the attestation; the materials section runs quality checks against the SBOM itself. Apply and verify:
For full details on policy group structure and capabilities, see Policy Groups.

Step 3 - Define a Requirement

A requirement specifies what must be satisfied for compliance - which policies to evaluate, how often, and what manual evidence is needed. Let’s create one that enforces license compliance by referencing the policy from Step 1. Create license-compliance.yaml:
Requirements can also include periodicity (how often a policy is re-evaluated, e.g. daily, weekly), sla (grace period in hours before failures affect the compliance score), group (to organize policies into groups where any member passing satisfies the group), and manual_proofs for evidence that can’t be automated (e.g., license review sign-offs). For the full schema, see Compliance Frameworks. Apply and verify:

Step 4 - Build a Framework

A framework organizes requirements into a structured compliance program. You can group requirements into sections (and nested sub-sections) to model standards like CRA, SLSA, or your own internal policies. Let’s build one that includes the requirement from Step 3. Create best-practices.yaml:
This framework mixes built-in requirements (branch-protection, code-review) with the custom license-compliance requirement you created in Step 3. Chainloop ships with a library of built-in requirements and policies - your custom resources extend them. Apply and verify:
Each requirement can only appear once in a framework - either at the root level or within a section, not both.

Step 5 - Tie It Together in a Contract

A contract defines the attestation expectations for a workflow - what materials to collect and which policies and policy groups to evaluate. This is where everything comes together: the contract references the policy group from Step 2, which in turn includes the policy from Step 1. Create example-contract.yaml:
When a workflow attests against this contract, Chainloop will check that an SBOM is present, verify every component has a license, and flag any banned licenses - all driven by the resources you built in the previous steps. Apply and verify:
For the full contract schema including material types and runner context, see Contracts.

Managing Contracts Declaratively

A contract can stand on its own: it lists the materials and annotations that a workflow’s attestations must include, and optionally the policies to evaluate. Create build-contract.yaml:
Preview the change, apply it, and attach the contract to a workflow:
When you change the YAML and apply it again, Chainloop updates the contract. Every workflow attached to it uses the new version on its next attestation. Keep your contracts in a repository and apply them from CI/CD. Then each change to what your pipelines must attest goes through a pull request.

Applying Resources at Scale

The steps above apply resources one at a time. The chainloop apply command can handle any resource type, including multi-document YAML files and entire directories:
When applying multiple resources, Chainloop processes them in dependency order: Policies, then Requirements, Frameworks, Policy Groups, Contracts, and Workflow Templates. Multi-document YAML files use --- as the separator between resources.

Inspecting and Exporting Resources

After applying resources, you can verify them, explore what’s deployed, and export definitions for backup or migration. Export a resource as reusable YAML with the --output schema flag - useful for bootstrapping new configurations, backing up resources, or migrating between organizations:
Add --output json to any describe or list command for JSON output.

Automating with CI/CD

Store your YAML resource definitions in a git repository and apply them automatically whenever changes are merged. This keeps your Chainloop configuration up to date and auditable. You’ll need an API token stored as a CI secret.