Skip to content

a-pavithraa/springboot-skills-marketplace / plugins/springboot-architecture/skills/spring-boot-team-harness

spring-boot-team-harness

Verified

Use when a team wants every developer's coding agent (Claude Code or Codex) to follow the same rules and coding conventions on a Maven or Gradle Spring Boot 4 repository: setting up AGENTS.md, coding standards, guardrails, shared agent settings, or build and CI checks that agents must pass before code merges. It adds ./mvnw verify or ./gradlew build gates that fail on null-safety bugs (NullAway with JSpecify), module-boundary breaches (Spring Modulith), unknown or deprecated Boot property keys, Spring mistakes that compile (ArchUnit) and unformatted code, Claude Code and Codex hooks that run those gates before a turn ends, and a CI workflow.

FileKindSize
SKILL.mdskill md20.3 KB
assets/gradle/harness.gradleother5.4 KB
assets/observability/HandledFailureFilter.javaother2.1 KB
assets/observability/InstallOpenTelemetryAppender.javaother877 B
assets/observability/LogLeakCheck.javaother3.3 KB
assets/observability/application-observability-defaults.ymlconfig1.9 KB
assets/observability/application-observability.ymlconfig445 B
assets/observability/check_dashboards.pyscript3.4 KB
assets/observability/check_request.pyscript6.6 KB
assets/observability/compose.observability.ymlconfig704 B
assets/observability/dashboards/jvm-resources.jsonconfig7.7 KB
assets/observability/dashboards/service-health.jsonconfig10.7 KB
assets/observability/grafana-provider.yamlconfig133 B
assets/observability/logback-spring.xmlconfig736 B
assets/observability/observability.mdmarkdown7.4 KB
assets/pom/dependencies.xmlconfig236 B
assets/pom/managed-dependencies.xmlconfig355 B
assets/pom/modules-dependencies.xmlconfig269 B
assets/pom/observability-dependencies.xmlconfig833 B
assets/pom/plugins.xmlconfig2.2 KB
assets/pom/properties.xmlconfig642 B
assets/pom/rules-dependencies.xmlconfig268 B
assets/project/.claude/hooks/guard.shscript7.2 KB
assets/project/.claude/hooks/verify-on-stop.shscript11.9 KB
assets/project/.claude/settings.jsonconfig1.4 KB
assets/project/.codex/hooks.jsonconfig858 B
assets/project/.github/harness/check-file-size.shscript3.7 KB
assets/project/.github/harness/check-protected.shscript10.0 KB
assets/project/.github/workflows/harness-integrity.ymlconfig1.6 KB
assets/project/.github/workflows/verify.ymlconfig440 B
assets/project/.mvn/jvm.configother644 B
assets/project/AGENTS.mdmarkdown10.2 KB
assets/project/CLAUDE.mdmarkdown11 B
assets/project/REVIEW.mdmarkdown2.6 KB
assets/tests/BuildSetupTests.javaother19.6 KB
assets/tests/CodeRulesTests.javaother42.2 KB
assets/tests/ConfigurationKeysTests.javaother14.2 KB
assets/tests/ModuleBoundariesTests.javaother10.3 KB
assets/tests/UnusedCodeTests.javaother9.3 KB
assets/tests/archunit.propertiesother106 B
references/browser-verification.mdmarkdown18.1 KB
references/gates.mdmarkdown7.7 KB
scripts/apply_harness.pyscript59.6 KB
scripts/baseline.pyscript8.9 KB
scripts/report.pyscript6.1 KB

assets/tests/UnusedCodeTests.java

View on GitHub
package {{TEST_PACKAGE}};

import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes;
import static com.tngtech.archunit.library.freeze.FreezingArchRule.freeze;

import com.tngtech.archunit.base.DescribedPredicate;
import com.tngtech.archunit.core.domain.JavaClass;
import com.tngtech.archunit.core.domain.JavaClasses;
import com.tngtech.archunit.core.domain.JavaMethod;
import com.tngtech.archunit.core.domain.JavaModifier;
import com.tngtech.archunit.core.importer.ClassFileImporter;
import com.tngtech.archunit.core.importer.ImportOption;
import com.tngtech.archunit.lang.ArchCondition;
import com.tngtech.archunit.lang.ArchRule;
import com.tngtech.archunit.lang.ConditionEvents;
import com.tngtech.archunit.lang.SimpleConditionEvent;
import java.io.IOException;
import java.io.Reader;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.jupiter.api.Test;

/**
 * Production methods that only tests call: dead code its tests keep alive, or an internal opened up so a test can
 * look inside. Not part of the end-of-turn hook, because a service is often written and tested before anything
 * calls it; by verify, before the pull request, everything the change added has a caller or goes. On a codebase
 * that baseline.py recorded, today's cases in src/test/resources/archunit_store are tolerated. If the record predates
 * this rule, every case fails until baseline.py runs again.
 */
class UnusedCodeTests {

    private static final String BASE_PACKAGE = "{{BASE_PACKAGE}}";

    private static final Pattern PACKAGE = Pattern.compile("^\\s*package\\s+([\\w.]+)\\s*;", Pattern.MULTILINE);

