🤖

Cline Rules for Kotlin + Android

Native Android development with Kotlin and Jetpack Compose

KotlinAndroidComposeJetpack
.clinerules
# Role
You are an expert Kotlin developer building Android apps with Jetpack Compose.

# Tech Stack
- Kotlin 2.0+
- Jetpack Compose
- Room
- Hilt
- Ktor/Retrofit

# Code Conventions
- Use Jetpack Compose for all UI — no XML layouts.
- Follow MVVM architecture with ViewModel and StateFlow.
- Use Hilt for dependency injection.
- Use Room for local database with Flow/StateFlow.
- Use Kotlin coroutines for async operations.
- Use Navigation Compose for screen navigation.
- Use Material 3 design components.
- Write UI previews with `@Preview` annotation.

# Code Style Preferences
- Use TypeScript strict mode. Define types for all variables, parameters, and return values.
- Never use the `any` type. Use `unknown` if the type is truly uncertain, then narrow it.
- Use `const` by default. Only use `let` when reassignment is needed. Never use `var`.
- Always handle errors explicitly. Use try/catch for async operations. Never silently swallow errors.
- Use early returns (guard clauses) to reduce nesting and improve readability.
- Use descriptive, meaningful names for variables, functions, and classes. Avoid abbreviations.
- Keep functions small and focused. Each function should do one thing. Aim for under 50 lines.

# What to Avoid
- Do not use XML layouts — use Compose.
- Do not use LiveData — prefer StateFlow.
- Do not block the main thread.
- Do not use `!!` operator — handle nullability properly.

About Cline Rules for Kotlin + Android

The .clinerules file helps Cline understand your Kotlin + Android project's conventions, tech stack, and coding standards. This ensures the AI generates code that matches your team's style and follows best practices for Android.

This preset includes rules for:

  • Use Jetpack Compose for all UI — no XML layouts.
  • Follow MVVM architecture with ViewModel and StateFlow.
  • Use Hilt for dependency injection.
  • Use Room for local database with Flow/StateFlow.
  • Use Kotlin coroutines for async operations.

How to use this file

  1. Click Copy or Download above.
  2. Place the .clinerules file in your project's root directory.
  3. Cline will automatically detect and apply these rules.

Get Kotlin + Android Rules for Other IDEs

Other Cline Presets