swiftui-performance-audit
하는 일
이 스킬은 코드 검토부터 스크롤이 느리거나 업데이트가 무거운 원인 찾기까지 SwiftUI 성능을 점검합니다. 화면이 느리거나 끊기는 iOS 개발자를 위한 스킬입니다.
사용하는 경우
- ✓SwiftUI 화면이 스크롤하거나 이동할 때 끊길 때.
- ✓SwiftUI 뷰에서 메모리나 CPU 사용량이 높아 보일 때.
- ✓SwiftUI 기능의 성능 검토를 받고 싶을 때.
스킬 링크
https://github.com/steipete/agent-scripts/blob/main/skills/swiftui-performance-audit/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“이 SwiftUI 리스트가 스크롤할 때 끊겨요. 코드를 검토하고 가능성이 높은 원인을 알려 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 뷰 코드에서 넓은 범위의 상태 변경, 뷰 body 안의 무거운 작업 같은 흔한 원인을 찾습니다. 검토 결과가 분명하지 않으면 Instruments에서 프로파일링하는 과정을 안내합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 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
자주 묻는 질문
항상 프로파일이 필요한가요?
아닙니다. 먼저 코드 검토로 시작하고, 검토 결과가 분명하지 않을 때만 프로파일을 요청합니다.
어떤 흔한 원인을 찾나요?
넓은 범위의 상태 변경, 안정적이지 않은 리스트 식별자, 뷰 body 안의 무거운 작업, 큰 이미지를 찾습니다.
프로파일링은 어떤 빌드로 해야 하나요?
스킬은 프로파일링에 Release 빌드를 사용하도록 권장합니다.
상세 정보
작성자의 원본 설명
SwiftUI performance: render, scroll, CPU/memory, updates, layout, Instruments.
repo: steipete/agent-scripts
인기도
- GitHub 스타
- 7.4k
- 순위
- #13250
- 라이선스
- MIT
- 업데이트
- 2026. 10. 30.
댓글
- …
이 저장소의 다른 스킬
beeper
7.4k에이전트가 로컬 Beeper 채팅 기록을 검색해 메시지를 찾고, 모호한 힌트가 어느 채팅이나 연락처를 가리키는지 알아내도록 돕습니다.
cloudflare-registrar
7.4k에이전트가 Cloudflare Registrar에서 도메인 가격과 사용 가능 여부를 확인하고, 확인 단계를 거쳐 도메인을 등록하거나 목록을 조회하도록 돕습니다.
codexbar
7.4k에이전트가 Codex, Claude, Kimi 같은 AI 서비스의 남은 사용량을 한도, 크레딧, 초기화 시간과 함께 확인하도록 돕습니다.
create-cli
7.4k에이전트가 명령줄 도구의 명령, 옵션, 도움말, 출력, 오류를 설계해 사람과 스크립트 모두가 쓸 수 있도록 돕습니다.
비슷한 스킬
android-clean-architecture
280k에이전트가 Android 프로젝트를 효율적으로 구성하도록 돕습니다. 유지보수와 새 기능 개발이 쉽도록 코드를 구조화합니다.
compose-multiplatform-patterns
280k에이전트가 KMP 프로젝트에서 Compose Multiplatform과 Jetpack Compose 패턴을 쓰도록 돕습니다. 상태, 내비게이션, 테마, 성능을 다룹니다.
dart-flutter-patterns
280kDart와 Flutter 앱용 코드를 작성하도록 에이전트를 돕습니다. 견고하고 관리하기 쉬운 앱을 만드는 현대적인 패턴을 씁니다.