a-pavithraa/springboot-skills-marketplace / plugins/springboot-architecture/skills/spring-boot-team-harness
spring-boot-team-harness
VerifiedUse 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.
assets/tests/ConfigurationKeysTests.java
View on GitHubpackage {{TEST_PACKAGE}};
import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
import org.springframework.boot.env.PropertiesPropertySourceLoader;
import org.springframework.boot.env.PropertySourceLoader;
import org.springframework.boot.env.YamlPropertySourceLoader;
import org.springframework.core.env.EnumerablePropertySource;
import org.springframework.core.env.PropertySource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
/**
* Spring Boot ignores a property key that no dependency defines, so a misspelt, renamed or removed key fails
* silently. This test checks every spring, management, server and logging key in the application's own
* config files against the configuration metadata of the jars on the classpath.
*/
class ConfigurationKeysTests {
private static final List<String> CHECKED_PREFIXES = List.of("spring.", "management.", "server.", "logging.");
private static final Set<String> UNSAFE_ENDPOINTS =
Set.of("*", "env", "configprops", "beans", "heapdump", "threaddump", "logfile", "loggers", "shutdown");
private static final Set<String> LOCAL_PROFILES = Set.of("local", "dev", "test", "observability");
private static final Pattern PLACEHOLDER_DEFAULT = Pattern.compile("\\$\\{([^:${}]+):([^${}]*)}");
private static final Set<String> STAND_IN_DEFAULTS = Set.of("mock", "fake", "stub", "noop", "dummy", "changeme");
private static final String[] METADATA_FILES = {
"META-INF/spring-configuration-metadata.json", "META-INF/additional-spring-configuration-metadata.json"
};
@Test
void everyBootKeyIsDefinedAndCurrent() throws IOException {
Metadata metadata = Metadata.load();
List<String> problems = new ArrayList<>();
for (Resource file : configFiles()) {
for (String key : keysIn(file)) {
if (CHECKED_PREFIXES.stream().noneMatch(key::startsWith)) {
continue;
}
String canonical = canonical(key);
if (!metadata.isKnown(canonical)) {
problems.add(file.getFilename() + ": " + key + " is defined by no dependency, so Boot ignores it");
} else if (metadata.deprecations.containsKey(canonical)) {
problems.add(
file.getFilename() + ": " + key + " is deprecated" + metadata.deprecations.get(canonical));
}
}
}
assertThat(problems).as("Fix or remove these configuration keys").isEmpty();
}
@Test
void shippedConfigKeepsActuatorPrivate() throws IOException {
List<String> problems = new ArrayList<>();
Map<String, String> base = new HashMap<>();
for (Resource file : configFiles()) {
if (!String.valueOf(file.getFilename()).contains("-")) {
base.putAll(valuesIn(file));
}
}
for (Resource file : configFiles()) {
if (isLocalProfile(file)) {
continue;
}
Map<String, String> values = valuesIn(file);
Map<String, String> effective = new HashMap<>(base);
effective.putAll(values);
if (!actuatorHasItsOwnPort(effective)) {
effective.forEach((key, value) -> {
if (key.startsWith("management.endpoints.web.exposure.include")) {
for (String endpoint : value.split(",")) {
if (UNSAFE_ENDPOINTS.contains(endpoint.strip())) {
problems.add(file.getFilename() + " exposes " + endpoint.strip()
+ " on the public port. Move it to a local profile, or set "
+ "management.server.port to a literal port other than server.port, "
+ "and keep that port off the public network");
}
}
}
});
}
if ("always".equals(values.get("management.endpoint.health.show-details"))) {
problems.add(file.getFilename() + " shows health details to anyone. Use when-authorized");
}
}
assertThat(problems).as("Actuator can leak secrets and internals").isEmpty();
}
@Test
void shippedConfigHasNoStandInDefaults() throws IOException {
List<String> problems = new ArrayList<>();
for (Resource file : configFiles()) {
if (isLocalProfile(file)) {
continue;
}
valuesIn(file).forEach((key, value) -> PLACEHOLDER_DEFAULT.matcher(value).results()
.filter(placeholder -> STAND_IN_DEFAULTS.contains(placeholder.group(2).strip().toLowerCase()))
.forEach(placeholder -> problems.add(file.getFilename() + ": " + key + " falls back to "
+ placeholder.group(2).strip() + " when " + placeholder.group(1) + " is unset, so a "
+ "deploy that forgets it runs on a stand-in. Remove the default, or move it to a local "
+ "profile")));
}
assertThat(problems).as("A shipped config file defaults to a stand-in").isEmpty();
}
/** Only says the ports differ. Whether the port is reachable depends on the deployment, which can't be read here. */
private static boolean actuatorHasItsOwnPort(Map<String, String> values) {
String management = port(values.get("management.server.port"));
String server = port(values.getOrDefault("server.port", "8080"));
if (management == null || server == null) {
return false;
}
return Set.of("0", "-1").contains(management) || !management.equals(server);
}
/** The literal port, or the default of a ${VAR:default} placeholder; null when the file doesn't decide it. */
private static @Nullable String port(@Nullable String value) {
if (value == null) {
return null;
}
String port = value.strip().replaceAll("^\\$\\{[^:}]+:(.*)}$", "$1");
return port.contains("${") ? null : port;
}
private static boolean isLocalProfile(Resource file) {
String name = file.getFilename() == null ? "" : file.getFilename();
int dash = name.indexOf('-');
int dot = name.lastIndexOf('.');
return dash > 0 && dot > dash && LOCAL_PROFILES.contains(name.substring(dash + 1, dot));
}
private static Map<String, String> valuesIn(Resource file) throws IOException {
String name = file.getFilename() == null ? "" : file.getFilename();
PropertySourceLoader loader =
name.endsWith(".properties") ? new PropertiesPropertySourceLoader() : new YamlPropertySourceLoader();
Map<String, String> values = new HashMap<>();
for (PropertySource<?> source : loader.load(name, file)) {
if (source instanceof EnumerablePropertySource<?> enumerable) {
for (String key : enumerable.getPropertyNames()) {
values.put(key, String.valueOf(enumerable.getProperty(key)));
}
}
}
return values;
}
private static List<Resource> configFiles() throws IOException {
var resolver = new PathMatchingResourcePatternResolver();
List<Resource> files = new ArrayList<>();
for (String pattern : List.of("application*.properties", "application*.yml", "application*.yaml")) {
for (Resource resource : resolver.getResources("classpath*:" + pattern)) {
if ("file".equals(resource.getURL().getProtocol())) {
files.add(resource);
}
}
}
return files;
}
private static Set<String> keysIn(Resource file) throws IOException {
String name = file.getFilename() == null ? "" : file.getFilename();
PropertySourceLoader loader =
name.endsWith(".properties") ? new PropertiesPropertySourceLoader() : new YamlPropertySourceLoader();
Set<String> keys = new HashSet<>();
for (PropertySource<?> source : loader.load(name, file)) {
if (source instanceof EnumerablePropertySource<?> enumerable) {
keys.addAll(List.of(enumerable.getPropertyNames()));
}
}
return keys;
}
/** Relaxed binding: case, dashes, underscores and list indexes don't matter. */
private static String canonical(String key) {
return key.replaceAll("\\[[^]]*]", "").toLowerCase().replaceAll("[-_]", "");
}
private record Metadata(Set<String> names, Set<String> maps, Map<String, String> deprecations) {
static Metadata load() throws IOException {
var metadata = new Metadata(new HashSet<>(), new HashSet<>(), new HashMap<>());
ClassLoader classLoader = ConfigurationKeysTests.class.getClassLoader();
for (String file : METADATA_FILES) {
Enumeration<URL> urls = classLoader.getResources(file);
while (urls.hasMoreElements()) {
try (InputStream in = urls.nextElement().openStream()) {
metadata.add(new String(in.readAllBytes(), StandardCharsets.UTF_8));
}
}
}
return metadata;
}
@SuppressWarnings("unchecked")
private void add(String json) {
Map<String, Object> document = (Map<String, Object>) new Json(json).value();
for (Object item : (List<Object>) document.getOrDefault("properties", List.of())) {
Map<String, Object> property = (Map<String, Object>) item;
String name = canonical(String.valueOf(property.get("name")));
names.add(name);
if (String.valueOf(property.get("type")).startsWith("java.util.Map")) {
maps.add(name);
}
if (property.get("deprecation") instanceof Map<?, ?> deprecation) {
Object replacement = deprecation.get("replacement");
deprecations.put(name, replacement == null ? "" : ", use " + replacement);
} else if (Boolean.TRUE.equals(property.get("deprecated"))) {
deprecations.put(name, "");
}
}
for (Object item : (List<Object>) document.getOrDefault("groups", List.of())) {
Map<String, Object> group = (Map<String, Object>) item;
if (String.valueOf(group.get("type")).startsWith("java.util.Map")) {
maps.add(canonical(String.valueOf(group.get("name"))));
}
}
}
boolean isKnown(String canonical) {
return names.contains(canonical) || maps.stream().anyMatch(map -> canonical.startsWith(map + "."));
}
}
/**
* Reads the metadata JSON without a JSON library. Boot's JsonParserFactory falls back to a parser that
* returns nested objects as strings when neither Jackson nor Gson is on the test classpath.
*/
private static final class Json {
private final String text;
private int at;
Json(String text) {
this.text = text;
}
@Nullable Object value() {
skipSpace();
char c = text.charAt(at);
if (c == '{') {
Map<String, Object> object = new HashMap<>();
at++;
while (next() != '}') {
String key = string();
expect(':');
object.put(key, value());
if (next() == ',') at++;
}
at++;
return object;
}
if (c == '[') {
List<Object> array = new ArrayList<>();
at++;
while (next() != ']') {
array.add(value());
if (next() == ',') at++;
}
at++;
return array;
}
if (c == '"') return string();
int start = at;
while (at < text.length() && ",}] \t\r\n".indexOf(text.charAt(at)) < 0) at++;
String word = text.substring(start, at);
return switch (word) {
case "true" -> Boolean.TRUE;
case "false" -> Boolean.FALSE;
case "null" -> null;
default -> word;
};
}
private String string() {
expect('"');
StringBuilder out = new StringBuilder();
while (text.charAt(at) != '"') {
char c = text.charAt(at++);
if (c != '\\') {
out.append(c);
continue;
}
char escaped = text.charAt(at++);
switch (escaped) {
case 'n' -> out.append('\n');
case 't' -> out.append('\t');
case 'r' -> out.append('\r');
case 'b' -> out.append('\b');
case 'f' -> out.append('\f');
case 'u' -> {
out.append((char) Integer.parseInt(text.substring(at, at + 4), 16));
at += 4;
}
default -> out.append(escaped);
}
}
at++;
return out.toString();
}
private char next() {
skipSpace();
return text.charAt(at);
}
private void expect(char c) {
if (next() != c) {
throw new IllegalStateException("Expected '" + c + "' at offset " + at + " of configuration metadata");
}
at++;
}
private void skipSpace() {
while (at < text.length() && Character.isWhitespace(text.charAt(at))) at++;
}
}
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| 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: 472k | Updated | Claude CodeCodex | Verified | Install |
| 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: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| 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 available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |