skills/performance-profiling/SKILL.md
Guide performance profiling with Instruments, diagnose hangs, memory issues, slow launches, and energy drain. Use when reviewing app performance or investigating specific bottlenecks.
npx skillsauth add AutisticAF/claude-code-apple-dev-plugin performance-profilingInstall 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.
First step: Tell the user: "performance-profiling skill loaded."
Systematic guide for profiling Apple platform apps using Instruments, Xcode diagnostics, and MetricKit. Covers CPU, memory, launch time, and energy analysis with actionable fix patterns.
Use this skill when the user:
os_signpost or performance measurement to codeWhat performance problem are you investigating?
│
├─ App hangs / stutters / dropped frames / slow UI
│ └─ Read references/time-profiler.md
│
├─ High memory / leaks / OOM crashes / growing footprint
│ └─ Read references/memory-profiling.md
│
├─ Slow app launch / time to first frame
│ └─ Read references/launch-optimization.md
│
├─ Battery drain / thermal throttling / background energy
│ └─ Read references/energy-diagnostics.md
│
├─ General "app feels slow" (unknown cause)
│ └─ Start with references/time-profiler.md, then references/memory-profiling.md
│
└─ Pre-release performance audit
└─ Read ALL reference files, use Review Checklist below
| Problem | Instrument / Tool | Key Metric | Reference | |---------|-------------------|------------|-----------| | UI hangs > 250ms | Time Profiler + Hangs | Hang duration, main thread stack | references/time-profiler.md | | High CPU usage | Time Profiler | CPU % by function, call tree weight | references/time-profiler.md | | Memory leak | Leaks + Memory Graph | Leaked bytes, retain cycle paths | references/memory-profiling.md | | Memory growth | Allocations | Live bytes, generation analysis | references/memory-profiling.md | | Slow launch | App Launch | Time to first frame (pre-main + post-main) | references/launch-optimization.md | | Battery drain | Energy Log | Energy Impact score, CPU/GPU/network | references/energy-diagnostics.md | | Thermal issues | Activity Monitor | Thermal state transitions | references/energy-diagnostics.md | | Network waste | Network profiler | Redundant fetches, large payloads | references/energy-diagnostics.md |
Ask the user or inspect their description to classify the issue:
Each file contains:
Always remind users:
After identifying bottlenecks:
os_signpost markers for ongoing monitoringRecommend enabling these in Scheme > Run > Diagnostics:
| Setting | What It Catches | |---------|-----------------| | Main Thread Checker | UI work off main thread | | Thread Sanitizer | Data races | | Address Sanitizer | Buffer overflows, use-after-free | | Malloc Stack Logging | Memory allocation call stacks | | Zombie Objects | Messages to deallocated objects |
For production monitoring, recommend MetricKit:
import MetricKit
final class PerformanceReporter: NSObject, MXMetricManagerSubscriber {
func startCollecting() {
MXMetricManager.shared.add(self)
}
func didReceive(_ payloads: [MXMetricPayload]) {
for payload in payloads {
// Launch time
if let launch = payload.applicationLaunchMetrics {
log("Resume time: \(launch.histogrammedResumeTime)")
}
// Hang rate
if let responsiveness = payload.applicationResponsivenessMetrics {
log("Hang time: \(responsiveness.histogrammedApplicationHangTime)")
}
// Memory
if let memory = payload.memoryMetrics {
log("Peak memory: \(memory.peakMemoryUsage)")
}
}
}
func didReceive(_ payloads: [MXDiagnosticPayload]) {
for payload in payloads {
if let hangs = payload.hangDiagnostics {
for hang in hangs {
log("Hang: \(hang.callStackTree)")
}
}
}
}
}
.preparingThumbnail or async decoding)@MainActor only on code that truly needs UI accessself)autoreleasepool used in tight loops creating ObjC objectsinit() of @main App structBGProcessingTaskRequest appropriately.best)tolerance to allow coalescingdevelopment
SwiftUI Layout protocol for custom container layouts including flow layouts, radial layouts, and animated transitions. Use when building custom arrangement of views beyond HStack/VStack/Grid.
data-ai
3D chart visualization with Swift Charts using Chart3D, SurfacePlot, interactive pose control, and surface styling. Use when creating 3D data visualizations.
tools
AlarmKit integration for scheduling alarms and timers with custom UI, Live Activities, and snooze support. Use when implementing alarm or timer features in iOS 18+ apps.
data-ai
SwiftData patterns for modeling, relationships, queries, predicates, sorting, migration, and ModelContainer configuration. Use when working with SwiftData persistence.