一键导入
code-quality-audit
Systematic code review after feature development - structure, hygiene, separation of concerns, and performance
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Systematic code review after feature development - structure, hygiene, separation of concerns, and performance
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Guidance for creating effective modular skills for Claude. Use when creating or refining skills to ensure they are concise, follow progressive disclosure patterns, and provide appropriate degrees of freedom.
Guidelines for ensuring smooth and race-condition-free theme transitions in Android, specifically regarding icon tinting and state management.
Best practices for effective human-AI pair programming and communication
Clarify touch-target vs visual size when users ask to resize buttons without changing icons.
Choose whether the outer container acts as the touch proxy or remains a layout placeholder to control hit targets.
Best practices for 60fps custom View rendering with zero allocation in onDraw
| name | Code Quality Audit |
| description | Systematic code review after feature development - structure, hygiene, separation of concerns, and performance |
Last Verified: 2026-01-23 Applicable SDK: Android 14+ (API 34+) Dependencies: best-practice-check, codebase-aware-implementation
After completing a development phase, perform a comprehensive code quality audit focusing on production code (excluding test files). This skill provides a systematic approach to identify technical debt, architectural issues, and potential bugs before they become problems.
Objective: Ensure logical, maintainable project organization
Check Points:
feature, ui, data, domain, etc.)Commands to Run:
# List all Kotlin/Java files with their packages
find ./app/src/main -type f \( -name "*.kt" -o -name "*.java" \) -exec head -1 {} \; -print
# Find files that might be misplaced (e.g., Activities not in ui package)
grep_search for class definitions and check package declarations
Review Questions:
Objective: Remove clutter and ensure code quality standards
Check Points:
strings.xml)colors.xml or theme)dimens.xml).tmp, backup files)Commands to Run:
# Find hardcoded strings in Kotlin files
grep_search for string literals in .kt files (exclude test files)
# Find TODO/FIXME comments
grep_search for "TODO" and "FIXME" in source files
# Find commented code blocks
grep_search for "//.*fun " or "//.*val " patterns
# Find debug logs
grep_search for "Log.d", "Log.v", "println" in source files
# Check for unused resources (use Android Lint)
./gradlew lint
Review Questions:
button_height not size_48dp)?Objective: Ensure proper layering and responsibility distribution
Check Points:
Commands to Run:
# Find Activities/Fragments with potential business logic
view_file_outline for each Activity/Fragment and check method complexity
# Find ViewModels holding Context
grep_search for "Context" in ViewModel files
# Find large classes (potential God classes)
# Check line counts and method counts per class
Review Questions:
Red Flags:
Context in non-UI classesObjective: Identify memory leaks and performance bottlenecks
Check Points:
use {})lazy for expensive initializationsonDraw() has zero allocationsCommands to Run:
# Find static Context references
grep_search for "companion object.*Context" or "static.*Context"
# Find Handler usage without WeakReference
grep_search for "Handler(" in source files
# Find potential main thread blocking
grep_search for "Thread.sleep", ".get()" on futures, blocking IO
# Find unclosed resources
grep_search for "FileInputStream", "Cursor", "InputStream" without ".use"
# Find allocations in onDraw
view_code_item for custom Views and check onDraw methods
Review Questions:
Critical Patterns to Check:
// ❌ BAD: Context leak
companion object {
lateinit var context: Context
}
// ✅ GOOD: Application context if needed
companion object {
lateinit var appContext: Application
}
// ❌ BAD: Listener not unregistered
class MyFragment : Fragment() {
override fun onViewCreated(...) {
someManager.addListener(this)
}
}
// ✅ GOOD: Proper cleanup
class MyFragment : Fragment() {
override fun onViewCreated(...) {
someManager.addListener(this)
}
override fun onDestroyView() {
someManager.removeListener(this)
super.onDestroyView()
}
}
// ❌ BAD: Allocation in onDraw
override fun onDraw(canvas: Canvas) {
val paint = Paint() // Creates new object every frame!
canvas.drawCircle(x, y, radius, paint)
}
// ✅ GOOD: Reuse objects
private val paint = Paint()
override fun onDraw(canvas: Canvas) {
canvas.drawCircle(x, y, radius, paint)
}
./gradlew clean build./gradlew lint and review the reportRun these commands and collect output:
# Find all production source files
find ./app/src/main -type f -name "*.kt" | grep -v Test
# Check for common issues
grep -r "TODO" app/src/main --include="*.kt"
grep -r "FIXME" app/src/main --include="*.kt"
grep -r "Log\.[dv]" app/src/main --include="*.kt"
grep -r "println" app/src/main --include="*.kt"
# Find large files (potential refactoring candidates)
find ./app/src/main -name "*.kt" -exec wc -l {} \; | sort -rn | head -20
# Check for unused resources (requires Android Studio or gradlew)
./gradlew lint
For each dimension (1-4 above):
view_file_outline to understand class structureview_code_item to examine specific methodsgrep_search to find patternsCreate a markdown report with:
# Code Quality Audit Report
**Date**: [Current Date]
**Commit**: [Git commit hash]
**Auditor**: [Your name or "AI Assistant"]
## Executive Summary
[Brief overview of findings]
## 1. File Structure & Organization
### Issues Found
- [ ] **[Severity]** `path/to/File.kt` - [Description]
- **Line**: [Line number if applicable]
- **Suggestion**: [How to fix]
## 2. Code Hygiene
### Issues Found
- [ ] **[Severity]** `path/to/File.kt:123` - [Description]
- **Suggestion**: [How to fix]
## 3. Separation of Concerns
### Issues Found
- [ ] **[Severity]** `path/to/File.kt:45-67` - [Description]
- **Suggestion**: [How to fix]
## 4. Performance & Memory
### Critical Issues
- [ ] **HIGH** `path/to/File.kt:89` - [Memory leak description]
- **Risk**: [Explain the risk]
- **Fix**: [How to fix]
### Performance Issues
- [ ] **MEDIUM** `path/to/File.kt:123` - [Performance issue]
- **Impact**: [Explain impact]
- **Fix**: [How to fix]
## Recommendations
1. [Priority 1 recommendation]
2. [Priority 2 recommendation]
...
## Metrics
- Total files reviewed: X
- Issues found: Y
- Critical issues: Z
- Estimated effort: [hours/days]
Categorize findings by severity:
For each issue found, provide:
Example:
❌ **HIGH** - Performance & Memory
📁 `app/src/main/java/com/example/ui/MainActivity.kt:45-52`
🔍 **Issue**: Coroutine launched with GlobalScope instead of lifecycleScope
💥 **Impact**: Potential memory leak - coroutine continues after Activity destroyed
✅ **Fix**: Replace `GlobalScope.launch` with `lifecycleScope.launch`
// Before
GlobalScope.launch {
repository.loadData()
}
// After
lifecycleScope.launch {
repository.loadData()
}
*Test.kt, androidTest/, test/./gradlew lint
# Review: app/build/reports/lint-results.html
./gradlew detekt
view_file_outline: Get class structure overviewview_code_item: Examine specific methodsgrep_search: Find patterns across codebasefind_by_name: Locate files by name/patternonDraw(), onMeasure()Do NOT audit:
*Test.kt, androidTest/, test/)build/, .gradle/)libs/)A successful audit should:
After audit completion: