home / skills / willsigmon / sigstack / performance-expert
This skill helps iOS developers optimize performance by identifying main thread work, memory leaks, and battery drains using profiling best practices.
npx playbooks add skill willsigmon/sigstack --skill performance-expertReview the files below or copy the command above to add this skill to your agents.
---
name: Performance Expert
description: iOS performance - main thread blocking, rendering, memory leaks, battery drain, profiling
allowed-tools: Read, Edit, Grep, Glob
---
# Performance Expert
Performance optimization for Leavn iOS app.
## Main Thread Violations
Find heavy work in View body:
```swift
// BAD: In View body
let image = processImage(data) // Blocks UI
// GOOD: In ViewModel, async
Task { processedImage = await processImage(data) }
```
## SwiftUI Rendering
- Use `@Observable` (not @Published) for granular updates
- `EquatableView` for expensive views
- `LazyVStack/LazyHStack` for lists
- `drawingGroup()` for complex graphics
## Memory Issues
- Capture `[weak self]` in closures
- Break retain cycles in delegates
- Use `Instruments > Leaks` to find issues
## Battery/Thermal
- Batch network requests
- Reduce location update frequency
- Use `beginBackgroundTask` sparingly
- Profile with Instruments > Energy Log
## Profiling Commands
```bash
# Time Profile
xcrun xctrace record --template "Time Profiler" --launch -- /path/to/app
# Memory
xcrun xctrace record --template "Leaks" --launch -- /path/to/app
```
Use when: Slow UI, battery drain, memory issues, thermal throttling
This skill helps diagnose and fix iOS performance problems for SwiftUI apps, focusing on main-thread blocking, rendering inefficiencies, memory leaks, and battery/thermal issues. It provides concrete profiling commands, patterns to avoid, and actionable optimizations to restore smooth UI and reduce resource usage. Use it to prioritize fixes and verify improvements with Instruments.
The skill inspects common hotspots: heavy synchronous work inside SwiftUI view bodies, inefficient rendering patterns, closure retain cycles, and battery-heavy background behavior. It recommends code-level changes (move work to view models, use weak captures, use lazy stacks and drawingGroup) and gives xcrun xctrace commands to capture Time Profiler, Leaks, and Energy traces for root-cause analysis. It also suggests runtime mitigations like batching and throttling updates.
How do I spot main-thread work in SwiftUI?
Look for synchronous processing inside View bodies; move heavy tasks into async ViewModel tasks and verify with Time Profiler traces.
Which Instruments templates should I run first?
Start with Time Profiler for CPU, Leaks for memory issues, and Energy Log for battery/thermal investigation.