Skip to content

Repository files navigation

Detektifier

A Gradle plugin that rewrites Detekt reports in a way that is easier for coding agents to process reported issues.

When the detektifierReport task runs, it reads Detekt's Checkstyle XML report and generates a compact plain-text violations report optimized for AI agent consumption. Each violation is formatted as a single line: relative/path/to/File.kt:line [ruleSetId/ruleName] message. The report is always written to build/reports/detektifier/violations.txt — even when Detekt fails — so agents can consistently read and act on violations.

Report format and freshness

The report begins with a provenance header so you can tell a current report from a stale leftover:

# Detektifier report — generated 2026-06-30T10:00:00Z
# sources (1): build/reports/detekt/detekt.xml (2026-06-30T09:59:59Z)
# No violations
  • A # WARNING: report may be stale line means the Detekt XML predates the build scripts; re-run with --rerun-tasks.
  • A # No Detekt output analyzed (...) body means the Detekt tasks were NO-SOURCE, skipped, or never ran — common on Kotlin Multiplatform modules, where the aggregate detekt task analyzes nothing. This is not a clean result.

Run ./gradlew :<module>:detektifierDoctor to see which Detekt tasks exist, which ones the report is wired to, and the report's freshness.

In a multi-module build, applying the plugin to the root project adds detektifierAggregateReport, which merges every submodule's report into build/reports/detektifier/aggregate-violations.txt.

Requirements

  • Gradle 8+
  • Kotlin DSL or Groovy DSL (build.gradle.kts or build.gradle)
  • Detekt Gradle plugin applied to the same module
  • Detekt 1.23.8 or 2.0.0-alpha.2 (newer Detekt versions will be supported as they are released)

Adding the Plugin

The plugin is published to the Gradle Plugin Portal. Apply it alongside Detekt in your module's build.gradle.kts:

// Detekt 1.x
plugins {
    id("io.gitlab.arturbosch.detekt") version "1.23.8"
    id("com.commonsware.detektifier") version "0.2.0"
}

// Detekt 2.x
plugins {
    id("dev.detekt") version "2.0.0-alpha.2"
    id("com.commonsware.detektifier") version "0.2.0"
}

Or in build.gradle:

// Detekt 1.x
plugins {
    id 'io.gitlab.arturbosch.detekt' version '1.23.8'
    id 'com.commonsware.detektifier' version '0.2.0'
}

// Detekt 2.x
plugins {
    id 'dev.detekt' version '2.0.0-alpha.2'
    id 'com.commonsware.detektifier' version '0.2.0'
}

No additional repository declarations are needed if you already have gradlePluginPortal() in your settings.gradle.kts plugin management block:

pluginManagement {
    repositories {
        gradlePluginPortal()
        mavenCentral()
    }
}

Running the Task

Run the Detekt analysis task for your module:

./gradlew :your-module:detekt

detektifierReport runs automatically as a build finalizer — you do not invoke it directly. The report is always written, even when Detekt finds violations and the build fails.

Why not run detektifierReport directly? Detektifier uses finalizedBy rather than dependsOn so that the report task still runs when Detekt fails. The trade-off is that running detektifierReport directly will not trigger Detekt, so no XML is produced and the report will show # No violations.

Report Format

The report is written to <module>/build/reports/detektifier/violations.txt:

When there are no violations:

# No violations

When violations are found:

src/main/kotlin/com/example/Foo.kt:10 [style/MagicNumber] 5 is a magic number.
src/main/kotlin/com/example/Foo.kt:25 [complexity/LongMethod] The function foo is too long.
src/main/kotlin/com/example/Bar.kt:3 [naming/VariableNaming] Variable name 'x' is too short.

Violations are sorted by file path, then line number. Each line contains:

  • File path — relative to the module root
  • Line number — where the violation occurs
  • Rule ID — in the format ruleSetId/ruleName (e.g., style/MagicNumber)
  • Message — the human-readable violation message from Detekt

Teaching Your Agent to Use Detektifier

Detektifier ships with a ready-made skill that tells AI coding agents how to run the detektifierReport task, read the report, and make changes to the code to fix the reported issues.

The skill is at skills/detektifier-report/SKILL.md in this repository.

Adding the Skill to Claude Code

Claude Code discovers skills placed in .claude/skills/<skill-name>/SKILL.md within your project. Copy the skill directory there (create .claude/skills/ if it does not exist):

# From your project root
mkdir -p .claude/skills/detektifier-report
cp path/to/detektifier/skills/detektifier-report/SKILL.md .claude/skills/detektifier-report/SKILL.md

Once the file is in place, the skill is available in Claude Code as:

/detektifier-report

You can invoke it directly, or instruct Claude to run it after writing or modifying tests in a module.

Adding the Skill to Other Agents

Any agent that supports file-based skill definitions can use the same file. Copy skills/detektifier-report/SKILL.md to wherever your agent looks for skill definitions and follow that agent's conventions for invocation.

If your agent does not have a skill system, paste the contents of the file into your agent's system prompt or project instructions.

License

Apache License 2.0

Contributing

See CONTRIBUTING.md for guidelines before submitting changes.

Changelog

See CHANGELOG.md for a history of notable changes.

About

A Gradle plugin that rewrites Detekt reports in a way that is easier for coding agents to process reported issues. Read-only mirror of https://codeberg.org/commonsguy/detektifier.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages