pattern-engineer-kotlin
Skill0 starsChanged 5 months agoMITView on GitHub
Modern idiomatic Kotlin (JVM/server): Gradle Kotlin DSL + wrapper; ktlint/detekt gates; JUnit 5 + MockK; no `!!` in prod (`?.`/`?:`/`requireNotNull`); pin Java platform types at boundaries; `data class` DTOs; sealed types + exhaustive `when` (no domain `else`); `value class` ids; `val` + read-only `List`; structured concurrency (no `GlobalScope`); `suspend` never blocks (`withContext(Dispatchers.IO)`); never swallow `CancellationException`; `Flow` streams; named args. Activate on `.kt`/`.kts`.
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-javaSkill
- 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
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
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-kotlin.md in the consuming project (resolve …
- Very specific: line 39
Read-only collection types in public signatures (List, Map, Set — never MutableList / ArrayList).
- Distinctive: line 52
No exception-as-control-flow — branch on a value, not on a thrown-and-caught exception.
≈ “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-kotlin
When to activate
Activate when writing or editing any .kt or .kts file, scaffolding a Kotlin service or shared module, editing Gradle Kotlin DSL build scripts (build.gradle.kts / settings.gradle.kts), tuning .editorconfig / ktlint / detekt config, or working with coroutines / Flow / kotlinx.serialization / JUnit 5 / MockK / Kotest. Skip for non-Kotlin code; pure-Java files are owned by pattern-engineer-java.
Project memory overlay
After loading this skill, also check $MAIN_ROOT/.claude/memory/patterns/pattern-engineer-kotlin.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
- Gradle with the Kotlin DSL (
build.gradle.kts); commit the wrapper (gradlew,gradle/wrapper/) and pin the distribution. - ktlint and detekt are the gates; nothing merges red. Wire both into the
checktask. - JUnit 5 (
useJUnitPlatform()) + MockK for tests; Kotest acceptable. Don't pull in legacy JUnit 4 or PowerMock. - Pin the JVM toolchain (
kotlin { jvmToolchain(21) }) so the build is reproducible across machines. - kotlinx.serialization or Jackson lives at the boundary only — keep (de)serialization annotations off core domain types.
Null safety
- No
!!in production code —?./?:chains, smart casts, or early return instead. (!!in tests is fine.) requireNotNull(x) { "..." }/checkNotNull(x) { "..." }with a message to assert an invariant and narrow the type.- Pin platform types from Java interop with an explicit nullable/non-null type at the boundary (
val name: String = javaApi.getName()), never letString!leak inward. lateinitonly for genuinely deferred non-null init (DI / lifecycle); never as a!!workaround for nullable data.
Types
data classfor DTOs / value carriers — no behavior beyond trivial derived properties.- Sealed interface / sealed class + exhaustive
whenfor closed domain hierarchies; noelsearm on a domainwhen(it silently absorbs a future variant — let the compiler flag the gap). value class(inline) for domain ids (@JvmInline value class UserId(val value: Long)) — no bareLong/Stringids.valovervar; reassignable state is the exception, not the default.- Read-only collection types in public signatures (
List,Map,Set— neverMutableList/ArrayList); mutate locally, expose read-only.
Coroutines
- Structured concurrency only — never
GlobalScope. Scope is owned by the lifecycle owner; child work is launched in that scope. suspendfunctions never block a thread — wrap blocking I/O inwithContext(Dispatchers.IO) { ... }.Flowfor streams of values; cold by default, collected in the consumer's scope.- Cancellation stays cooperative — never swallow
CancellationException. If youcatch (e: Exception)around suspending code, rethrowCancellationExceptionfirst. runCatchingaround suspending code catchesCancellationException— avoid it there, or rethrow it explicitly inside the failure branch.
Errors
- Wrap with cause when rethrowing (
throw DomainException("...", e)); catch the narrowest type that applies. - No exception-as-control-flow — branch on a value, not on a thrown-and-caught exception.
- Sealed result types (or
Result<T>) at module seams where callers must branch on failure; exceptions for truly exceptional, non-branched failures.
Idiom
- Expression bodies for one-liners (
fun area() = w * h); block body only when there's real statement logic. - Named arguments for boolean params and runs of adjacent same-type params (
move(x = 1, y = 2, animate = true)). - Scope functions (
let/apply/also/run) at most one level deep — nested scope-function chains are a smell; name an intermediatevalinstead. - Extension functions for utilities, not core domain behavior — domain behavior belongs as methods on the type.
- String templates (
"id=$id") over+concatenation.
Security-grade rules (secret handling, crypto choice, input validation) are owned by
pattern-engineer-security; test-coverage substance bypattern-test-coverage; language-agnostic service wiring bypattern-engineer-backend-standard/pattern-engineer-api. This skill does not restate them.
Tooling
./gradlew ktlintCheck # Style / formatting gate
./gradlew detekt # Static analysis gate
./gradlew test # JUnit 5 (+ MockK / Kotest)
./gradlew check # Aggregate gate (ktlint + detekt + test)Auto-fix style before re-running:
./gradlew ktlintFormatA minimal detekt baseline worth pinning (fail on the null-safety and coroutine smells this skill enforces):
# detekt.yml
potential-bugs:
active: true
UnsafeCast: { active: true }
style:
active: true
ForbiddenMethodCall:
active: true
methods: ['kotlinx.coroutines.GlobalScope']
MaxLineLength: { maxLineLength: 120 }
coroutines:
active: true
GlobalCoroutineUsage: { active: true }
SuspendFunWithFlowReturnType: { active: true }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.

