MCPInstall

performance-profiling

Guide performance profiling with Instruments, diagnose hangs, memory issues, slow launches, and energy drain. Use when reviewing app performance or investigating specific bottlenecks.

Installs
81
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/rshankras/claude-code-apple-skills --skill performance-profiling
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads performance-profiling automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

Performance Profiling

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.

When This Skill Activates

Use this skill when the user:

  • Reports app hangs, stutters, or dropped frames
  • Needs to profile CPU usage or find hot code paths
  • Has memory leaks, high memory usage, or OOM crashes
  • Wants to optimize app launch time
  • Needs to reduce battery/energy impact
  • Asks about Instruments, Time Profiler, Allocations, or Leaks
  • Wants to add os_signpost or performance measurement to code
  • Is preparing for App Store review and needs performance validation

Decision Tree

What performance problem are you investigating?
│
├─ App hangs / unresponsive to taps / slow UI
│  └─ Read time-profiler.md
│
├─ Scroll or animation stutter / dropped frames / hitches
│  └─ Read hitches.md
│
├─ High memory / leaks / OOM crashes / growing footprint
│  └─ Read memory-profiling.md
│
├─ Slow app launch / time to first frame
│  └─ Read launch-optimization.md
│
├─ Battery drain / thermal throttling / background energy
│  └─ Read energy-diagnostics.md
│
├─ General "app feels slow" (unknown cause)
│  └─ Start with time-profiler.md, then memory-profiling.md
│
└─ Pre-release performance audit
   └─ Read ALL reference files, use Review Checklist below

Quick Reference

ProblemInstrument / ToolKey MetricReference
UI hangs > 250msTime Profiler + HangsHang duration, main thread stacktime-profiler.md
Scroll/animation hitchesAnimation Hitches templateHitch time ratio (< 5 ms/s good, > 10 critical)hitches.md
High CPU usageTime Profiler / CPU ProfilerCPU % by function, call tree weighttime-profiler.md
Memory leakLeaks + Memory GraphLeaked bytes, retain cycle pathsmemory-profiling.md
Memory growthAllocationsLive bytes, generation analysismemory-profiling.md
Slow launchApp LaunchTime to first frame (pre-main + post-main)launch-optimization.md
Battery drainEnergy Log / Power ProfilerEnergy Impact score, CPU/GPU/networkenergy-diagnostics.md
Thermal issuesActivity MonitorThermal state transitionsenergy-diagnostics.md
Network wasteNetwork profilerRedundant fetches, large payloadsenergy-diagnostics.md

The 8 Key Metrics (WWDC21 10181)

Apple enumerates exactly eight things to track for app performance, all coverable with five tools (Xcode Organizer, MetricKit, Instruments, XCTest, App Store Connect API):

#MetricThreshold / signalTool
1Battery usageEnergy Gauge flags CPU use > 20% as High CPU, plus CPU Wake Overhead regions; top subsystems to watch: CPU, Networking, LocationEnergy Gauge → Time Profiler
2Launch timeTime between icon tap and first frame renderedApp Launch template, XCTApplicationLaunchMetric
3Hang rateUnresponsive to input for ≥ 250msHangs instrument, Organizer
4MemoryOrganizer charts peak memory and memory at suspension; a spike with no termination spike yet is your early warningAllocations, Leaks, VM Tracker
5Disk writesException report when the app writes > 1 GB in 24 hours (with stack trace + Insights annotations)File Activity template, XCTStorageMetric
6ScrollingRed bars in the Organizer scrolling chart = poor scroll experience, fix immediatelyAnimation Hitches, XCTOSSignpostMetric.scrollDecelerationMetric
7TerminationsEvery termination forces a slow cold launch next time and loses user stateMXAppExitMetric, Organizer
8MXSignpostsCustom marked intervals for your critical code sectionsMetricKit

