6.2 KiB
6.2 KiB
name, description, allowed-tools
| name | description | allowed-tools |
|---|---|---|
| android-code-review | Comprehensive Android Kotlin code review for Payoo Android app. Checks Kotlin best practices, coroutines, Clean Architecture, MVVM patterns, lifecycle management, dependency injection, memory management, security, and performance. Use when reviewing Kotlin files, pull requests, or ViewModels, Activities, Fragments, UseCases, and Repositories. | Read, Grep, Glob |
Android Code Review
Expert Android code reviewer for Payoo Android application, specializing in Kotlin, Coroutines, Jetpack components, and Clean Architecture patterns.
When to Activate
- "review android code", "check android file", "review android PR"
- Mentions Kotlin/Java files: Activity, Fragment, ViewModel, UseCase, Repository
- "code quality", "best practices", "check android standards"
- Coroutines, Clean Architecture, MVVM patterns, Jetpack components
Review Process
Step 1: Identify Scope
Determine what to review:
- Specific files (e.g., "PaymentViewModel.kt")
- Directories (e.g., "payment module")
- Git changes (recent commits, PR diff)
- Entire module or feature
Step 2: Read and Analyze
Use Read tool to examine files, checking against 7 core categories.
Step 3: Apply Standards
1. Naming Conventions ✅
- Types: PascalCase, descriptive (e.g.,
PaymentViewModel) - Variables: camelCase (e.g.,
paymentAmount,isLoading) - Constants: UPPER_SNAKE_CASE (e.g.,
MAX_RETRY_COUNT) - Booleans: Prefix with
is,has,should,can - No abbreviations except URL, ID, API, HTTP, UI
- Views: Include type suffix (e.g.,
amountEditText,submitButton)
2. Kotlin Best Practices 🎯
- Null Safety: Use
?and!!appropriately, prefer safe calls - Data Classes: Use for DTOs and models
- Sealed Classes: For state management and result types
- Extension Functions: For reusable utilities
- Scope Functions: Use
let,apply,run,also,withcorrectly - Immutability: Prefer
valovervar
3. Coroutines Patterns 🔄
- Scope: Use
viewModelScope,lifecycleScopeappropriately - Dispatchers:
Dispatchers.IOfor network/DB,Dispatchers.Mainfor UI - Cancellation: All coroutines properly cancelled
- Error Handling: Use
try-catchorrunCatchingin coroutines - Flows: Use
StateFlow,SharedFlowfor reactive data - No blocking: Never use
runBlockingin production code
4. Clean Architecture 🏗️
- Flow: ViewModel → UseCase → Repository → DataSource (API/DB)
- ViewModels: Extend
ViewModel, expose UI state viaStateFlow - UseCases: Contain business logic, single responsibility
- Repositories: Abstract data sources
- DI: Dependencies injected (Dagger/Hilt/Koin)
- Layers: Strict separation (Presentation/Domain/Data)
5. Lifecycle Management 🔁
- ViewModels: Don't hold Activity/Fragment references
- Observers: Use
viewLifecycleOwnerin Fragments - Coroutines: Launch in lifecycle-aware scopes
- Resources: Clean up in
onDestroyoronCleared - Configuration Changes: Handle properly
6. Security 🔒
- Sensitive Data: Use EncryptedSharedPreferences
- API Keys: Never hardcode, use BuildConfig
- Network: HTTPS only, certificate pinning if needed
- Logs: No sensitive data in production logs
- Input Validation: Sanitize user inputs
- ProGuard/R8: Proper obfuscation rules
7. Performance ⚡
- Background Work: Network and DB on IO dispatcher
- Memory Leaks: No Activity/Context leaks
- RecyclerView: Use DiffUtil, ViewBinding
- Images: Use Coil/Glide with proper caching
- Database: Room queries optimized with indexes
- Lazy Loading: Load data on demand
Step 4: Generate Report
Provide structured output with:
- Summary: Issue counts by severity (🔴 Critical, 🟠 High, 🟡 Medium, 🟢 Low)
- Issues by category: Organized findings
- Code examples: Current vs. fixed code
- Explanations: Why it matters
- Recommendations: Prioritized actions
Severity Levels
🔴 Critical - Fix immediately
- Memory leaks (Activity/Context references)
- Coroutines not cancelled → Resource leak
- Sensitive data in plain SharedPreferences
- UI updates on background thread → Crash risk
- Hardcoded API keys or secrets
🟠 High Priority - Fix soon
- Missing error handling in coroutines
- Wrong Dispatcher usage
- ViewModel calling repository directly (skip UseCase)
- Business logic in ViewModel/Activity
- No ProGuard rules for critical code
🟡 Medium Priority - Should improve
- Not using lifecycle-aware components
- Poor naming conventions
- Not using data classes for models
- Missing null safety checks
- Inefficient RecyclerView usage
🟢 Low Priority - Nice to have
- Inconsistent code style
- Could use more extension functions
- Documentation improvements
Output Format
# Android Code Review Report
## Summary
- 🔴 Critical: X | 🟠 High: X | 🟡 Medium: X | 🟢 Low: X
- By category: Naming: X, Kotlin: X, Coroutines: X, Architecture: X, etc.
## Critical Issues
### 🔴 [Category] - [Issue Title]
**File**: `path/to/file.kt:line`
**Current**:
```kotlin
// problematic code
Fix:
// corrected code
Why: [Explanation of impact]
Recommendations
- Fix all critical issues immediately
- Address high priority before next release
- Plan medium priority for next sprint
Positive Observations
✅ [Acknowledge well-written code]
## Quick Reference
**Standards**: See `standards.md` in this skill directory for detailed Android coding standards including:
- Kotlin best practices and idioms
- Coroutines patterns and anti-patterns
- Clean Architecture implementation
- Dependency injection patterns
- Security guidelines
- Performance optimization techniques
**Examples**: See `examples.md` for extensive code examples, common issues, and recommended patterns.
## Tips
- **Be thorough**: Check all 7 categories
- **Be specific**: Reference exact line numbers
- **Be constructive**: Explain why, not just what
- **Be practical**: Prioritize by severity
- **Be encouraging**: Acknowledge good code
- **Context matters**: Consider app-specific requirements