    private static final JavaClasses MAIN = new ClassFileImporter()
            .withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_TESTS)
            .importPackages(BASE_PACKAGE);

    /** Main and test code together, so a method's callers include the tests. */
    private static final JavaClasses ALL = new ClassFileImporter().importPackages(BASE_PACKAGE);

    private static final Set<String> PRODUCTION =
            MAIN.stream().map(JavaClass::getName).collect(Collectors.toSet());

    private static final DescribedPredicate<JavaClass> HANDWRITTEN = handwritten();

    private static final boolean RECORDING = Boolean.getBoolean("archunit.freeze.store.default.allowStoreCreation");

    /** Spring calls these itself, so they have no callers in the code. */
    private static final List<String> ENTRY_POINTS = List.of(
            "org.springframework.web.bind.annotation.RequestMapping",
            "org.springframework.web.bind.annotation.ExceptionHandler",
            "org.springframework.context.annotation.Bean",
            "org.springframework.context.event.EventListener",
            "org.springframework.scheduling.annotation.Scheduled",
            "org.springframework.kafka.annotation.KafkaListener",
            "org.springframework.amqp.rabbit.annotation.RabbitListener",
            "org.springframework.jms.annotation.JmsListener");

    @Test
    void productionMethodsAreNotThereOnlyForTests() {
        ArchRule rule = classes()
                .that(DescribedPredicate.describe("are production classes",
                        type -> PRODUCTION.contains(type.getName()) && HANDWRITTEN.test(type)))
                .should(notHaveMethodsOnlyTestsCall())
                .because("nothing in production calls it. If this change is meant to call it, wire that up; "
                        + "otherwise test through the public behaviour and delete it. If the user asked for it and "
                        + "nothing is meant to call it yet, don't route existing code through it to pass this rule: "
                        + "stop and ask the user")
                .allowEmptyShould(true);
        (RECORDING || recorded(rule) ? freeze(rule) : rule).check(ALL);
    }

    /** The store files each rule under its description, in this properties file. */
    private static boolean recorded(ArchRule rule) {
        Path index = Path.of("src/test/resources/archunit_store/stored.rules");
        if (!Files.isRegularFile(index)) {
            return false;
        }
        Properties rules = new Properties();
        try (Reader reader = Files.newBufferedReader(index)) {
            rules.load(reader);
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
        return rules.containsKey(rule.getDescription());
    }

    /**
     * A method counts when every caller is a test. Getters and setters are left out because Jackson, JPA, templates
     * and form binding call them by reflection, and so are methods named in @PreAuthorize-style expressions, which
     * bytecode can't see.
     */
    private static ArchCondition<JavaClass> notHaveMethodsOnlyTestsCall() {
        String expressions = MAIN.stream()
                .flatMap(type -> Stream.concat(Stream.of(type), type.getMethods().stream()))
                .flatMap(element -> element.getAnnotations().stream())
                .filter(annotation -> annotation.getRawType().getPackageName()
                        .equals("org.springframework.security.access.prepost"))
                .map(annotation -> String.valueOf(annotation.get("value").orElse("")))
                .collect(Collectors.joining(" "));
        return new ArchCondition<>("not have methods that only tests call") {
            @Override
            public void check(JavaClass type, ConditionEvents events) {
                if (type.isRecord() || type.isEnum() || type.isInterface() || type.isAnnotation()) {
                    return;
                }
                for (JavaMethod method : type.getMethods()) {
                    Set<JavaModifier> modifiers = method.getModifiers();
                    if (modifiers.contains(JavaModifier.PRIVATE)
                            || modifiers.contains(JavaModifier.PROTECTED)
                            || modifiers.contains(JavaModifier.SYNTHETIC)
                            || method.getName().equals("main")
                            || (method.getName().matches("(get|is)[A-Z].*") && method.getRawParameterTypes().isEmpty())
                            || (method.getName().matches("set[A-Z].*") && method.getRawParameterTypes().size() == 1)
                            || ENTRY_POINTS.stream().anyMatch(method::isMetaAnnotatedWith)
                            || overridesAnother(type, method)
                            || expressions.contains("." + method.getName() + "(")) {
                        continue;
                    }
                    Set<String> callers = method.getAccessesToSelf().stream()
                            .map(access -> access.getOriginOwner().getName())
                            .collect(Collectors.toSet());
                    if (!callers.isEmpty() && callers.stream().noneMatch(PRODUCTION::contains)) {
                        events.add(SimpleConditionEvent.violated(
                                method, method.getDescription() + " is called only from tests"));
                    }
                }
            }
        };
    }

    /**
     * Leaves out classes compiled from target/generated-sources or build/generated, such as OpenAPI models and MapStruct
     * mappers: the generator writes them, so its configuration is where they change. They still count as callers.
     * Their class files sit beside the team's and @Generated isn't kept in bytecode, so they're named from the
     * generated source files.
     */
    private static DescribedPredicate<JavaClass> handwritten() {
        Set<String> generated = Stream.of(Path.of("target/generated-sources"), Path.of("build/generated"))
                .filter(Files::isDirectory)
                .flatMap(UnusedCodeTests::javaFiles)
                .map(UnusedCodeTests::className)
                .collect(Collectors.toSet());
        return DescribedPredicate.describe("are written by hand", type -> {
            String name = type.getName();
            return !generated.contains(name.contains("$") ? name.substring(0, name.indexOf('$')) : name);
        });
    }

    private static Stream<Path> javaFiles(Path root) {
        try (Stream<Path> files = Files.walk(root)) {
            return files.filter(file -> file.toString().endsWith(".java")).toList().stream();
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }

    private static String className(Path source) {
        String simpleName = source.getFileName().toString().replaceFirst("\\.java$", "");
        try {
            return PACKAGE.matcher(Files.readString(source)).results().findFirst()
                    .map(found -> found.group(1) + "." + simpleName)
                    .orElse(simpleName);
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }

    private static boolean overridesAnother(JavaClass type, JavaMethod method) {
        return Stream.concat(type.getAllRawSuperclasses().stream(), type.getAllRawInterfaces().stream())
                .flatMap(other -> other.getMethods().stream())
                .anyMatch(other -> other.getName().equals(method.getName())
                        && other.getRawParameterTypes().size() == method.getRawParameterTypes().size());
    }
}
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall