Skip to main content
skill Claude Code CX Codex Cursor GitHub Copilot

argent-native-profiler — Claude Code skill: profiling

Profiles native performance on iOS and Android to find CPU hotspots and UI hangs. It also analyzes memory leaks on iOS.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add software-mansion/argent --skill argent-native-profiler -a claude-code
Open on GitHub

What argent-native-profiler does

argent-native-profiler guides an agent through recording and reading native performance traces. It surfaces CPU hotspots and UI hangs on iOS and Android. It also analyzes memory leaks on iOS. iOS uses xctrace; Android runs Perfetto through adb shell perfetto alongside an in-process WASM trace processor.

The app needs to be running first. native-profiler-start records, and native-profiler-stop exports the trace. Then native-profiler-analyze returns categorized bottlenecks. profiler-stack-query drills into call stacks and thread breakdowns; profiler-load reopens earlier sessions. Each stage has its own tool.

iOS requires Xcode command-line tools on PATH. Physical iPhones are unsupported, so that limits where you can profile an iOS app. Android call stacks require a debuggable app or <profileable android:shell="true"/> in its manifest. Android RSS growth is a memory-pressure signal, not a confirmed leak.

What it helps with

  • Find native functions that consume excessive CPU time
  • Locate what blocks the main thread during a UI hang
  • Inspect iOS leak stacks to identify responsible frames
  • Reopen a saved trace and compare the profile after a fix

Example prompts for the agent

  • Profile this iOS simulator run and find the UI hangs.
  • Trace the CPU hotspots in this Android app during this scenario.
  • Inspect the iOS leak stacks and identify the responsible frames.

How to install argent-native-profiler

1Skills CLI (Vercel)

npx skills add software-mansion/argent --skill argent-native-profiler -a claude-code

2Manually: put the files in place

~/.claude/skills/argent-native-profiler/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/argent-native-profiler/

From the same set15

The whole set →
argent-android-emulator-setup software-mansion This skill connects an Android emulator through argent MCP tools. Use it to find a device or boot an AVD before working with an Android UI. Claude Code CX Codex Cursor +1 26,500installs argent-react-native-optimization software-mansion Profiles React Native apps to pinpoint runtime bottlenecks and fixes mechanical code issues. It steps in when user screens stutter, startup lags, or re-renders spike. Claude Code CX Codex Cursor +1 26,400installs argent-react-native-profiler software-mansion Profiles a React Native Hermes app to measure re-renders and CPU use. Use it to compare a fix, find slow components, or inspect hotspots. Claude Code CX Codex Cursor +1 26,300installs argent-react-native-app-workflow software-mansion Provides step-by-step procedures for building, running, and debugging React Native apps on iOS simulators or Android emulators. Helps resolve Metro issues and build crashes. Claude Code CX Codex Cursor +1 26,300installs argent-ios-simulator-setup software-mansion A skill for connecting to an iOS simulator via argent MCP tools. Use it to find a booted simulator, get its UDID, and prepare for any interaction task. Claude Code CX Codex Cursor +1 26,300installs argent-metro-debugger software-mansion A skill that connects a debugger to a JS runtime via CDP. Inspect React components, read console logs, and evaluate code live. Works with React Native (iOS, Android, Vega) and Chromium apps (Electron, browsers). Claude Code CX Codex Cursor +1 26,200installs argent-test-ui-flow software-mansion A skill for autonomous iOS and Android UI testing in Claude Code. Runs interact-screenshot-verify loops through argent MCP tools to check flows and screens. Claude Code CX Codex Cursor +1 26,200installs argent-screenshot-diff software-mansion Compares before and after screenshots to catch layout shifts, spacing, color and text rendering changes. Claude Code CX Codex Cursor +1 24,900installs

Similar

