AgentLint Verified 94/10070 Kotlin repos analyzed
Kotlin CLAUDE.md & AGENTS.md Template
Coroutines safety, ktlint/detekt gates, and Gradle test filtering from Kotlin repos.
# Kotlin Project — Kotlin Harness Kotlin + Gradle project using structured concurrency, ktlint, detekt, and JUnit 5. ## Commands - Fast unit test: `./gradlew :core:test --tests '*TargetTest'` - Full verification: `./gradlew check` - Static checks: `./gradlew ktlintCheck detekt` ## Rules - Don't use `!!` (not-null assertion) in production code. Instead use safe calls (`?.`), Elvis defaults, or `requireNotNull` with an explicit message. Because `!!` throws opaque NPEs. - Don't launch work on `GlobalScope`. Instead inject a structured `CoroutineScope`. Because unscoped coroutines leak memory and break cancellation. - When updating Compose UI or navigation routes, read `docs/navigation.md`. ## Continuity - Keep `local.properties`, keystores, and `CLAUDE.local.md` gitignored and update `HANDOFF.md`.
Most Adopted Kotlin Rules Across Real Open-Source Repos
Measured across 70 public Kotlin repositories in the 4,533-repo harness study:
gradle-kotlintooling
Gradle with Kotlin DSL
54.0%27 repos
jetpack-composeframework
Jetpack Compose for UI
50.0%25 repos
unit-teststesting
Write unit tests for all changes
48.0%24 repos
data-classpatterns
Use data classes
38.0%19 repos
mvvm-kotlinpatterns
MVVM architecture
36.0%18 repos
ci-cdtooling
CI/CD pipeline must pass
34.0%17 repos
coroutinespatterns
Kotlin coroutines
34.0%17 repos
error-handlingpatterns
Proper error handling with context
32.0%16 repos
Essential Commands (Checks W1 & W7)
- install
- ./gradlew dependencies
- fastTest
- ./gradlew :app:testDebugUnitTest --tests '*TargetTest'
- fullTest
- ./gradlew check
- lint
- ./gradlew ktlintCheck detekt
- build
- ./gradlew assembleDebug
Common Kotlin Agent Pitfalls
- 01Using
GlobalScope.launchleaks coroutines across screen/request lifecycles. - 02Double-bang
!!bypasses Kotlin's entire null-safety model.