swiftui-performance-audit
O que ela faz
Esta skill audita o desempenho de telas SwiftUI, desde a revisão do código até a busca pelas causas de rolagem lenta ou atualizações pesadas. Ela serve para desenvolvedores iOS cujas telas parecem lentas ou travam.
Quando usar
- ✓Quando uma tela SwiftUI trava ao rolar ou navegar.
- ✓Quando o uso de memória ou de CPU parece alto em uma view SwiftUI.
- ✓Quando você quer uma revisão de desempenho de uma funcionalidade SwiftUI.
Link da skill
https://github.com/steipete/agent-scripts/blob/main/skills/swiftui-performance-audit/SKILL.mdCopie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.
Como usar
O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.
Mensagem pronta para colar
Para Claude Code, Codex ou Cursor: rode na pasta do projeto e a skill fica instalada.
Baixe o SKILL.md e coloque na pasta de skills do seu agente.
Exemplo do que pedir para a IA
“Esta lista SwiftUI trava quando eu rolo. Revise o código e me diga as causas prováveis.”
5 skills novas por semana. 1 minuto de leitura.
Como funciona
O agente revisa o código da view em busca de causas comuns, como mudanças de estado muito amplas e trabalho pesado dentro do body da view. Se a revisão não for conclusiva, ele guia você por uma execução de perfilagem no Instruments.
Conteúdo técnico (SKILL.md original)
Texto original do autor, em inglês, direto do GitHub.
SwiftUI Performance Audit
Attribution: copied from @Dimillian’s Dimillian/Skills (2025-12-31).
Overview
Audit SwiftUI 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 a trace or screenshots.
1. Code-First Review
Collect:
- Target view/feature code.
- Data flow: state, environment, observable models.
- Symptoms and reproduction steps.
Focus on:
- View invalidation storms from broad state changes.
- Unstable identity in lists (
idchurn,UUID()per render). - Heavy work in
body(formatting, sorting, image decoding). - Layout thrash (deep stacks,
GeometryReader, preference chains). - Large images without downsampling or resizing.
- Over-animated hierarchies (implicit animations on large trees).
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 with Instruments:
- Use the SwiftUI template in Instruments (Release build).
- Reproduce the exact interaction (scroll, navigation, animation).
- Capture SwiftUI timeline and Time Profiler.
- Export or screenshot the relevant lanes and the call tree.
Ask for:
- Trace export or screenshots of SwiftUI lanes + Time Profiler call tree.
- Device/OS/build configuration.
3. Analyze and Diagnose
Prioritize likely SwiftUI culprits:
- View invalidation storms from broad state changes.
- Unstable identity in lists (
idchurn,UUID()per render). - Heavy work in
body(formatting, sorting, image decoding). - Layout thrash (deep stacks,
GeometryReader, preference chains). - Large images without downsampling or resizing.
- Over-animated hierarchies (implicit animations on large trees).
Summarize findings with evidence from traces/logs.
4. Remediate
Apply targeted fixes:
- Narrow state scope (
@State/@Observablecloser to leaf views). - Stabilize identities for
ForEachand lists. - Move heavy work out of
body(precompute, cache,@State). - Use
equatable()or value wrappers for expensive subtrees. - Downsample images before rendering.
- Reduce layout complexity or use fixed sizing where possible.
Common Code Smells (and Fixes)
Look for these patterns during code review.
Expensive formatters in body
var body: some View {
let number = NumberFormatter() // slow allocation
let measure = MeasurementFormatter() // slow allocation
Text(measure.string(from: .init(value: meters, unit: .meters)))
}
Prefer cached formatters in a model or a dedicated helper:
final class DistanceFormatter {
static let shared = DistanceFormatter()
let number = NumberFormatter()
let measure = MeasurementFormatter()
}
Computed properties that do heavy work
var filtered: [Item] {
items.filter { $0.isEnabled } // runs on every body eval
}
Prefer precompute or cache on change:
@State private var filtered: [Item] = []
// update filtered when inputs change
Sorting/filtering in body or ForEach
List {
ForEach(items.sorted(by: sortRule)) { item in
Row(item)
}
}
Prefer sort once before view updates:
let sortedItems = items.sorted(by: sortRule)
Inline filtering in ForEach
ForEach(items.filter { $0.isEnabled }) { item in
Row(item)
}
Prefer a prefiltered collection with stable identity.
Unstable identity
ForEach(items, id: \.self) { item in
Row(item)
}
Avoid id: \.self for non-stable values; use a stable ID.
Image decoding on the main thread
Image(uiImage: UIImage(data: data)!)
Prefer decode/downsample off the main thread and store the result.
Broad dependencies in observable models
@Observable class Model {
var items: [Item] = []
}
var body: some View {
Row(isFavorite: model.items.contains(item))
}
Prefer granular view models or per-item state to reduce update fan-out.
5. Verify
Ask the user to re-run the same capture and compare with baseline metrics. Summarize the delta (CPU, frame drops, memory peak) if provided.
Outputs
Provide:
- A
Perguntas frequentes
Sempre é preciso fazer um perfil?
Não. Ele começa com uma revisão de código e só pede um perfil se a revisão não for conclusiva.
Quais causas comuns ele procura?
Mudanças de estado muito amplas, identidade instável de listas, trabalho pesado no body da view e imagens grandes.
Qual build deve ser perfilado?
A skill recomenda um build Release para a perfilagem.
Detalhes
Descrição original do autor
SwiftUI performance: render, scroll, CPU/memory, updates, layout, Instruments.
repo: steipete/agent-scripts
Popularidade
- Estrelas no GitHub
- 7,4 mil
- Posição no ranking
- #13250
- Licença
- MIT
- Atualizada em
- 30/10/2026
Comentários
- …
Mais skills deste repositório
beeper
7,4 milAjuda seu agente a pesquisar o seu histórico local de conversas do Beeper para encontrar mensagens e descobrir a qual conversa ou contato uma pista vaga se refere.
cloudflare-registrar
7,4 milAjuda seu agente a consultar preços e disponibilidade de domínios no Cloudflare Registrar, e a registrar ou listar domínios com uma etapa de confirmação.
codexbar
7,4 milAjuda seu agente a verificar quanto uso você ainda tem em serviços de IA como Codex, Claude e Kimi, incluindo limites, créditos e horários de renovação.
create-cli
7,4 milAjuda seu agente a desenhar os comandos, as opções, os textos de ajuda, a saída e os erros de uma ferramenta de linha de comando, para que ela funcione tanto para pessoas quanto para scripts.
Skills parecidas
android-clean-architecture
280 milFaz seu agente organizar projetos Android de forma eficiente. Ele estrutura o código para facilitar a manutenção e o desenvolvimento de novos recursos.
compose-multiplatform-patterns
280 milAjuda seu agente a usar Compose Multiplatform e Jetpack Compose em projetos KMP. Cobre estado, navegação, temas e performance.
dart-flutter-patterns
280 milFaz seu agente escrever código para apps Dart e Flutter. Ele usa padrões modernos para criar apps robustos e fáceis de gerenciar.