cribro reports which lines a branch changed that no test executes, and which changed lines no test would notice
breaking. It works in Gradle and Maven builds with Java or Kotlin sources: test ends with a diff coverage report from
JaCoCo, and a separate task runs PIT mutation testing on the changed lines only. The reports are plain text sized for
an AI agent, so an agent that changed the code reads them in the build output and writes the tests that are missing.
There is no HTML report of its own.
A coverage figure for the whole project barely moves when a change adds untested code. cribro looks only at the lines
the branch changed since its merge base with the upstream branch, or with origin/HEAD, origin/main, or
origin/master where there is no upstream. -Pcribro.diffBase=<ref> in Gradle, or -Dcribro.diffBase=<ref> in Maven,
picks another base.
On pgjdbc/pgjdbc#4036, test ends with a block like this one, cut here
to one file:
Diff coverage against origin/HEAD (a340cb2b0), from :postgresql:test --tests *SRVLookupTest
a filtered run leaves the rest of the change looking unexecuted
ordered by uncovered changed lines, then uncovered branches
pgjdbc/src/main/java/org/postgresql/Driver.java
12/16 changed lines executed, 12/22 branches covered
uncovered changed code:
254: not executed; 0 of 4 branches covered: if (!url.startsWith("jdbc:postgresql:") && !url.startsWith("jdbc:postgresql+srv:")) {
731: not executed: String srvHost = PGProperty.SRV_HOST.getOrDefault(props);
The code started in NullAway's buildSrc (uber/NullAway#1833 and
uber/NullAway#1975), written by the same author.
The Gradle plugin is io.github.cribro-dev.cribro on the Gradle Plugin Portal. The Maven extension is
io.github.cribro-dev:cribro-maven-plugin on Maven Central. Both have the same version numbers. <version> below is
the latest release, which the badges at the top of this page show.
Each build tool can take cribro in one of two ways. Added to the build, cribro is part of the project, and everyone who builds the project gets it. Installed on your machine, cribro measures any project you build, and no project file changes.
| Build tool | You want | Section | Files it changes |
|---|---|---|---|
| Gradle | cribro for everyone who builds the project | Add cribro to a Gradle build | The project's settings.gradle(.kts) and AGENTS.md |
| Gradle | cribro for yourself, in projects you do not want to modify | Install cribro on your machine for any Gradle build | ~/.gradle/cribro/ and ~/.claude/skills/cribro/ |
| Maven | cribro for everyone who builds the project | Add cribro to a Maven build | The project's .mvn/extensions.xml and AGENTS.md |
| Maven | cribro for yourself, in projects you do not want to modify | Install cribro on your machine for any Maven build | ~/.m2/cribro/ and ~/.claude/skills/cribro/ |
For a Gradle build, cribro is a settings plugin, io.github.cribro-dev.cribro. It attaches JaCoCo to the test
task of every Java project, which then ends with the diff coverage report, and adds a pitestDiff task that runs PIT
on the changed lines.
A Gradle build needs:
- Gradle 8.0 or later, running on JDK 11 or later (Gradle 9 itself needs JDK 17). Nothing older than 8.14 has been tried.
- Tests that run on JDK 11 or later, since PIT loads this plugin's classes into the test JVM.
- Java or Kotlin sources under the main source set of the
javaplugin, which the Kotlin JVM plugin applies;src/main/kotlincounts. Groovy sources, Kotlin Multiplatform, and Android builds are not measured. - JUnit 4, or JUnit Jupiter or Vintage on the JUnit Platform, for
pitestDiff.
Tried on pgjdbc (Gradle 9.4.1 and 9.7.1, JUnit Jupiter), NullAway (Gradle 9.8.1, JUnit 4), and a one-class build on
Gradle 8.14.3 whose tests have no junit-platform-launcher dependency. CI runs test pitestDiff through the init
script on a one-class build with both Gradle 8.14.3 and its tests on JDK 11.
-
Add the plugin to the project's
settings.gradle.kts. It adds the tasks to every project of the build that applies thejavaplugin, which the Kotlin JVM plugin applies too:plugins { id("io.github.cribro-dev.cribro") version "<version>" }Where the file already has a
pluginsblock, add the line to it instead of writing a second one. Insettings.gradle, the line isid 'io.github.cribro-dev.cribro' version '<version>'. Gradle resolves the plugin from the Plugin Portal; where the build'spluginManagementblock lists its ownrepositories, keepgradlePluginPortal()among them. -
Check that the build applies it, from the project's root directory. The command prints
cribro <version>and the projects that have the tasks:./gradlew -q cribro
-
Tell the agents that work on the project.
./gradlew -q cribroprints the guide for the version the build runs, so a note inAGENTS.md, or in whichever file the project's agents read, names the commands and the two markers and leaves the rest to the guide:After changing the Java or Kotlin sources under `src/main` of a module, run `./gradlew <project>:test`, where `<project>` is that module's Gradle project path, such as `:app`, and act on the diff coverage report it prints. Once the changed lines are covered, run `./gradlew <project>:pitestDiff -Pcribro.pitestTargetTests=<test classes>` and act on the mutants it reports; `test` does not run it. Mark an uncovered line that is unreachable or not worth a test with `// diff-coverage: ignore -- <reason>`, and a mutant no caller can observe with `// mutant: equivalent <id> -- <reason>`, where `<id>` is the text in brackets after the mutant in the `pitestDiff` report, such as `MathMutator#2`. Before your first measurement in a task, run `./gradlew -q cribro`: it prints how to read both reports and how to write the markers.
To upgrade, change the version in settings.gradle(.kts).
What cribro changes in a Gradle build lists the settings it overrides in each
project.
Build cribro from source instead
Building cribro needs a JDK 25 where Gradle finds it, for example as JAVA_HOME; the build does not download one. A
build from source has the version cribro.version from gradle.properties with -SNAPSHOT appended, and it resolves
only from the local Maven repository of the machine that built it. A clone of the project on any other
machine, CI included, fails to resolve the plugin, so keep this change out of a repository that others build.
-
Clone this repository into a directory outside the project,
<cribro-dir>below, and publish the plugin to the local Maven repository:git clone https://github.com/cribro-dev/cribro.git <cribro-dir>
cd <cribro-dir> && ./gradlew --quiet publishToMavenLocal
-
In the project's
settings.gradle.kts, addmavenLocal()to the plugin repositories, and use the-SNAPSHOTversion in step 1 of the release install:pluginManagement { repositories { mavenLocal() gradlePluginPortal() } }A
repositoriesblock replaces Gradle's default of the Plugin Portal, so keepgradlePluginPortal()in it.
The init script applies cribro to a build that knows nothing about it, such as a clone of pgjdbc. Gradle runs it only
in a command that names it with --init-script. The script resolves the plugin from the Gradle Plugin Portal.
-
Download the init script of the latest release into
~/.gradle/cribro/, with its version filled in, and the agent skill into~/.claude/skills/cribro/. The skill tells the agent when to run cribro and how to reach the guide through the init script, and it covers Maven builds too.agent/cribro/SKILL.mdis a plain skill file; the commands install it for Claude Code:version=$(curl -fsSL https://api.github.com/repos/cribro-dev/cribro/releases/latest | sed -n 's/.*"tag_name": *"v\([^"]*\)".*/\1/p') mkdir -p ~/.gradle/cribro ~/.claude/skills/cribro curl -fsSL "https://raw.githubusercontent.com/cribro-dev/cribro/v$version/cribro-gradle-plugin/src/dist/cribro.init.gradle" | sed "s/@version@/$version/g" > ~/.gradle/cribro/cribro.init.gradle curl -fsSL -o ~/.claude/skills/cribro/SKILL.md "https://raw.githubusercontent.com/cribro-dev/cribro/v$version/agent/cribro/SKILL.md"
-
Check it from the root directory of the project you want to measure. The command prints
cribrowith the version and the projects that have the tasks:./gradlew --init-script ~/.gradle/cribro/cribro.init.gradle -q cribro
To upgrade, run step 1 again.
Build cribro from source instead
Building cribro needs a JDK 25 where Gradle finds it, for example as JAVA_HOME; the build does not download one.
-
Clone this repository into a directory outside any project,
<cribro-dir>below, and build the init script and the plugin jar intocribro-gradle-plugin/build/dist:git clone https://github.com/cribro-dev/cribro.git <cribro-dir>
cd <cribro-dir> && ./gradlew --quiet dist
-
Copy them into
~/.gradle/cribro/, and the skill into~/.claude/skills/cribro/. Run this from<cribro-dir>:mkdir -p ~/.gradle/cribro && cp cribro-gradle-plugin/build/dist/* ~/.gradle/cribro/
mkdir -p ~/.claude/skills/cribro && cp agent/cribro/SKILL.md ~/.claude/skills/cribro/
The init script loads cribro.jar from its own directory where there is one. A script built from a -SNAPSHOT
version without its jar fails with:
No cribro.jar beside <script>, and cribro <version> is a development build that the Gradle Plugin Portal does not host. Copy cribro-gradle-plugin/build/dist/cribro.jar of the cribro build into <directory>.
After git pull in <cribro-dir>, run ./gradlew --quiet dist and step 2 again. An init script built before cribro
became a settings plugin applies the plugin a second time to a build that applies it itself, and that build fails.
For Gradle, both ways add the same tasks. Where the build applies the plugin itself, the init script leaves it alone and the build's version runs, so the two ways can coexist.
The plugin jar has no runtime dependencies: PIT is resolved from the target build's repositories when pitestDiff
runs.
./gradlew -q cribro prints the guide to the other tasks: the projects that have them, the commands written the way
this build runs them, the properties, and how to act on each report.
./gradlew -q cribroWith the init script:
./gradlew --init-script ~/.gradle/cribro/cribro.init.gradle -q cribroThe two commands an agent runs most are these, written for a build that applies the plugin; with the init script,
add --init-script ~/.gradle/cribro/cribro.init.gradle to each:
./gradlew <project>:test./gradlew <project>:pitestDiff -Pcribro.pitestTargetTests=<tests><project> is a Gradle project path such as :app, which can differ from the directory: pgjdbc's pgjdbc/ directory
is :postgresql. The guide lists the paths. For the root project, the task path is :test.
The plugin registers cribro on the root project, and adds a cribroProjectElements configuration to every project;
cribro resolves that configuration of each project to list the projects that have the tasks. Applied as a settings
plugin or through the init script, cribro works with Isolated Projects, tried on Gradle 9.8.2. On Gradle 8, Isolated
Projects fails the cribro task where a subproject has the same group and name as the root project. For every project
with the java plugin, it:
- applies
jacoco, enables it on thetesttask, and hastestfinalized byjacocoTestReportwith the XML report, then bydiffCoverage. These override the build's own settings after its scripts run, so a build that disables JaCoCo still gets the report. A setting made in anafterEvaluateaction, or in agradle.afterProjectaction registered after cribro, runs after the overrides and wins. Where the build does not applyjacocoitself, the otherTesttasks run without it; - replaces the JaCoCo version only where it is Gradle's bundled default and older than 0.8.16;
- registers
changedLinesandpitestDiff, and acribroPitestconfiguration withpitest-command-line, pluspitest-junit5-pluginwhentestuses the JUnit Platform, plusjunit-platform-launcherwhen the tests do not bring one; - runs PIT in a separate JVM from the
testtask's launcher, with its JVM arguments and system properties.
For a Maven build, cribro is a Maven extension and plugin, io.github.cribro-dev:cribro-maven-plugin. Loaded as an
extension, it attaches JaCoCo to the tests of surefire's default-test execution and prints the diff coverage report
before Maven's build summary. Its goal cribro:pitest-diff runs PIT on the changed lines.
- Maven 3.9 running on JDK 11 or later; tried on 3.9.16. Maven 4 has not been tried.
- CI tests the extension on JDK 17 and later. It is compiled for JDK 11, but no test runs Maven on JDK 11.
- Tests run by surefire's
default-testexecution, in a forked JVM. - Java sources under the compile source roots, or Kotlin sources under those roots or the
sourceDirsofkotlin-maven-plugin. - For
cribro:pitest-diff: tests on JUnit 4, or on JUnit Jupiter or Vintage on the JUnit Platform, in a JVM of JDK 11 or later.
Tried on Guava, whose tests live in guava-tests and test the code of guava, without changing its build.
-
Add
.mvn/extensions.xmlto the project's root directory. Where the file exists, add the<extension>element to it, with the latest release in place ofVERSION. Maven resolves the extension from Maven Central.<extensions> <extension> <groupId>io.github.cribro-dev</groupId> <artifactId>cribro-maven-plugin</artifactId> <version>VERSION</version> </extension> </extensions>
-
Check it from the project's root directory. The command prints
cribro <version>and the modules with tests:mvn -q cribro:guide
-
Tell the agents that work on the project.
mvn -q cribro:guideprints the guide for the version the build loads, so a note inAGENTS.md, or in whichever file the project's agents read, names the commands and the two markers and leaves the rest to the guide:After changing the Java or Kotlin sources under `src/main` of a module, run `mvn -pl <module> -am test`, where `<module>` is the module whose tests exercise the change, such as `:app`, and act on the diff coverage report it prints. Once the changed lines are covered, run `mvn -pl <module> -am test-compile cribro:pitest-diff -Dcribro.pitestTargetTests=<test classes>` and act on the mutants it reports; `test` does not run it. Mark an uncovered line that is unreachable or not worth a test with `// diff-coverage: ignore -- <reason>`, and a mutant no caller can observe with `// mutant: equivalent <id> -- <reason>`, where `<id>` is the text in brackets after the mutant in the `cribro:pitest-diff` report, such as `MathMutator#2`. Before your first measurement in a task, run `mvn -q cribro:guide`: it prints how to read both reports and how to write the markers.
To upgrade, change the version in .mvn/extensions.xml.
Maven loads cribro from a jar passed with -Dmaven.ext.class.path. The release does not publish that jar, so this way
builds it from source, and needs a JDK 25 where Gradle finds it, for example as JAVA_HOME. The build has the version
cribro.version from gradle.properties with -SNAPSHOT appended.
-
Clone this repository into a directory outside the project,
<cribro-dir>below, publish the plugin to the local Maven repository, and build the extension jar intocribro-maven-plugin/build/dist:git clone https://github.com/cribro-dev/cribro.git <cribro-dir>
cd <cribro-dir> && ./gradlew --quiet publishToMavenLocal :cribro-maven-plugin:extensionJar
-
Copy the extension jar into
~/.m2/cribro/. Run this from<cribro-dir>:mkdir -p ~/.m2/cribro && cp cribro-maven-plugin/build/dist/cribro-maven.jar ~/.m2/cribro/
The jar alone measures diff coverage.
cribro:pitest-diffandcribro:guidealso need the plugin in a repository Maven reads, which step 1 put in the local one. -
Check it from the project's root directory. The command prints
cribrowith the version you built and the modules with tests:mvn -Dmaven.ext.class.path="$HOME"/.m2/cribro/cribro-maven.jar -q cribro:guide -
Install the agent skill, which tells the agent when to run cribro and how to reach the guide through the extension jar.
agent/cribro/SKILL.mdis a plain skill file; for Claude Code, run this from<cribro-dir>:mkdir -p ~/.claude/skills/cribro && cp agent/cribro/SKILL.md ~/.claude/skills/cribro/
After git pull in <cribro-dir>, run steps 1 and 2 again, so that the extension jar and the plugin in the local
Maven repository are the same version.
Where a build loads cribro both ways, the build's copy acts and the other stands down.
cribro:guide prints the commands written for this build, the properties, and how to act on each report. The two
commands an agent runs most are these; with cribro installed on your machine, add
-Dmaven.ext.class.path="$HOME"/.m2/cribro/cribro-maven.jar to each:
mvn -pl <module> -am testmvn -pl <module> -am test-compile cribro:pitest-diff -Dcribro.pitestTargetTests=<tests><module> is the module whose tests exercise the change, written :artifactId. The tests of every module in the
build count, so -am adds the modules the tests depend on, and their changed code is measured too. Properties are
the Gradle ones with -D in place of -P.
Loaded as an extension, cribro:
- adds a JaCoCo agent to the
argLineof surefire'sdefault-testexecution just before it runs, whatever the POM sets there. Where theargLinealready attaches a JaCoCo agent, asjacoco-maven-plugin'sprepare-agentdoes, cribro reads that agent's file instead; - writes
target/cribro/jacoco.xmlandtarget/cribro/diff-coverage.txtin each module the change reached; - declares
cribro-maven-pluginin every module that does not declare it, so that thecribro:prefix resolves.
cribro:pitest-diff runs PIT in a separate JVM, with the classpath, JVM, argLine, system properties, environment
variables, working directory, groups, includes, and excludes of surefire's default-test execution.
An agent learns about cribro from one of two places:
- the
AGENTS.mdnote of a build that applies cribro, step 3 of Add cribro to a Gradle build or of Add cribro to a Maven build; - the agent skill installed with cribro on your machine, in Install cribro on your machine for any Gradle build or Install cribro on your machine for any Maven build. One skill covers both build tools.
A changed file is matched to its JaCoCo counters and its PIT mutants by the package it declares and its name, which is
what its class files record, so a Kotlin file whose directory does not follow its package is still measured. The block
on unchanged code the change routes new inputs to is built from the changed .java files only; a change to a .kt
file adds nothing to it.
PIT drops the mutants of the Kotlin compiler-generated code it knows about, such as null checks on parameters; the
rest are reported as live mutants on a changed line whose text gives no hint. Arcmutate's
Kotlin plugin filters more of them:
-Pcribro.pitestPlugins=com.arcmutate:pitest-kotlin-plugin:<version> in Gradle, or -Dcribro.pitestPlugins=... in
Maven, puts it on PIT's classpath, and it needs an Arcmutate licence file, arcmutate-licence.txt, at the repository
root; its page gives the terms.