Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Cursor rules for Kotlin Springboot Best Practices.
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 34% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 133% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 64% | 0% |
| case-16 | ✗→✓ | ▲ Improved | 84% | 0% |
| case-21 | ✗→✓ | ▲ Improved | 80% | 0% |
Cursor rules for Kotlin Springboot Best Practices.
Synced from https://github.com/PatrickJS/awesome-cursorrules/tree/main/rules/kotlin-springboot-best-practices-cursorrules-prompt-file.mdc.
val by default, and only use var when mutation is necessary to promote safer, more predictable code.kotlin val maxConnections = 10 // immutable reference var currentUsers = 0 // mutable, try to avoid if possible
equals() and copy() without writing boilerplate code.kotlin // Kotlin – use default parameters fun createConnection(host: String, secure: Boolean = true) { … }
createConnection("example.com") // uses default secure=true createConnection(host = "test.com", secure = false) // named arg for clarity
when expressions instead of long if-else chains to write cleaner, more readable conditional logic that clearly handles each case.kotlin fun String.capitalizeFirst(): String = replaceFirstChar { it.uppercaseChar() }
println("kotlin".capitalizeFirst()) // prints "Kotlin"
apply, let, also, run, and with to reduce repetition and clearly express object configuration or null-safe operations.?.) and the Elvis operator (?:) to avoid runtime crashes.!!) and instead provide fallback values or explicit null checks to write safer and more predictable code.String or String? to avoid spreading nullability uncertainty in your Kotlin code.filter, map, and forEach instead of manual loops to write concise and expressive data transformation logic.kotlin // Imperative approach val activeUsers = mutableListOf<User>() for (user in users) { if (user.isActive) activeUsers.add(user) }
// Idiomatic functional approach val activeUsers = users.filter { it.isActive }
kotlin fun toDto(entity: User) = UserDto(name = entity.name, email = entity.email)
$var or ${expression}) instead of concatenation, and use triple-quoted strings for clean multi-line text.val to keep them immutable and to align with Spring and Kotlin idioms.kotlin @Service class OrderService( private val orderRepo: OrderRepository, private val notifier: Notifier ) { // ... }
final by default, and let Spring’s 'all-open' plugin handle proxy generation so you don’t need to manually add the open modifier.object declaration for true singletons or stateless utility holders instead of static methods or Java-style singletons.when expressions.kotlin sealed class Result<out T> data class Success<T>(val data: T): Result<T>() data class Error(val exception: Throwable): Result<Nothing>()
use the use function to safely manage and close resources like streams and file handles, ensuring they are closed even if an exception occurs.kotlin FileInputStream("data.txt").use { stream -> // read from stream } // stream is automatically closed here
private or internal where possible, and only expose what’s truly necessary as public.launch or async to write clean, asynchronous backend code without callback hell.lazy, observable, infix, and operator overloading to write concise, expressive, and idiomatic code.val fields and Kotlin’s JPA plugin to satisfy JPA requirements while keeping your models safe and thread-friendly.Other measured skills in the registry, with their headline benchmark lift.