AgentLint Verified 98/100120 Java repos analyzed

    Java CLAUDE.md & AGENTS.md Template

    Targeted Gradle/Maven test execution, null-safety, and Spring/JVM patterns from Java repos.

    # Java Project — Java Harness
    
    Java 21 Gradle multi-module service with JUnit 5, Spotless formatting, and Checkstyle gates.
    
    ## Commands
    
    - Fast single test: `./gradlew :core:test --tests '*InvoiceServiceTest'`
    - Full verification: `./gradlew check`
    - Format & lint: `./gradlew spotlessApply && ./gradlew checkstyleMain`
    
    ## Rules
    
    - Don't run the full multi-module Gradle build for a single class change. Instead target the module and test filter above. Because full builds take 2+ minutes per loop.
    - Don't return `null` from public service methods when absence is expected. Instead return `Optional<T>` or an empty collection. Because unchecked nulls cause production NPEs.
    - When changing database entities, read `docs/flyway-migrations.md` first.
    
    ## Continuity
    
    - Keep `application-local.yml` and `CLAUDE.local.md` out of git and record migration steps in `HANDOFF.md`.

    Most Adopted Java Rules Across Real Open-Source Repos

    Measured across 120 public Java repositories in the 4,533-repo harness study:

    maventooling

    Maven build tool

    49.1%26 repos
    dockertooling

    Docker for containerization

    47.2%25 repos
    unit-teststesting

    Write unit tests for all changes

    41.5%22 repos
    springframework

    Spring Framework

    39.6%21 repos
    spring-bootframework

    Spring Boot framework

    37.7%20 repos
    junittesting

    JUnit for testing

    32.1%17 repos
    optionalpatterns

    Use Optional instead of null

    32.1%17 repos
    gradletooling

    Gradle build tool

    30.2%16 repos
    Essential Commands (Checks W1 & W7)
    install
    ./gradlew dependencies
    fastTest
    ./gradlew :module:test --tests '*TargetTest'
    fullTest
    ./gradlew check
    lint
    ./gradlew spotlessCheck checkstyleMain
    build
    ./gradlew build -x test
    Common Java Agent Pitfalls
    • 01Running full ./gradlew build on every edit wastes minutes; always document --tests '*ClassName'.
    • 02Agents disable Spotless/Checkstyle instead of running ./gradlew spotlessApply.

    More Verified Stack Templates