Skip to main content
skill CX Codex

performance-profiling — Claude Code skill: setup and features

Guides performance profiling for Apple apps using Instruments and MetricKit. It directs the AI agent to pinpoint hangs and slow launch times.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add MengTo/Skills --skill performance-profiling -a claude-code
Open on GitHub

What performance-profiling does

This skill equips coding agents with a structured approach to Apple app diagnostics. Instead of guessing, it routes the workflow through a decision tree based on concrete symptoms. It points to dedicated guides for Time Profiler, Allocations, and launch optimization. UI hangs exceeding 250 milliseconds and memory leaks get targeted investigation steps.

The workflow enforces strict diagnostic hygiene. Simulator profiling skews data because it runs on the host machine CPU and memory. You must test on a physical device using a Release build where compiler optimizations reflect production reality.

For production metrics, the skill supplies ready-to-use Swift snippets for MetricKit subscribers to capture launch latency and hang payloads. It also provides pre-release checks covering @MainActor isolation and os_signpost instrumentation.

What it helps with

  • isolate main thread hangs exceeding 250 ms
  • track down memory leaks and retain cycles in closures
  • reduce cold launch time and time to first frame
  • implement MetricKit subscribers for production telemetry

Example prompts for the agent

  • Analyze this main thread hang report and suggest fixes based on Time Profiler data
  • Add a MetricKit subscriber to track launch metrics and hang diagnostics in production
  • Audit this SwiftUI view model against the memory and responsiveness checklist

How to install performance-profiling

1Skills CLI (Vercel)

npx skills add MengTo/Skills --skill performance-profiling -a claude-code

2Manually: put the files in place

~/.claude/skills/performance-profiling/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/performance-profiling/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about performance-profiling

How to install performance-profiling in Claude Code?

Run npx skills add MengTo/Skills --skill performance-profiling -a claude-code in your terminal.

Which diagnostic tools does this skill cover?

It covers Xcode Instruments such as Time Profiler, Allocations, and Leaks, alongside runtime diagnostics like Main Thread Checker. It also covers production monitoring via MetricKit.

Why does the skill require profiling on a physical device in Release mode?

The Simulator relies on your host Mac processor and RAM, yielding inaccurate performance numbers. Release builds are necessary because compiler optimizations alter execution paths and hot spots.

Source text

SKILL.md · MIT
---
name: performance-profiling
description: Guide performance profiling for Apple platform apps with Instruments, Xcode diagnostics, and MetricKit. Use when investigating app hangs, stutters, high CPU, memory leaks, memory growth, OOM crashes, slow launch, battery drain, thermal issues, App Store performance readiness, or when adding os_signpost and measurement hooks.
---

# Performance Profiling

Use this skill to diagnose Apple app performance issues systematically, pick the right profiling workflow, apply targeted fixes, and verify the change with real measurements.

## Decision Tree

Choose the reference file before changing code:

```text
What performance problem are you investigating?

+ App hangs, stutters, dropped frames, slow UI, high CPU
  -> Read references/time-profiler.md

+ High memory, leaks, OOM crashes, growing footprint
  -> Read references/memory-profiling.md

+ Slow cold launch, warm launch, resume, or time to first frame
  -> Read references/launch-optimization.md

+ Battery drain, thermal throttling, background energy, network waste
  -> Read references/energy-diagnostics.md

+ General "app feels slow"
  -> Start with references/time-profiler.md, then references/memory-profiling.md

+ Pre-release performance audit
  -> Read all reference files and use the review checklist below
```

## Quick Reference

| Problem | Instrument / Tool | Key Metric | Reference |
| --- | --- | --- | --- |
| UI hangs over 250 ms | Time Profiler + Hangs | Hang duration, main thread stack | `references/time-profiler.md` |
| High CPU usage | Time Profiler | CPU percent 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, CPU/GPU/network activity | `references/energy-diagnostics.md` |
| Thermal issues | Activity Monitor, Instruments | Thermal state transitions | `references/energy-diagnostics.md` |
| Network waste | Network profiler | Redundant fetches, payload size | `references/energy-diagnostics.md` |

## Workflow

1. Identify the performance category from the user report, traces, logs, or code path.
2. Read only the matching reference file unless the issue is broad or unclear.
3. Prefer real device profiling with a Release build and representative data.
4. Inspect the code path named by the profile before proposing a fix.
5. Apply the smallest targeted fix that addresses the measured bottleneck.
6. Re-profile or add a repeatable measurement to confirm the improvement.