The Organizer aggregates all of these from consented user devices across the last 16 app versions; the Regressions pane (Xcode 13) isolates every metric that increased significantly in the most recent version, in one place. The same data is available as JSON via the App Store Connect API (WWDC21 10181).

Process

1. Identify the Problem Category

Ask the user or inspect their description to classify the issue:

  • Responsiveness: Hangs, stutters, animation drops
  • Memory: Leaks, growth, OOM crashes
  • Launch: Slow cold/warm start
  • Energy: Battery drain, thermal throttling

2. Read the Appropriate Reference File

Each file contains:

  • Which Instruments template to use
  • Step-by-step profiling workflow
  • How to interpret results
  • Common fix patterns with code examples

3. Profile on Real Hardware

Always remind users:

  • Profile on device, not Simulator (Simulator uses host CPU/memory)
  • Use Release build configuration (optimizations change behavior)
  • Profile with representative data (empty databases hide real perf)
  • Close other apps to reduce noise

4. Apply Fixes and Verify

After identifying bottlenecks:

  • Apply targeted fix from the reference file
  • Re-profile to confirm improvement
  • Add os_signpost markers for ongoing monitoring

Xcode Diagnostic Settings

Recommend enabling these in Scheme > Run > Diagnostics:

SettingWhat It Catches
Main Thread CheckerUI work off main thread
Thread SanitizerData races
Address SanitizerBuffer overflows, use-after-free
Malloc Stack LoggingMemory allocation call stacks
Zombie ObjectsMessages to deallocated objects

MetricKit Integration

For production monitoring, recommend MetricKit (WWDC20 10081, WWDC21 10181):

import MetricKit

final class PerformanceReporter: NSObject, MXMetricManagerSubscriber {
    func startCollecting() {
        MXMetricManager.shared.add(self)   // subscribe once, early in launch
    }
    // best practice: remove(self) in deinit (WWDC21 10181)

    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)")
            }
            // Scroll hitches (ratio of time hitching to time scrolling)
            if let animation = payload.animationMetrics {
                log("Scroll hitch ratio: \(animation.scrollHitchTimeRatio)")
            }
            // Exit reasons — daily counts per termination cause, fg + bg
            if let exits = payload.applicationExitMetrics {
                log("Exits: \(exits.backgroundExitData)")
            }
        }
    }

    func didReceive(_ payloads: [MXDiagnosticPayload]) {
        for payload in payloads {
            if let hangs = payload.hangDiagnostics {
                for hang in hangs {
                    log("Hang: \(hang.callStackTree)")
                }
            }
        }
    }
}

Key facts (WWDC20 10081, WWDC21 10181):

  • ❌ Subscribing lazily (e.g. in a settings screen) silently misses delivered payloads — ✅ subscribe in App/AppDelegate init; the previous day's payloads are handed to you on launch.
  • Metrics arrive as 24-hour payloads, at most once per day, in three aggregation forms: cumulative, averaged, and bucketized (MXHistogram). On iOS 15+/macOS 12+, all diagnostics are delivered immediately after the issue occurs instead of daily.
  • Termination and memory telemetry arrive in the daily metric payload by default — no extra instrumentation.
  • Diagnostic types: MXHangDiagnostic (main-thread unresponsive time + backtraces), MXCrashDiagnostic (exception info, termination reason, VM region info), MXCPUExceptionDiagnostic (threads burning CPU — the programmatic form of Organizer energy logs), MXDiskWriteExceptionDiagnostic (fires on the 1 GB/day write threshold).
  • MXCallStackTree backtraces are unsymbolicated by design — symbolicate off-device with atos-class tools + your dSYMs; ❌ don't try on-device.
  • MXSignpost marks critical code sections for field telemetry; the animation variant captures hitch-rate telemetry for the interval:
let handle = MXMetricManager.makeLogHandle(category: "animation_telemetry")
mxSignpostAnimationIntervalBegin(log: handle, name: "custom_animation")
// ... animation ...
mxSignpost(OSSignpostType.end, log: handle, name: "custom_animation")

