kotlin-idiomatic-refactorer-spring-aware
Skill15 starsChanged 9 months agoMITView on GitHub
Refactor Kotlin code toward clearer, more idiomatic design without breaking Spring behavior, serialization, persistence, or public contracts. Use when Java-flavored Kotlin needs cleanup, domain modeling should become more expressive, or boilerplate should be reduced, but the refactoring must remain safe for proxies, Jackson, JPA, configuration binding, and existing tests.
1 other project uses a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- JetBrains/skillsedited, first seen Apr 28, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 1
- JetBrains/skills★ 38696% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository24 other files it gives its agents.
- ci-cd-containerization-advisorSkill
- configuration-properties-profiles-kotlin-safeSkill
- dependency-conflict-resolverSkill
- domain-decomposition-api-design-advisorSkill
- error-model-validation-architectSkill
- gradle-kotlin-dsl-doctorSkill
- integration-resilience-engineerSkill
- jackson-kotlin-serialization-specialistSkill
- java-kotlin-migration-assistantSkill
- jpa-spring-data-kotlin-mapperSkill
- kotlin-spring-proxy-compatibilitySkill
- observability-integratorSkill
- performance-concurrency-advisorSkill
- production-incident-responderSkill
- project-context-ingestionSkill
- schema-migration-plannerSkill
- spring-context-di-reasoningSkill
- spring-kotlin-code-reviewSkill
- spring-mvc-webflux-api-builderSkill
- spring-security-configurator-auditorSkill
- stacktrace-log-triageSkill
- test-suite-builderSkill
- transaction-consistency-designerSkill
- upgrade-breaking-change-navigatorSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
20 rules. About 0 are common, 17 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈17
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
Prefer refactorings that increase clarity and reduce accidental complexity while preserving behavior.
- Distinctive: line 28
Keep changes incremental unless the user explicitly wants a larger rewrite.
- Distinctive: line 32
Prefer constructor injection and immutable dependencies.
- Very specific: line 34
Use sealed class or sealed interface for closed result or error domains.
- Very specific: line 35
Use data class for pure transport or value models, not for JPA entities.
- Distinctive: line 36
Use value classes for domain primitives when the surrounding framework stack can support them safely.
- Very specific: line 37
Prefer explicit null-handling over scattered !!
- Distinctive: line 38
Use extension functions only when they improve discoverability and do not obscure ownership or layering.
- Distinctive: line 60
Prefer refactors that make invalid states harder to represent, not only code shorter to read.
- Distinctive: line 61
Keep business transitions explicit when the domain has invariants, auditing, or transactional significance.
- Distinctive: line 62
If a refactor improves local beauty but obscures logs, traces, or step-by-step debugging, it is probably not worth it.
- Distinctive: line 67
Do not refactor proxy-reliant classes in ways that remove needed openness or change bean boundaries accidentally.
- Distinctive: line 68
Do not convert entities into data classes or over-lean value objects without checking persistence support.
- Distinctive: line 69
Do not change constructor shapes for DTOs or config classes without checking Jackson and configuration binding.
- Distinctive: line 70
Do not move logic into extension functions that cross architecture layers implicitly.
- Distinctive: line 71
Do not hide important framework interactions behind clever utility abstractions.
- Distinctive: line 85
Do not refactor for aesthetics alone when risk is non-trivial.
- Distinctive: line 86
Do not introduce advanced Kotlin constructs just to prove idiomatic knowledge.
- Distinctive: line 87
Do not compress code until debugability suffers.
- Distinctive: line 88
Do not change public contracts without calling that out explicitly.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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
Kotlin Idiomatic Refactorer Spring Aware
Source mapping: Tier 2 high-value skill derived from Kotlin_Spring_Developer_Pipeline.md (SK-20).
Mission
Improve the codebase's Kotlin quality without trading away framework correctness. Prefer refactorings that increase clarity and reduce accidental complexity while preserving behavior.
Read First
- The current implementation and its tests.
- Public signatures, annotations, and serialization or persistence boundaries.
- Build plugins and framework constraints already discovered in project context.
- Existing code style and module-boundary conventions.
Refactor In This Order
- Characterize current behavior with tests or existing callers.
- Identify whether the code is transport DTO, domain logic, entity, configuration, or framework glue.
- Apply the smallest idiomatic improvement that materially helps readability or safety.
- Re-check proxy, serialization, and persistence compatibility.
- Keep changes incremental unless the user explicitly wants a larger rewrite.
High-Value Kotlin Moves
- Prefer constructor injection and immutable dependencies.
- Replace imperative branching with
whenwhen it improves exhaustive reasoning. - Use
sealed classorsealed interfacefor closed result or error domains. - Use
data classfor pure transport or value models, not for JPA entities. - Use value classes for domain primitives when the surrounding framework stack can support them safely.
- Prefer explicit null-handling over scattered
!!. - Use extension functions only when they improve discoverability and do not obscure ownership or layering.
Advanced Refactoring Traps
- More concise is not always clearer. Scope functions can hide control flow and receiver identity quickly.
- A beautiful Kotlin one-liner can become unreadable when side effects, logging, or transactions are involved.
- Value classes are excellent domain tools but may require extra care for Jackson, JPA, validation, and map keys.
Sequenceand lazy pipelines are not automatically faster, especially around JPA or repeated iteration.- Converting mutable services to expression-heavy style must not hide exception paths or operational logging.
- Replacing explicit classes with generic helper abstractions often harms Spring traceability and domain clarity.
- Refactoring null handling can silently change API semantics if
null, absent, and default were distinct before.
Kotlin Language Nuances
- Public inline functions, default arguments, and generated overloads can affect binary compatibility for library modules more than teams expect.
- A read-only Kotlin collection type does not guarantee an immutable backing collection. Refactors that assume true immutability can still leak mutation.
copy()on data classes is convenient but can weaken domain invariants when state transitions should stay explicit.- Exhaustive
whenover sealed hierarchies improves safety, but only if the hierarchy is truly closed in the relevant module boundary. - Reified generics and extension-heavy DSLs can improve ergonomics while making stack traces and Java interop worse. Use them where the tradeoff is worth it.
Expert Heuristics
- Prefer refactors that make invalid states harder to represent, not only code shorter to read.
- Keep business transitions explicit when the domain has invariants, auditing, or transactional significance.
- If a refactor improves local beauty but obscures logs, traces, or step-by-step debugging, it is probably not worth it.
- In shared modules, treat source compatibility and binary compatibility as separate review questions.
Spring-Aware Safety Rules
- Do not refactor proxy-reliant classes in ways that remove needed openness or change bean boundaries accidentally.
- Do not convert entities into data classes or over-lean value objects without checking persistence support.
- Do not change constructor shapes for DTOs or config classes without checking Jackson and configuration binding.
- Do not move logic into extension functions that cross architecture layers implicitly.
- Do not hide important framework interactions behind clever utility abstractions.
Output Contract
Return these sections:
Refactoring intent: what quality problem is being solved.Safe transformations: the concrete Kotlin improvements that are appropriate here.Framework constraints: the Spring, Jackson, JPA, or config rules that limit the refactor.Minimal patch plan: incremental changes in a safe order.Verification: which tests or runtime checks protect behavior.
Guardrails
- Do not refactor for aesthetics alone when risk is non-trivial.
- Do not introduce advanced Kotlin constructs just to prove idiomatic knowledge.
- Do not compress code until debugability suffers.
- Do not change public contracts without calling that out explicitly.
Quality Bar
A good run of this skill leaves the code more Kotlin-native and still boringly reliable in Spring. A bad run produces elegant Kotlin that is harder to debug, harder to evolve, or incompatible with framework behavior.
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.

