Token导航 LogoToken导航TokenDH.com
研究检索只读github未标认证来源可访问许可证需确认审计通过

compose-performance-audit撰写绩效审计

Agent Skill

用于辅助安全审计、权限检查、凭据风险、认证流程和常见漏洞排查。它适合让 Agent 梳理敏感配置、检查依赖风险、分析鉴权逻辑或生成安全复核清单。使用时不能把工具输出直接当最终结论,涉及密钥、令牌、用户数据或生产系统时,应先确认最小权限、脱敏方式和操作边界。

总安装

6,977

周安装

285

GitHub Stars

772

下载量

2,257
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:compose-performance-audit(撰写绩效审计)
来源仓库:https://github.com/new-silvermoon/awesome-android-agent-skills
仓库路径:skills/compose-performance-audit
安装命令:
npx skills add https://github.com/new-silvermoon/awesome-android-agent-skills --skill compose-performance-audit
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/new-silvermoon/awesome-android-agent-skills --skill compose-performance-audit

简介

compose-performance-audit 对 Jetpack Compose 视图性能进行端到端审计。

  • 适用于存在渲染卡顿、布局异常或资源占用过高的 Compose 应用。
  • 从 instrumentation 和 baselining 开始,直至根因分析和具体修复步骤。
  • 若用户仅描述症状而无代码,需先引导用户提供最小复现代码。
  • 必要时引导用户使用 Layout Inspector 或 Perfetto traces 获取详细性能数据。

SKILL.md

Compose Performance Audit

Overview

Audit Jetpack Compose view performance end-to-end, from instrumentation and baselining to root-cause analysis and concrete remediation steps.

Workflow Decision Tree

  • If the user provides code, start with "Code-First Review."
  • If the user only describes symptoms, ask for minimal code/context, then do "Code-First Review."
  • If code review is inconclusive, go to "Guide the User to Profile" and ask for Layout Inspector output or Perfetto traces.

1. Code-First Review

Collect:

  • Target Composable code.
  • Data flow: state, remember, derived state, ViewModel connections.
  • Symptoms and reproduction steps.

Focus on:

  • Recomposition storms from unstable parameters or broad state changes.
  • Unstable keys in LazyColumn/LazyRow (key churn, missing keys).
  • Heavy work in composition (formatting, sorting, filtering, object allocation).
  • Unnecessary recompositions (missing remember, unstable classes, lambdas).
  • Large images without proper sizing or async loading.
  • Layout thrash (deep nesting, intrinsic measurements, SubcomposeLayout misuse).

Provide:

  • Likely root causes with code references.
  • Suggested fixes and refactors.
  • If needed, a minimal repro or instrumentation suggestion.

2. Guide the User to Profile

Explain how to collect data:

  • Use Layout Inspector in Android Studio to see recomposition counts.
  • Enable Recomposition Highlights in Compose tooling.
  • Use Perfetto or System Trace for frame timing analysis.
  • Check Macrobenchmark results for startup/scroll metrics.

Ask for:

  • Layout Inspector screenshot showing recomposition counts.
  • Perfetto trace or System Trace export.
  • Device/OS/build configuration (debug vs release).
Important: Ensure profiling is done on a release build with R8 enabled. Debug builds have significant overhead.

3. Analyze and Diagnose

Prioritize likely Compose culprits:

  • Recomposition storms from unstable parameters or broad state changes.
  • Unstable keys in lazy lists (key churn, index-based keys).
  • Heavy work in composition (formatting, sorting, object allocation).
  • Missing remember causing recreations on every recomposition.
  • Large images without Modifier.size() constraints.
  • Unnecessary state reads in wrong composition phases.

Summarize findings with evidence from traces/Layout Inspector.

4. Remediate

Apply targeted fixes:

  • Stabilize parameters: Use @Stable or @Immutable annotations on data classes.
  • Stabilize keys: Use stable, unique IDs for LazyColumn/LazyRow items.
  • Defer state reads: Use derivedStateOf, lambda-based modifiers, or Modifier.drawBehind.
  • Remember expensive computations: Wrap in remember {} or remember(key) {}.
  • Skip recomposition: Extract stable composables, use key() to control identity.
  • Async image loading: Use Coil/Glide with proper sizing constraints.
  • Reduce layout complexity: Flatten hierarchies, avoid deep nesting.

Common Code Smells (and Fixes)

Unstable lambda captures

// BAD: New lambda instance every recomposition
Button(onClick = { viewModel.doSomething(item) }) { ... }

// GOOD: Use remember or method reference
val onClick = remember(item) { { viewModel.doSomething(item) } }
Button(onClick = onClick) { ... }

Expensive work in composition

// BAD: Sorting on every recomposition
@Composable
fun ItemList(items: List<Item>) {
    val sorted = items.sortedBy { it.name } // Runs every recomposition
    LazyColumn { items(sorted) { ... } }
}

// GOOD: Use remember with key
@Composable
fun ItemList(items: List<Item>) {
    val sorted = remember(items) { items.sortedBy { it.name } }
    LazyColumn { items(sorted) { ... } }
}

Missing keys in LazyColumn

// BAD: Index-based identity (causes recomposition on list changes)
LazyColumn {
    items(items) { item -> ItemRow(item) }
}

// GOOD: Stable key-based identity
LazyColumn {
    items(items, key = { it.id }) { item -> ItemRow(item) }
}

Unstable data classes

// BAD: Unstable (contains List, which is not stable)
data class UiState(
    val items: List<Item>,
    val isLoading: Boolean
)

// GOOD: Mark as Immutable if truly immutable
@Immutable
data class UiState(
    val items: ImmutableList<Item>, // kotlinx.collections.immutable
    val isLoading: Boolean
)

Reading state too early

// BAD: State read during composition (recomposes whole tree)
@Composable
fun AnimatedBox(scrollState: ScrollState) {
    val offset = scrollState.value // Recomposes on every scroll
    Box(modifier = Modifier.offset(y = offset.dp)) { ... }
}

// GOOD: Defer state read to layout/draw phase
@Composable
fun AnimatedBox(scrollState: ScrollState) {
    Box(modifier = Modifier.offset {
        IntOffset(0, scrollState.value) // Read in layout phase
    }) { ... }
}

Object allocation in composition

// BAD: Creates new Modifier chain every recomposition
Box(modifier = Modifier.padding(16.dp).background(Color.Red))

// GOOD for dynamic modifiers: Remember the modifier
val modifier = remember { Modifier.padding(16.dp).background(Color.Red) }
Box(modifier = modifier)

Stability Checklist

TypeStable by Default?Fix
Primitives (Int, String, Boolean)YesN/A
data class with stable fieldsYes*Ensure all fields are stable
List, Map, SetNoUse ImmutableList from kotlinx
Classes with var propertiesNoUse @Stable if externally stable
LambdasNoUse remember {}

5. Verify

Ask the user to:

  • Re-run Layout Inspector and compare recomposition counts.
  • Run Macrobenchmark and compare frame timing.
  • Test on a real device with release build.

Summarize the delta (recomposition count, frame drops, jank) if provided.

Outputs

Provide:

  • A short metrics table (before/after if available).
  • Top issues (ordered by impact).
  • Proposed fixes with estimated effort.

References

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

36.4%
按下载量换算822

Claude

30.12%
按下载量换算680

Cursor

19.01%
按下载量换算429

Gemini CLI

10.69%
按下载量换算241

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills