java-kotlin-standards
Use when writing, reviewing, testing, formatting, or building any Java or Kotlin code in a touchstone repo — triggers on .java/.kt files, build.gradle(.kts)/settings.gradle.kts, gradle/libs.versions.toml, or pom.xml. Covers JDK/Gradle toolchain, Spotless, null-safety, records/sealed types, coroutines/virtual threads, JUnit/Testcontainers, and reproducible builds. Not for Android UI, JVM service frameworks, or cross-cutting supply-chain (see security/dependencies siblings).
- License 许可
- MIT
- 最近更新
- 2026-08-26
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- java-kotlin-standards
- license
- MIT
- metadata
- { "author": "touchstone", "version": "0.2.0" }
- description
- Use when writing, reviewing, testing, formatting, or building any Java or Kotlin code in a touchstone repo — triggers on .java/.kt files, build.gradle(.kts)/settings.gradle.kts, gradle/libs.versions.toml, or pom.xml. Covers JDK/Gradle toolchain, Spotless, null-safety, records/sealed types, coroutines/virtual threads, JUnit/Testcontainers, and reproducible builds. Not for Android UI, JVM service frameworks, or cross-cutting supply-chain (see security/dependencies siblings).
03 SKILL.md 正文
Java & Kotlin (JVM) Standards
Full standard: standards/languages/java-kotlin.md in the touchstone repo. This skill inlines the
load-bearing rules so it stays useful even when installed standalone in ~/.claude/skills/:
Always
- One JDK, one build tool: LTS Temurin (21/25) via SDKMAN!, pinned by Gradle toolchain; Gradle Kotlin DSL + version catalog (
libs.versions.toml). Maven is the escape hatch. Commit + SHA-pin the Wrapper. - Format with Spotless (google-java-format + ktlint);
spotlessCheckis the CI gate. Error Prone + NullAway (Java) and Detekt (Kotlin) on every build; warnings are errors. - JUnit + AssertJ + Testcontainers; mock only genuine external collaborators (MockK/Mockito). Coverage is a ratcheted floor.
Don't get burned
- Null-safety: never
!!in Kotlin; use?./?:/requireNotNull. Java uses JSpecify@NullMarked+ NullAway.Optionalis a return type only — never a field or parameter. Assert nullability once at the Kotlin/Java seam. - Model data with
record/data classand closed hierarchies withsealed— exhaustiveswitch/whenwith nodefaultso a new variant is a compile error. - Structured concurrency: Kotlin coroutines in a
coroutineScope(neverGlobalScope); Java virtual threads +StructuredTaskScope(don't pool virtual threads, don't pin undersynchronized). Every blocking call is timeout-bounded. - Lock the graph: version catalog is the only version source; Gradle dependency locking + verification (checksums + signatures) on; commit the lockfile; CI builds
--offline.dependencyCheckAnalyzeclean. - Reproducible jars (stable timestamps/order); ship via jlink, GraalVM
native-imageonly where cold start is measured (scale-up). Supply-chain details:standards/practices/security.mdandstandards/practices/dependencies.md.
Done
spotlessCheck clean · Error Prone/NullAway + Detekt pass · warnings-as-errors · ./gradlew test green (Testcontainers for integration) · dependency locking + verification on, lockfile committed · dependencyCheckAnalyze clean · reproducible jars with SBOM + signed provenance. See standards/languages/java-kotlin.md.
04 同仓库更多 Skills
ok-standards
Use when writing shell, per standards/languages/shell.md.
demo-standards
Use when editing demo code in a touchstone fixture repo, a deliberately ordinary description that is long enough to clear the forty character minimum.
demo-standards
Use when editing demo code in a touchstone fixture repo, a deliberately ordinary description that is long enough to clear the forty character minimum.
demo-standards
Use when editing demo code in a touchstone fixture repo, a deliberately ordinary description that is long enough to clear the forty character minimum.
demo-standards
Use when editing demo code in a touchstone fixture repo, a deliberately ordinary description that is long enough to clear the forty character minimum.
demo-standards
Use when editing demo code in a touchstone fixture repo, a deliberately ordinary description that is long enough to clear the forty character minimum.