android-perceived-performance
Skill0 starsChanged 3 months agoMITView on GitHub
Measures UX-relevant Android performance (app-startup time, frame jank, loading-state correctness) on a physical device and remediates the findings, grounded in spec/android/perceived-performance/. Invoke when the user asks to measure startup time, fix jank or dropped frames, profile app launch, add or repair Baseline Profiles, diagnose a slow or stuttering screen, or optimize perceived performance. Also handles equivalent German-language requests. Runs a MEASURE phase (Macrobenchmark TTID/TTFD, FrameTimingMetric, Perfetto traces read trace-first, dumpsys gfxinfo as a local check) then an interactive FIX phase (Baseline Profiles, deferred init, work off the main thread, corrected loading-state UI) with re-measurement. Don't use for build failures or crashes (android-debugging), for authoring a list or screen (android-compose-ui), or for functional-test authoring. Supports resume on re-invocation per spec/claude/resumable-work/.
In this repository12 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- android-barcode-scanner-scaffoldSkill
- android-compose-uiSkill
- android-debuggingSkill
- android-feature-implementSkill
- android-localization-applySkill
- android-notification-deriveSkill
- android-permissions-deriveSkill
- android-project-scaffoldSkill
- android-test-suite-applySkill
- android-toolchain-upgradeSkill
- android-uvc-microscope-scaffoldSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 2 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 69
Read references/measurement.md when you enter this phase — it holds the exact Macrobenchmark, dumpsys gfxinfo, and Perfetto command recipes.
- Very specific: line 82
Run cold, warm, and hot and report each separately.
- Distinctive: line 100
Write the measured numbers and their pass/fail verdicts to the resume state (see Resume below).
- Very specific: line 101
When the operator wants a regression gate, write the committed baseline record in the format references/measurement.md §"Baseline record" …
- Very specific: line 106
Read references/remediations.md when a finding needs a fix — it maps each finding class to its concrete remediation.
- Distinctive: line 115
Ask the operator to approve this remediation.
- Very specific: line 120
Run ./gradlew build. If it fails, stop and report the red state (REQ-7).
- Very specific: line 139
Write checkpoints to .resume/android-perceived-performance/<run-id>.yml (never elsewhere).
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Android Perceived Performance
Measure UX-relevant performance on a physical device, then remediate the findings and re-measure. Two phases, in order: MEASURE produces numbers against fixed budgets; FIX applies remediations one at a time, each behind an operator approval gate, and re-measures to prove the change moved the number.
CLI-first: terminal, Gradle, and ADB are sufficient — Android Studio is never required (REQ-3). Device measurement runs over ADB per spec/android/adb-workflows/.
Why this is a skill, not an agent
- Interactivity (decisive): the FIX phase asks the operator to approve each remediation before editing code (REQ-8 forbids unconfirmed overwrites); a fire-and-forget agent has no stable way to surface that mid-flow gate.
- Change scope + lifecycle (decisive): the run persists across the conversation — measure, edit, rebuild, re-measure, iterate — with edits flowing back into the main context, which is the skill bias.
- Orchestrator role: the measurement sweep is the kind of step that would be dispatched to a sub-agent for context-window protection, and the orchestrator that fans out is always a skill (
spec/claude/skill-vs-agent/§Hybrid pattern). No such measurement agent exists in this plugin today; this skill declares noallowed-toolsrestriction (consistent with its siblings), so a run may use web research where currency matters — Macrobenchmark/AGP/profile-plugin versions in particular — per REQ-5. - Counter-dimension (outweighed): the MEASURE step performs heavy device reads and trace parsing, which biases toward an isolated agent for context protection — but that step is the isolatable one, while the interactive FIX loop keeps the whole capability a skill.
Operating principle: the spec owns the methodology
spec/android/perceived-performance/ is the authoritative source for this capability and this skill operationalizes it without restating or contradicting it. It fixes what is measured (§A), the conditions under which a number counts at all (§B), the budgets that turn a number into a finding (§C), the startup and jank methodology (§D/§E), Baseline Profiles (§F), the benchmark module and result handling (§G), and the remediation order (§H).
Neighbouring ownership still holds and is referenced, never duplicated: spec/android/long-list-scrolling/ §G owns list-scroll measurement and its deliberate refusal to fix a scroll pass/fail percentile; spec/android/test-automation/ §F owns the lane split; spec/android/adb-workflows/ §D/§E owns Perfetto and device mechanics; the wait-indication matrix and response-time thresholds live in spec/android/ui-components/ §A and spec/android/app-design-navigation/ §F; the release-build configuration a measurement runs against is spec/android/release-readiness/ §A.
On any conflict the spec wins. When a run needs a decision no spec covers, report the gap and propose a spec extension rather than deciding silently (REQ-6, REQ-17).
Operations
Two operations, run in order or singly — say which is running:
measure— Phase 1 below: measurement infrastructure, run conditions and pre-flight, startup, jank, loading-state audit, baseline checkpoint. Writes no app code (a missing benchmark module orprofileableflag is scaffolded only after the operator confirms, and is reported as infrastructure, not as a remediation).fix— Phase 2 below: one remediation at a time behind an approval gate, rebuild, re-measure. Refuses to start without a checkpointed baseline frommeasure(or a committed baseline record with its §A conditions).
Hard rules
- Measure on a physical device for startup and jank; benchmarks run in a separate scheduled lane and MUST NOT be added to the per-commit CI suite (
spec/android/test-automation/§F). An emulator is acceptable only for coarse loading-state UI checks, never for the reported startup/jank numbers. - Never edit code without operator approval for that specific remediation (REQ-8). One remediation, one gate, one re-measurement.
- Never leave the project red without reporting it: after every FIX iteration run
./gradlew build(REQ-1); if it fails, stop and report — do not stack further edits (REQ-7). - Never scaffold outdated mechanisms (kapt, monolithic buildSrc, Groovy DSL) into a benchmark module; use KSP and the Kotlin DSL (REQ-9).
- Classify every number against
references/thresholds.md— a raw millisecond value is not a finding until it is compared to its budget. - One change at a time. Batching remediations destroys attribution: you cannot tell which edit moved which number.
- Trace before remedy. For startup and jank alike, read the Perfetto trace and name the cause before proposing anything — a remedy without a trace is a guess (spec §D/§E).
- Never commit traces or raw benchmark output (
*.perfetto-trace,build/outputs/connected_android_test_additional_output/, benchmark JSON). What may be committed is the small baseline record described inreferences/measurement.md§"Baseline record", carrying the numbers and their §A conditions.
Phase 1 — MEASURE
Read references/measurement.md when you enter this phase — it holds the exact Macrobenchmark, dumpsys gfxinfo, and Perfetto command recipes. Read references/thresholds.md when you need the budget to classify a number as pass or fail.
1. Establish the device, target, and measurement infrastructure
- Confirm exactly one
platform-toolsadb (which -a adb) and target the device explicitly (-s <serial>orANDROID_SERIAL) perspec/android/adb-workflows/§A. - Measurement infrastructure (spec §B/§G, MUST): target app declared
profileable; benchmarks in a separatecom.android.testmodule; a dedicatedbenchmarkbuild type derived fromrelease(initWith(release), non-debuggable, minified,matchingFallbacks += listOf("release")for multi-module resolution). Gradle shape:references/measurement.md§"Benchmark module setup". Where any is missing, propose scaffolding it (Kotlin DSL, KSP — REQ-9) and get confirmation before writing (REQ-8); it is infrastructure, not a remediation. - Build and install the
benchmarkvariant (non-debuggable, release-shaped) for measurement — a debuggable build distorts startup and frame timings. - Pre-flight the confounders (spec §B): animations disabled (
settings put global window_animation_scale 0.0and the two siblings,spec/android/adb-workflows/§E); device not thermally throttled (dumpsys thermalservicestatus 0/none, and let a hot device cool); screen on and unlocked; no unrelated foreground work (close other apps, no sync or download in progress, charger state consistent across compared runs). Record the pre-flight result with the conditions. - Capture the run conditions now, before any measurement: device model, Android version, build type, minification state,
CompilationMode, refresh rate, iteration count (references/measurement.md§"Device preconditions" has thegetprop/dumpsys displaycalls).spec/android/perceived-performance/§A makes a number without them unreportable, and they go into the resume state so a resumed run does not have to re-measure to restate them.
2. Measure startup (TTID/TTFD)
- Produce the reported number with a Macrobenchmark
StartupTimingMetricrun;am start -Wand theActivityManager: Displayedlogcat line are a quick local check only, measure TTID alone, and perspec/android/perceived-performance/§D MUST NOT be the basis of a reported finding. Report TTFD from the app'sreportFullyDrawn()/ReportDrawn*instrumentation (the local check for it is theActivityManager: Fully drawn <pkg>/<activity>: +NNNmslogcat line, which only appears when the app reports it), and report its absence as the finding when there is none. - Run cold, warm, and hot and report each separately; cold is the primary case. See
references/measurement.md. - Trace first (spec §D, MUST): when startup misses its budget, capture a Perfetto trace of a cold start (
spec/android/adb-workflows/§D invocation) and read it against the startup phases before proposing any remedy. Check the four documented cost centres, in this order, and name which one(s) the trace shows: (1) work inApplication.onCreate()and in eagerly-initialized content providers, (2) heavy activity / first-screen initialization, (3) blocking I/O or bitmap decoding on the main thread, (4) a custom splash-screen activity where the platformSplashScreenAPI belongs. Only then openreferences/remediations.md.
3. Measure jank
- Produce the reported number with a Macrobenchmark
FrameTimingMetricrun and readframeOverrunMsat P50/P90/P95/P99 againstreferences/thresholds.md.dumpsys gfxinfois a coarse local check and, perspec/android/perceived-performance/§E, MUST NOT carry a jank finding for a Compose surface on its own — the vendor documentation scopes it to View-toolkit apps. - For a scrolling list, follow
spec/android/long-list-scrolling/§G rather than this skill's general recipe: measure withFrameTimingMetricover a scroll journey, readframeOverrunMsas the primary number, report the P95/P99 tail (a healthy P50 proves nothing), and always state the refresh-rate deadline the budget is set against. A jank claim from a debug build is not a finding. - Capture a Perfetto trace with the
record_android_traceinvocationspec/android/adb-workflows/§D owns, for any stutter the frame metric flags, and read it to locate the offending work on the main thread (spec/android/perceived-performance/§E). - Assign every jank finding to exactly one cause family (spec §E, MUST) — the report may not say "the screen is slow": (a) main-thread work (I/O, binder calls, lock contention, allocation/GC pressure), (b) render-thread work (oversized bitmap uploads, expensive paths), (c) layout and recomposition cost, (d) image or data work that belongs off the main thread. The family comes from the trace, not from the symptom, and it selects the remediation entry.
- Classify each frame with the spec's vocabulary: janky = over the display deadline; slow = 16–700 ms; frozen = over 700 ms (always a defect).
4. Audit loading-state correctness
- Against
references/thresholds.md, verify the response-time feedback semantics and the wait-indication matrix: instant feedback on tap, no indicator below ~200 ms, a loading indicator for short indeterminate waits (200 ms–5 s), a progress indicator — determinate as soon as progress is known — beyond ~5 s (spec/android/ui-components/§A), a cancel affordance beyond ~10 s (spec/android/app-design-navigation/§F), one indicator per group, and no in-place loading→determinate hand-off. The two thresholds are distinct obligations; do not fold them into "5–10 s". - The absolute TTFD number is also judged here: it is bounded by the wait indication the loading state owes the user (spec §C).
5. Checkpoint the baseline
- Write the measured numbers and their pass/fail verdicts to the resume state (see Resume below). This baseline is what every FIX iteration is compared against.
- When the operator wants a regression gate, write the committed baseline record in the format
references/measurement.md§"Baseline record" fixes — numbers plus every §A condition; the file format is free, the condition fields are not (spec §G). Traces and raw output stay out of the repository. - State in the report which numbers are new, which are compared against a baseline, and which had no baseline (spec §G).
Phase 2 — FIX
Read references/remediations.md when a finding needs a fix — it maps each finding class to its concrete remediation. Apply them in the user-impact order spec/android/perceived-performance/ §H fixes, not by signal strength.
1. Propose one remediation
- Pick the next finding in the user-impact order
spec/android/perceived-performance/§H fixes — ANRs and frozen frames, then startup, then slow frames, then the rest — and within a category the largest budget gap. State the remediation, the files it will touch, the trace evidence (cost centre or cause family) it rests on, and the expected effect on the number. Common remediations: removing the traced cost centre (deferred/lazy startup work, work off the main thread, platformSplashScreeninstead of a splash activity), Baseline Profiles (+ Startup Profiles), and correcting the loading-state UI to the wait-indication matrix. - Baseline Profile content (spec §F): the
BaselineProfileRulejourney covers startup, the main navigation paths, and the app's main list scroll;androidx.profileinstalleris present and current; the profile is verified against the minified release build only; it is regenerated whenever the covered journeys change materially; and no post-R8 DEX-modifying tooling is introduced (it invalidates the profile and the DEX layout —spec/android/release-readiness/§A). A profile is required for any app whose startup or scroll is measured — its absence is itself a finding.
2. Get approval, then edit
- Ask the operator to approve this remediation. On approval, apply the edit; on decline, record the decision and move to the next finding. Never overwrite existing code or config without this approval (REQ-8).
- Checkpoint the decision immediately (see Resume).
3. Rebuild and re-measure
- Run
./gradlew build. If it fails, stop and report the red state (REQ-7); do not proceed. - Re-run only the measurement that this remediation targeted (step 2/3/4 of MEASURE) and compare against the baseline. Record the delta.
4. Iterate or conclude
- Repeat from FIX step 1 for the next finding until every number is within budget or the remaining findings need a spec decision (then report the gap per the operating principle).
Report
Conclude with: the baseline table (number, budget, verdict, new/compared/no-baseline), the remediations applied with their before/after deltas (including the ones that did not move their number), the final ./gradlew build status, any red state left behind, and any spec/android/perceived-performance/ gap surfaced during the run.
Every number in that table carries the conditions spec/android/perceived-performance/ §A requires — device model, Android version, build type, minification state, CompilationMode, refresh rate, iteration count — plus the pre-flight result, and every verdict drawn against a §C portfolio decision says so, so the operator can tell a corpus target from a platform requirement. A number without its conditions is not reportable. Every jank finding names its cause family; every startup finding names the cost centre the trace showed.
Field measurement (spec §I). Recommend JankStats (androidx.metrics:metrics-performance) as a SHOULD where no field frame telemetry exists; where telemetry exists or is added, personal data MUST stay out of performance events entirely (no identifiers, content, free text, or precise location) — flag any violation as a finding.
Resume
This skill is resumable: true (multi-phase with per-remediation approval gates), per spec/claude/resumable-work/.
- Write checkpoints to
.resume/android-perceived-performance/<run-id>.yml(never elsewhere). Checkpoint after the baseline is captured and after every approval gate, appending each approval todecisions:(never rewriting earlier entries). - Resume detection on re-invocation: scan
.resume/android-perceived-performance/*.ymlforstatus: in_progressmatching the current inputs (target package + variant). When one matches, prompt the operator withresume/start-new/discard; never resume from a checkpoint without that confirmation. - Model the payload under
state:with the run conditions from MEASURE step 1, the baseline numbers, the applied remediations, and the last completed phase (measured,awaiting-approval-<n>,fixed,re-measured). Conditions are part of the checkpoint, not re-derived on resume.
German trigger phrases
Also invoke on equivalent German requests, and reply to the operator in German (instructions in this file stay English):
- "Miss die Startzeit der App" / "App-Start profilieren"
- "Behebe das Ruckeln" / "Jank / abgehackte Frames beheben"
- "Warum ist der Screen so langsam / hakelig?"
- "Baseline Profiles hinzufügen oder reparieren"
- "Gefühlte Performance optimieren"
- "Prüfe die Ladeindikatoren gegen die Reaktionszeit-Schwellen"
- "Benchmark-Modul / Macrobenchmark einrichten"
- "Kaltstart mit Perfetto tracen" / "Warum startet die App so langsam?"
- "Frame-Drops beim Scrollen messen"
Gotchas
- A debuggable build measures far slower and janktier than release; always measure a release-shaped, R8-minified variant, or the numbers are drift by construction.
am start -WTotalTimeis TTID, not TTFD; a screen that shows a spinner "quickly" can still be slow to become useful — report TTFD fromreportFullyDrawn()where it matters.dumpsys gfxinfoaccumulates until reset; alwaysresetimmediately before the scenario or the percentages fold in prior activity.- Baseline Profiles only take effect on a release install performed through the normal install path with profile compilation; verifying them on a debug build shows no gain and is a false negative.
- The first cold start after install includes one-time work (dexopt, profile install); discard it and measure subsequent cold starts.
- Macrobenchmark refuses to run against a debuggable target and needs the app
profileable; abenchmarkbuild type withoutmatchingFallbacksfails to resolve library modules that only havedebug/release. - The
Fully drawnlogcat line never appears for an app that does not callreportFullyDrawn()— its absence is data, not a logging problem.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

