android-kotlin-api-design-reviewer
Kotlin API Design Review
Naming Rules
- Clear at point of use
- Omit needless words
lowerCamelCase: properties, functions, variablesUpperCamelCase: classes, interfaces, objectsUPPER_SNAKE_CASE: constants- Booleans:
is,has,can,shouldprefix - Collections: plural names (
users, notuserList)
Compose-specific Naming
- Composable functions returning
Unit: use PascalCase nouns (e.g.,UserProfileCard, notuserProfile) - Avoid spaces and backticked identifiers in function names, especially in public APIs (discouraged by Kotlin conventions)
Common Issues
| Issue | Fix |
|---|---|
var visible |
var isVisible |
fun getData() |
fun getUserName() |
var nameString |
var name |
userList |
users |
| Composable named like regular function | Rename to PascalCase noun (ProfileScreen) |
| Implicit return type in library | Add explicit : String |
Function Design
- Named parameters for clarity beyond first param
- Default parameters at end
- Suspend functions for async operations
- Extension functions for utility methods
- Operator overloading when semantically appropriate
- Prefer properties over parameterless functions when the operation is cheap and non-throwing
- Use named arguments + trailing commas for multi-parameter calls in public APIs
Return Types
- Nullable when null is meaningful
- Result for failable operations
- Flow for streams
- sealed class for finite states
- Explicitly declare return types in public library APIs (even if inferable)
Data Classes
- Use for data transfer objects
- Immutable by default (val over var)
- Copy function for updates
- Destructuring support
Public API / Library
- Provide KDoc for all public members
- Use
@JvmNamefor interop-friendly naming - Use backing properties (
_internalValue) for observed state - Consider type aliases for repeated complex function types
Severity
- 🔴 Critical: Violates conventions
- 🟡 Improvement: Could be clearer
- 🟢 Enhancement: Optional polish
More from desquared/agents-rules-skills
shared-bug-investigation
Scientific method expert for systematic bug investigation and root cause analysis. Use when users report bugs, crashes, unexpected behavior, or debugging requests. Applies hypothesis-driven investigation, controlled experiments, and rigorous validation across any programming language or platform.
23android-performance-profiler
Identifies potential performance bottlenecks in Jetpack Compose code including expensive recompositions, unnecessary redraws, and memory issues. Use when code involves lists, animations, complex UI, or when the user asks about performance optimization.
19ios-swiftui-architecture-review
Analyze SwiftUI view hierarchies and suggest MVVM or other architectural improvements. Use when **reviewing existing SwiftUI code**, creating new SwiftUI components, analyzing view structure, or when the user asks about SwiftUI architecture patterns. Best for code review and refactoring guidance.
13android-compose-architecture-review
Analyze Jetpack Compose UI hierarchies and suggest MVVM/MVI or other architectural improvements. Use when reviewing existing Compose code, creating new Compose components, analyzing composable structure, or when the user asks about Compose architecture patterns. Best for code review and refactoring guidance.
13android-accessibility-validator
Checks and suggests accessibility improvements for Jetpack Compose and Android Views including TalkBack labels, dynamic text support, and color contrast. Use when creating or modifying UI components, screens, or when the user asks about accessibility.
12flutter-performance-optimizer
Use when Flutter UI has jank, slow scrolling, excessive rebuilds, or memory leaks. Also use when optimizing lists, animations, or complex widget trees, or when the user asks about Flutter rendering performance.
10