## Profiling Ground Rules

- Profile on device when possible; Simulator uses host CPU and memory.
- Use Release configuration because optimizations can change hot paths.
- Reproduce with representative data, not empty databases or toy assets.
- Close unrelated apps to reduce noise during profiling.
- Keep measurements before and after the fix so the outcome is concrete.
- Add `os_signpost` markers when a workflow needs ongoing timing visibility.

## Xcode Diagnostics

Recommend relevant Scheme > Run > Diagnostics settings when they match the suspected issue:

| Setting | Use For |
| --- | --- |
| Main Thread Checker | UI work off the main thread |
| Thread Sanitizer | Data races and unsafe shared state |
| Address Sanitizer | Buffer overflows and use-after-free |
| Malloc Stack Logging | Allocation call stacks |
| Zombie Objects | Messages to deallocated objects |

## MetricKit Hook

Suggest MetricKit for production monitoring of launch, responsiveness, memory, and diagnostics:

```swift
import MetricKit

final class PerformanceReporter: NSObject, MXMetricManagerSubscriber {
    func startCollecting() {
        MXMetricManager.shared.add(self)
    }

    func didReceive(_ payloads: [MXMetricPayload]) {
        for payload in payloads {
            if let launch = payload.applicationLaunchMetrics {
                log("Resume time: \(launch.histogrammedResumeTime)")
            }
            if let responsiveness = payload.applicationResponsivenessMetrics {
                log("Hang time: \(responsiveness.histogrammedApplicationHangTime)")
            }
            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)")
                }
            }
        }
    }
}
```

## Review Checklist

Responsiveness:
- No synchronous work on the main thread over 100 ms.
- No file I/O or network calls on the main thread.
- Large Core Data or SwiftData fetches use background contexts.
- Images decode off the main thread.
- `@MainActor` is limited to code that truly needs UI access.

Memory:
- No retain cycles in delegates, closures, observers, or async tasks.
- Large resources are released when no longer visible.
- Collections and caches are bounded.
- `autoreleasepool` is used in tight loops that create Objective-C objects.

Launch:
- No heavy work in `init()` of the `@main App` struct.
- Non-essential initialization is deferred.
- Dynamic frameworks are minimized where practical.
- No synchronous network calls occur during launch.

Energy:
- Background tasks use the appropriate `BGTaskScheduler` request type.
- Location accuracy matches the product need.
- Timers use tolerance so the system can coalesce wakeups.
- Network requests are batched and cached where possible.

## References

- `references/time-profiler.md`: CPU profiling, hang detection, signpost API.
- `references/memory-profiling.md`: Allocations, Leaks, Memory Graph debugger.
- `references/launch-optimization.md`: Launch phases and cold/warm start optimization.
- `references/energy-diagnostics.md`: Battery, thermal state, and network efficiency.

© MengTo · MIT · MengTo/Skills

Similar skills

Everything for Mobile →

From the same set148

unsplash-asset-images This skill picks Unsplash photos for avatars, headshots, backgrounds and wallpapers, and names the ratios and resolutions you need. CX Codex +1 1,600installs scroll-world-storytelling Turns articles, case studies, and product journeys into visual scroll-driven landing pages. Useful when you need a connected story instead of generic stacked sections. CX Codex +1 1,600installs staggered-word-reveal Builds word-by-word text reveals as content enters the viewport. Use it for short headlines, section intros, quotes, and hero copy. CX Codex +1 1,600installs editorial-portfolio-chapters A skill for creative-studio, agency, photographer and artist sites where the work leads the story. Useful when a portfolio has to read as a run of magazine chapters. CX Codex +1 1,400installs audit-verify-explain-grade-5 This skill makes the agent audit a change, back every claim with evidence, and then explain the result in plain language. Handy when you review someone else's fix or a test report. CX Codex +1 1,400installs product-proof-saas A skill for SaaS and AI landing pages where the proof is a real interface or a clearly labeled demo, not atmospheric decoration. CX Codex +1 1,400installs funky-purple-container-tech Guides the agent to design dark, container-driven interfaces with fuchsia-purple accents, structured frame lines, and futuristic glowing details. CX Codex +1 1,400installs ambient-section-particles A skill that builds a restrained particle layer inside one section: petals, snow, sparks, confetti. Content stays readable. CX Codex +1 1,400installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor