pattern-engineer-java
Skill0 starsChanged 5 months agoMITView on GitHub
Modern Java 21: committed `./gradlew`/`./mvnw` wrapper; Spotless + ErrorProne/NullAway; JUnit 5 + AssertJ + Testcontainers. `record` DTOs; sealed + exhaustive `switch` (no catch-all `default`); `Optional` return-only; `List.of()` never null; `final` + `List.copyOf`; rethrow wrapping cause; no broad `catch (Exception)`; try-with-resources; `BigDecimal` money, `java.time` not `Date`; constructor injection; `Objects.equals/hash`; virtual threads. Activate on `.java`, `pom.xml`, `build.gradle`.
In this repository74 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- create-bug-issueSkill
- create-enhancement-issueSkill
- create-feature-issuesSkill
- dream-summary-memorySkill
- memory-conventionSkill
- operation-gitSkill
- pattern-architect-api-endpointSkill
- pattern-architect-data-modelSkill
- pattern-architect-deep-moduleSkill
- pattern-e2e-coding-standardSkill
- pattern-engineer-apiSkill
- pattern-engineer-backend-standardSkill
- pattern-engineer-coding-standardSkill
- pattern-engineer-containerSkill
- pattern-engineer-databaseSkill
- pattern-engineer-fastapiSkill
- pattern-engineer-frontend-standardSkill
- pattern-engineer-goSkill
- pattern-engineer-kotlinSkill
- pattern-engineer-nodeSkill
- pattern-engineer-non-functionalSkill
- pattern-engineer-observabilitySkill
- pattern-engineer-pythonSkill
- pattern-engineer-rustSkill
- pattern-engineer-securitySkill
- pattern-engineer-ssrSkill
- pattern-engineer-swiftSkill
- pattern-engineer-typescriptSkill
- pattern-engineer-viteSkill
- pattern-exploratory-testingSkill
- pattern-reviewer-apiSkill
- pattern-reviewer-backend-standardSkill
- pattern-reviewer-coding-standardSkill
- pattern-reviewer-containerSkill
- pattern-reviewer-contractSkill
- pattern-reviewer-databaseSkill
- pattern-reviewer-fastapiSkill
- pattern-reviewer-frontend-standardSkill
- pattern-reviewer-goSkill
- pattern-reviewer-javaSkill
- pattern-reviewer-kotlinSkill
- pattern-reviewer-nodeSkill
- pattern-reviewer-non-functionalSkill
- pattern-reviewer-observabilitySkill
- pattern-reviewer-pythonSkill
- pattern-reviewer-rustSkill
- pattern-reviewer-securitySkill
- pattern-reviewer-ssrSkill
- pattern-reviewer-swiftSkill
- pattern-reviewer-test-coverageSkill
- pattern-reviewer-typescriptSkill
- pattern-reviewer-viteSkill
- pattern-test-coverageSkill
- principle-engineer-tddSkill
- scaffold-projectSkill
- workflow-architect-interviewSkill
- workflow-designer-sample-pagesSkill
- workflow-design-interviewSkill
- workflow-e2e-authorSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 2 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 14
After loading this skill, also check $MAIN_ROOT/.claude/memory/patterns/pattern-engineer-java.md in the consuming project (resolve …
- Very specific: line 30
Never return null for a collection — return List.of() / Map.of() / Set.of().
- Distinctive: line 36
No setters on domain types without a demonstrated need.
- Very specific: line 40
Never swallow — rethrow wrapping the cause: throw new DomainException(msg, e).
- Very specific: line 41
No broad catch (Exception e) / catch (Throwable t) except at a top-level boundary handler (request filter, executor, main).
- Very specific: line 53
Never == / != on boxed primitives (Integer, Long) or String — use .equals.
- Very specific: line 77
Test-coverage *substance* (what to cover, boundary/error cases) is owned by pattern-test-coverage — follow it rather than this skill …
- Distinctive: line 85
Run through the wrapper so the pinned toolchain + plugin versions apply.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
pattern-engineer-java
When to activate
Activate when writing or editing any .java file, scaffolding a Java service or library, editing a Java project's pom.xml / build.gradle / build.gradle.kts, tuning Spotless / ErrorProne / NullAway config, or working with JUnit 5 / AssertJ / Testcontainers / Spring / Jakarta. Skip for non-Java code; .kt / .kts files are owned by pattern-engineer-kotlin even inside a Gradle project.
Project memory overlay
After loading this skill, also check $MAIN_ROOT/.claude/memory/patterns/pattern-engineer-java.md in the consuming project (resolve MAIN_ROOT="$(dirname "$(git rev-parse --path-format=absolute --git-common-dir)")"). If present, load it as an additive overlay to the rules below; if absent, skip silently. See memory-convention for the full contract (additivity, severity floor, conflict surfacing).
Patterns
Toolchain & build
- Java 21 LTS; pin the toolchain in the build (
languageVersion = JavaLanguageVersion.of(21)/maven.compiler.release=21). - Build through the committed wrapper —
./gradlew/./mvnw, never a globally installedgradle/mvn. Commitgradlew,gradle/wrapper/(ormvnw,.mvn/wrapper/). - Spotless with
googleJavaFormat()is the format gate; ErrorProne with NullAway is the static-analysis gate. Wire both intocheck/verify; nothing merges red. - JUnit 5 (
useJUnitPlatform()) + AssertJ for tests; Testcontainers for DB-touching integration tests. No JUnit 4, no PowerMock.
Types & data carriers
recordfor DTOs, value objects, and multi-value returns — not a hand-written class with getters.- Sealed interfaces/classes for closed hierarchies; switch over them with pattern matching kept exhaustive — no
defaultarm that silently absorbs future variants (let the compiler flag the gap when a variant is added). Optionalas a return type only — never a field, parameter, or collection element.- Never return
nullfor a collection — returnList.of()/Map.of()/Set.of().
Immutability
finalfields by default; mutate only where state genuinely changes.- Defensive copies at constructor/accessor boundaries via
List.copyOf/Map.copyOf/Set.copyOf. - No setters on domain types without a demonstrated need.
Errors & resources
- Never swallow — rethrow wrapping the cause:
throw new DomainException(msg, e). - No broad
catch (Exception e)/catch (Throwable t)except at a top-level boundary handler (request filter, executor,main). - try-with-resources for every
AutoCloseable— never a manualclose()in afinallyblock.
Numbers & time
BigDecimalwith an explicit scale +RoundingModefor money/precise decimals — neverdouble/float.java.time(Instant,LocalDate,LocalDateTime,ZonedDateTime,Duration) — neverDate/Calendar/SimpleDateFormat.- Store and compare instants in UTC; attach a zone only at display boundaries.
Equality
record, orequals+hashCodealways overridden together (one without the other is a bug); build both viaObjects.equals/Objects.hash.- Never
==/!=on boxed primitives (Integer,Long) orString— use.equals; forStringconstants use"literal".equals(x).
Dependency injection
- Constructor injection only — no field
@Autowired/@Inject/@Resource. - Components stateless; hold collaborators in
finalfields set by the constructor.
Streams & collections
- Streams for transformation pipelines (map/filter/collect); plain
for/ enhanced-for loops for side-effect-heavy logic. - No
parallelStream()without a measured win on a CPU-bound workload over a large dataset. - Collect to immutable results (
Stream.toList(),Collectors.toUnmodifiableList()).
Concurrency
- Virtual threads (
Executors.newVirtualThreadPerTaskExecutor()) for blocking-I/O concurrency. ExecutorServiceover a rawnew Thread(...).start(); shut executors down (try-with-resources on 21+, elsefinally).ConcurrentHashMapor an immutable map oversynchronizedblocks guarding a shared map; no hand-rolled double-checked locking — use a holder class or memoizedSupplier.
Tests
@ParameterizedTest(+@MethodSource/@CsvSource) for table-driven cases — not copy-pasted@Testmethods.- AssertJ fluent assertions (
assertThat(x).isEqualTo(...),assertThatThrownBy(...)) over bare JUnitassertEquals. - Testcontainers for tests that touch a real database/broker; no shared mutable static test state.
- Test-coverage substance (what to cover, boundary/error cases) is owned by
pattern-test-coverage— follow it rather than this skill restating it.
Adjacent surfaces
- HTTP/REST endpoint shape, status codes, and pagination are owned by
pattern-engineer-api; cross-language service wiring bypattern-engineer-backend-standard; injection / SQL / crypto / authz bypattern-engineer-security. Follow those rather than restating them here.
Tooling
Run through the wrapper so the pinned toolchain + plugin versions apply.
./gradlew spotlessCheck # google-java-format gate
./gradlew spotlessApply # auto-format
./gradlew compileJava # ErrorProne + NullAway run here
./gradlew test # JUnit 5
./gradlew check # all gatesMaven equivalent:
./mvnw spotless:check
./mvnw spotless:apply
./mvnw verify # compile (ErrorProne/NullAway) + testCanonical Gradle gate wiring:
plugins {
id("com.diffplug.spotless") version "6.25.0"
id("net.ltgt.errorprone") version "4.0.1"
}
java { toolchain { languageVersion = JavaLanguageVersion.of(21) } }
spotless { java { googleJavaFormat() } }
dependencies {
errorprone("com.google.errorprone:error_prone_core:2.27.1")
errorprone("com.uber.nullaway:nullaway:0.10.26")
}
tasks.withType<JavaCompile>().configureEach {
options.errorprone {
check("NullAway", net.ltgt.gradle.errorprone.CheckSeverity.ERROR)
option("NullAway:AnnotatedPackages", "com.example")
}
}Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

