.claude/skills/gradle-build-performance/SKILL.md
Optimize Gradle build speed with Configuration Cache, parallel execution, and AGP 9 tuning
npx skillsauth add ChooJeongHo/MovieFinder gradle-build-performanceInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Analyze and optimize build performance for $ARGUMENTS (or run a full audit if no argument given).
# Check current status
./gradlew assembleDebug --configuration-cache
# Enable permanently in gradle.properties
org.gradle.configuration-cache=true
org.gradle.configuration-cache.problems=warn # start with warn, move to fail later
Benefit: Skips configuration phase on subsequent builds (30-60% faster incremental builds). Gotcha: Some plugins don't support it yet — check output for incompatibilities.
# gradle.properties
org.gradle.parallel=true
org.gradle.workers.max=4 # adjust to CPU core count - 1
# gradle.properties
org.gradle.daemon=true
org.gradle.jvmargs=-Xmx4g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.caching=true
# Already required for this project — verify present
android.disallowKotlinSourceSets=false
android.enableR8.fullMode=true
# AGP 9 non-transitive R classes (faster builds, less R class bloat)
android.nonTransitiveRClass=true
# Disable unused features
android.defaults.buildfeatures.buildconfig=false # only enable per-module if needed
android.defaults.buildfeatures.aidl=false
android.defaults.buildfeatures.renderscript=false
This project uses KSP (already). Verify no KAPT stragglers:
# Should return nothing
grep -r "kapt" app/build.gradle.kts
KSP is ~2x faster than KAPT. Never mix both for the same processor.
# Generate build scan (detailed task timeline)
./gradlew assembleDebug --scan
# Or local profile report
./gradlew assembleDebug --profile
# Report: build/reports/profile/
# Check which tasks are slowest
./gradlew assembleDebug --info 2>&1 | grep "Task.*took"
| Slow Task | Cause | Fix |
|-----------|-------|-----|
| kspDebugKotlin | Large annotation processing | Split into modules (future) |
| testDebugUnitTest | All tests always re-run | --tests filter for local dev |
| detekt | Full source scan | Run only on changed files (CI) |
| jacocoTestReport | Instrument + report | Run only on CI, not local |
| lint | Full lint pass | ./gradlew lintDebug only when needed |
| packageDebug | Large assets | Check for accidentally committed large files |
# Run twice — second should be UP-TO-DATE for most tasks
./gradlew assembleDebug
./gradlew assembleDebug
# If tasks re-run on second build, they're not incremental
# Common culprit: task reads System.currentTimeMillis() or non-deterministic input
If build time exceeds 3 min, consider splitting:
:core (pure Kotlin — fastest to compile)
:data (Room, Retrofit)
:domain (pure Kotlin UseCases)
:app (presentation only)
Benefit: only changed modules recompile. Currently single-module is fine for this project size.
# Run only on app module source, not test sources
./gradlew :app:detekt
# Already configured in this project — verify source.setFrom() in build.gradle.kts
Current hook runs full testDebugUnitTest. If it's too slow:
# Option: run only affected module tests
./gradlew :app:testDebugUnitTest --daemon --quiet
# Option: parallel test execution (already default in AGP 9)
# Verify in build.gradle.kts:
testOptions {
unitTests.isParallelized = true // add if not present
}
## Build Performance Audit
### Current Baseline
- Clean build: Xs
- Incremental build: Xs
- Test only: Xs
### Configuration Cache Status
[Enabled/Disabled + any incompatible plugins]
### gradle.properties Gaps
[Missing optimizations vs recommended settings]
### Top 5 Slowest Tasks
[Task name → time → fix recommendation]
### Quick Win Priority
1. [Highest impact, lowest effort]
2. ...
### Estimated Improvement
[X% faster incremental builds after applying recommendations]
testing
Write and fix Unit, Hilt integration, and Espresso tests following MovieFinder patterns
development
Systematically diagnose and fix bugs using evidence-driven root cause analysis
tools
Diagnose and fix Kotlin coroutine race conditions, Flow issues, and thread safety bugs
development
Enforce Clean Architecture and Offline-first patterns in this MovieFinder codebase