flutter-expert https://github.com/Jeffallan Skill for building cross-platform apps with Flutter 3+ and Dart. Covers widgets, state management via Riverpod or Bloc, GoRouter navigation, and performance optimization. Claude Code CX Codex Cursor +1 14,300installs expo-router expo Skill for file-based routing, stacks, modals and tabs in Expo Router. Use it when building navigation in a React Native mobile app. Claude Code CX Codex Cursor +1 27,700installs expo-brownfield expo Embeds React Native and Expo into existing native iOS and Android apps. Useful when adding cross-platform screens to SwiftUI, UIKit, or Kotlin hosts. Claude Code CX Codex Cursor +1 27,700installs vercel-react-native-skills vercel A rules pack for React Native and Expo work: lists, animations, navigation, native modules. Load it so your agent makes mobile changes the same way every time. Claude Code CX Codex Cursor +1 253,900installs animate-expo emilkowalski Builds React Native and Expo animations using Reanimated and Gesture Handler. Helps keep motion on the UI thread and avoid dropped frames on physical devices. Claude Code CX Codex Cursor +1 135,900installs mobile-native emilkowalski Strips the tells that give a web app away on a phone: sticky hover, tap highlight flash, the 100vh bug. Claude Code CX Codex Cursor +1 84,500installs aso coreyhaines31 Audits App Store and Google Play listings against store optimization standards. Helps uncover gaps in metadata, visual assets, and conversion. Claude Code CX Codex Cursor +1 74,900installs swiftui-pro Paul Hudson Reviews SwiftUI code for deprecated APIs, data-flow issues, accessibility gaps, and performance concerns. Use it during feature work or code review. Claude Code CX Codex Cursor +1 35,000installs

Questions about argent-native-profiler

How do I install argent-native-profiler in Claude Code?

Run npx skills add software-mansion/argent --skill argent-native-profiler -a claude-code. The skill file is at ~/.claude/skills/argent-native-profiler/SKILL.md.

What does argent-native-profiler do?

It records and analyzes native traces to find CPU hotspots and UI hangs on iOS and Android. On iOS, it also analyzes memory leaks and lets you inspect call stacks.

Can I profile a physical iPhone?

No. Physical iPhones are unsupported, so use a simulator for iOS profiling. Xcode command-line tools must also be on PATH.

Source text

SKILL.md · Apache-2.0
---
name: argent-native-profiler
description: Native profiling for CPU hotspots, UI hangs, memory issues. iOS via xctrace; Android via Perfetto. Use when diagnosing native-level performance issues.
---

## 1. Tools

- `native-profiler-start`: start profiling on a booted device. iOS: xctrace recording for CPU, hangs, and leaks.
- `native-profiler-stop`: stop the profiler and export trace data to timestamped XML files.
- `native-profiler-analyze`: parse exported trace data and return a structured bottleneck payload.
- `profiler-stack-query`: drill into parsed data: hang stacks, function callers, thread breakdown, leak details.
- `profiler-load`: list and reload previous trace sessions from disk for re-investigation.
- Physical iPhone: not supported; use a simulator.

---

## 2. Platform Support

- **iOS**: Backend: Xcode Instruments via `xctrace` on a booted simulator or connected device. Requires Xcode command-line tools on PATH. Surfaces CPU hotspots, UI hangs, and memory leaks (instruments `Leaks` table).
- **Android**: Backend: Perfetto via `adb shell perfetto` + an in-process WASM trace-processor engine. Surfaces CPU hotspots and UI hangs, with per-hang jank reason codes, a main-thread state breakdown with `blocked_function` attribution, and a GC overlap annotation. Also reports an RSS-growth signal for memory pressure; treat it as a hint to confirm manually, not a confirmed leak. The target app must be debuggable or include `<profileable android:shell="true"/>` in its manifest for `perf_sample` callstacks to be captured.

---

## 3. Investigation Patterns

After `native-profiler-analyze` surfaces findings, use `profiler-stack-query` to drill into root causes:

- **Hang detected** → `profiler-stack-query` mode=`hang_stacks` for full native call chains → mode=`function_callers` for the suspected function → read native source.
- **CPU hotspot** → `profiler-stack-query` mode=`thread_breakdown` for per-thread distribution → mode=`function_callers` for the dominant function.
- **Memory leak** → `profiler-stack-query` mode=`leak_stacks` filtered by `object_type` for responsible frames and libraries.
  - iOS: if leaks come back unattributed (responsible frame `<Call stack limit reached>`), re-run `native-profiler-start` with `malloc_stack_logging: true`. This cold-launches the app with Malloc Stack Logging so leaks carry a real allocation backtrace (responsible frame + library). It restarts the app and adds overhead, so use it only when you need leak attribution, not for CPU/hang passes.

After presenting findings, ask the user whether to investigate further, implement fixes, or stop. After applying fixes, always re-profile the same scenario and compare with `profiler-load`. Report honestly whether the target metric improved, regressed, or stayed flat. If the fix showed no net benefit or introduced regressions elsewhere, say so and reconsider.

**Tip:** For reproducible before/after comparisons, record the interaction sequence as an e2e test using the `argent-create-e2e` skill before the first profiling run. Replay with `e2e-execute` on subsequent runs to eliminate interaction variance.