Review Checklist

Responsiveness

  • No synchronous work on main thread > 100ms
  • No file I/O or network calls on main thread
  • Core Data / SwiftData fetches use background contexts for large queries
  • Images decoded off main thread (use .preparingThumbnail or async decoding)
  • @MainActor only on code that truly needs UI access

Memory

  • No retain cycles (check delegate patterns, closures with self)
  • Large resources freed when not visible (images, caches)
  • Collections don't grow unbounded (capped caches, pagination)
  • autoreleasepool used in tight loops creating ObjC objects

Launch Time

  • No heavy work in init() of @main App struct
  • Deferred non-essential initialization (analytics, prefetch)
  • Minimal dynamic frameworks (prefer static linking)
  • No synchronous network calls at launch

Energy

  • Background tasks use BGProcessingTaskRequest appropriately
  • Location accuracy matches actual need (not always .best)
  • Timers use tolerance to allow coalescing
  • Network requests batched where possible

References

FAQ

What does the performance-profiling skill do?

Guide performance profiling with Instruments, diagnose hangs, memory issues, slow launches, and energy drain. Use when reviewing app performance or investigating specific bottlenecks.

How do I install performance-profiling?

Run npx skills add https://github.com/rshankras/claude-code-apple-skills --skill performance-profiling in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/performance-profiling/ (personal) or .claude/skills/performance-profiling/ (project).

Which AI agents can use performance-profiling?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is performance-profiling safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains performance-profiling?

It is published by rshankras in rshankras/claude-code-apple-skills. It has 81 recorded installs.

More from rshankras/claude-code-apple-skills

View all →

macos-development

rshankras/claude-code-apple-skills

Comprehensive macOS development guidance including Swift 6+, SwiftUI, SwiftData, architecture patterns, AppKit bridging, and macOS 26 Tahoe APIs. Use for macOS code review, best practices, UI review, or platform-specific features.

ios-development

rshankras/claude-code-apple-skills

Comprehensive iOS development guidance including Swift best practices, SwiftUI patterns, UI/UX review against HIG, and app planning. Use for iOS code review, best practices, accessibility audits, or planning new iOS apps.

Mobile823 installs

design

rshankras/claude-code-apple-skills

Design skills for Apple platform UI — Liquid Glass, animations, game feel (haptics, sound, celebrations), UI prototyping, UX writing, SF Symbols, and typography. Use when implementing design language features, adding juice/feedback, writing interface copy, or choosing type and iconography.

Frontend & Design680 installs

app-store

rshankras/claude-code-apple-skills

App Store optimization and marketing skills for descriptions, screenshots, keywords, review responses, and comprehensive promotional strategy. Use when user needs help with App Store presence, ASO, marketing, or customer communication.

Mobile599 installs

watchos

rshankras/claude-code-apple-skills

watchOS development guidance including SwiftUI for Watch, Watch Connectivity, complications, and watch-specific UI patterns. Use for watchOS code review, best practices, or Watch app development.

product-development

rshankras/claude-code-apple-skills

End-to-end product development for iOS/macOS apps. Covers market research, competitive analysis, PRD generation, architecture specs, UX design, implementation guides, testing, and App Store release. Use for product planning, validation, or generating specification documents.

Testing & QA554 installs

Popular code quality & workflow skills

View category →

grill-me

mattpocock/skills

A relentless interview to sharpen a plan or design.

Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.

handoff

mattpocock/skills

Compact the current conversation into a handoff document for another agent to pick up.

domain-modeling

mattpocock/skills

Build and sharpen a project's domain model. Use when discussing codebase terminology, writing or editing a GLOSSARY.md, or recording or editing an ADR.

codebase-design

mattpocock/skills

Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.

diagnosing-bugs

mattpocock/skills

Diagnosis loop for hard bugs and performance regressions. Use when the user says "diagnose"/"debug this", or reports something broken/throwing/failing/slow.