📖 About Kotlin
Kotlin is a modern, statically typed programming language that runs on the JVM and is fully interoperable with Java. It's the preferred language for Android development and brings many modern language features to the JVM ecosystem.
🎯 Best For
- Android mobile development
- Backend services with Ktor/Spring
- Multiplatform mobile (KMM)
- Server-side applications
- Gradle build scripts
🔧 Key Features
- Null safety built into the type system
- Coroutines for asynchronous programming
- Data classes for value objects
- Extension functions
- Sealed classes for restricted hierarchies
- Smart casts and type inference
🛠️ Development Tools
Build
gradle build
Test
gradle test
Coverage
gradle jacocoTestReport
Run
gradle run
📄 Package Contents (7 files)
AGENTS_RULES.md
Complete AI agent rules (universal)
- KOTLIN-specific best practices
- TDD workflow (Red-Green-Refactor)
- DDD principles and patterns
- Git workflow and commit format
- Code quality principles
.cursorrules
Quick reference for Cursor IDE
- Essential rules summary
- Links to full documentation
- Optimized for quick loading
.gitignore
Git exclusions
- KOTLIN-specific patterns
- Build artifacts
- IDE configuration files
- Dependency directories
AGENTS.md
Quick reference guide
- Common patterns
- Best practices summary
- Quick troubleshooting
README.md
Project template with examples
- Setup instructions
- Sample code and structure
- Testing examples
- Build and run commands
CODE_QUALITY_PRINCIPLES.md
Quality principles and best practices
- Avoid default values (fail-fast)
- Consistency across code paths
- Extract reusable functions
- KOTLIN-specific examples
CONTRIBUTING.md
Contribution guidelines
- TDD workflow (Red-Green-Refactor)
- Git commit format
- Code review process
- Testing requirements (90% coverage)
💻 Code Examples
Data Classes
data class User(
val name: String,
val email: String,
val age: Int
)
val user = User("John", "john@example.com", 30)
val updated = user.copy(age = 31)
Null Safety
fun findUser(email: String): User? {
return users.find { it.email == email }
}
val name = findUser("test@example.com")?.name ?: "Unknown"
Coroutines
suspend fun fetchUser(id: String): User {
return withContext(Dispatchers.IO) {
api.getUser(id)
}
}
viewModelScope.launch {
val user = fetchUser("123")
updateUI(user)
}