> **Note:** The `argent-react-native-profiler` instructs to start native profiling automatically alongside React profiling. This skill's workflow and investigation patterns apply in both cases.

---

## 4. Workflow

**Complete all steps in order; do not break mid-flow.**

### Step 0: Ensure the target app is running

The `native-profiler-start` tool **auto-detects** the running app on the device.
You do not need to derive `app_process` manually; just make sure the app is launched.

1. If the app is already running on the device, skip to Step 1 (do not pass `app_process`).
2. If the app is not running, use `launch-app` with the correct bundle ID first.
3. Only pass `app_process` explicitly if the tool reports multiple running user apps and you need to disambiguate.

> **Note**: If multiple build flavors are installed (dev, staging, prod), the tool will detect whichever one is currently running. If both are running, it will ask you to specify.

### Step 1: Start recording

Call `native-profiler-start` with `device_id` (iOS UDID or Android serial). The tool auto-detects the running app and saves the trace to `/tmp/argent-profiler-cwd/` with a timestamped filename.
Let the user interact with the app or drive interaction via simulator tools (see `argent-device-interact` skill).

### Step 2: Stop and export

Call `native-profiler-stop` with `device_id`. iOS sends SIGINT to xctrace, waits for trace packaging, and exports CPU, hangs, and leaks data to XML; check `exportDiagnostics` for any export warnings. Android sends SIGTERM to the on-device perfetto daemon, polls `/proc/<pid>` until it exits, then `adb pull`s the `.pftrace` to the host.

### Step 3: Analyze

Call `native-profiler-analyze` with `device_id`. Returns a markdown report with bottlenecks categorized as CPU hotspots, UI hangs, or memory leaks, sorted by severity.

### Step 4: Present findings and ask about next steps

Present a concise summary of the key findings. Then follow the "After analysis" guideline: ask whether to investigate further with query tools, implement fixes, or stop.

### Step 5: Drill-down investigation

Use `profiler-stack-query` to investigate specific findings. See §3 Investigation Patterns for chaining guidance.

### Step 6: Reload previous sessions

To revisit a previous trace:

1. Call `profiler-load` mode=`list` to see available sessions.
2. Call `profiler-load` mode=`load_native` session_id=`<timestamp>` device_id=`<UDID>` to re-parse the XML files.
3. Use `profiler-stack-query` to investigate the reloaded data.

---

## 5. Understanding Results

Bottlenecks are categorized by severity:

- **RED**: CPU functions taking >15% of total time, all UI hangs, and **attributed** memory leaks (those with a resolved responsible frame). These require immediate attention.
- **YELLOW**: CPU functions taking 3-15% of total time, and **unattributed** memory leaks (`<Call stack limit reached>`, no library; see the memory-leaks caveat below). Worth investigating but may be acceptable.

Each bottleneck type indicates a different class of problem:

- **CPU hotspots**: Native functions consuming excessive CPU time. Look for tight loops, expensive computations, or redundant work.
- **UI hangs**: Main thread blocked long enough to cause visible jank or unresponsiveness. Often caused by synchronous I/O, heavy layout passes, or lock contention.
- **Memory leaks**: Objects allocated but never freed. Common causes include retain cycles, unclosed resources, or forgotten observers. Argent records via `xctrace --attach`, which has no malloc-stack history, so on the simulator most leaks come back **unattributed** (`<Call stack limit reached>`, no library) and are dominated by benign system allocations; these are reported as a low-confidence YELLOW summary, not confirmed RED leaks. For attributed stacks, capture with malloc stack logging enabled at launch.

---

## 6. Important Caveats

- **Simulator vs device**: Simulator profiling reflects host Mac performance, not real device hardware. Use device profiling for accurate CPU timings and memory behavior.
- **xctrace availability (iOS)**: Requires Xcode command-line tools installed. Verify with `xcrun xctrace version`.
- **Profiler overhead**: xctrace instrumentation adds CPU load. If `JSLexer`, `JSONEmitter`, or Hermes runtime internals dominate the JS thread in CPU hotspot results, those reflect profiler overhead, not app work. Discount those entries when evaluating findings.
- **Run-to-run variance**: Small fluctuations in CPU percentages between runs are normal. Treat only consistent directional changes (across 2+ runs or >15% delta) as actionable signal.
- **Live data variability**: If the app fetches live API data, different responses between runs change rendering workload independently of code changes. Note when data-dependent screens show variance.

© software-mansion · Apache-2.0 · software-mansion/argent

See also

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