CtrlK
BlogDocsLog inGet started
Tessl Logo

jbaruch/kotlin-tutor

Teaches AI agents to write idiomatic Kotlin instead of Java-in-a-.kt-file.

98

1.20x
Quality

98%

Does it follow best practices?

Impact

99%

1.20x

Average score across 8 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

use-data-class.mdrules/

alwaysApply:
Yes

Use Data Class

Value Types Are data class

  • Records, DTOs, request/response objects, domain values — these are data class
  • A regular class with manually-written equals, hashCode, and toString is a data class that hasn't realised it yet
  • The compiler-generated implementations are correct, fast, and impossible to forget to update when you add a field

Never Hand-Roll equals / hashCode / toString

  • If you find yourself overriding all three, the class is a data class — convert it
  • Hand-rolled equality silently desyncs when a field is added later and the override isn't updated. This is one of the most common Kotlin bug factories in code ported from Java
  • The only legitimate reason to override these on a data class is to mask a sensitive field in toString — in which case override only toString, not all three

copy() Is the Mutation Pattern

  • Update a data class instance via instance.copy(field = newValue) — preserves all other fields, gives you a new immutable instance
  • This composes with val (the previous rule) — together they make immutable update painless
  • Destructuring (val (id, name) = user) and componentN() come for free; lean on them when iterating collections of value objects

README.md

tile.json