axiom-codex/skills/axiom-profile-performance/SKILL.md
Use when the user wants automated performance profiling, headless Instruments analysis, or CLI-based trace collection.
npx skillsauth add charleswiltgen/axiom axiom-profile-performanceInstall 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.
Note: This audit may use Bash commands to run builds, tests, or CLI tools.
You are an expert at automated performance profiling using xctrace CLI.
Measurement before optimization. Record actual performance data, analyze it programmatically, and provide actionable findings—all without requiring the Instruments GUI.
When the user requests performance profiling:
ALWAYS run these discovery commands FIRST:
# 1. Check for booted simulators
echo "=== Booted Simulators ==="
xcrun simctl list devices booted -j 2>/dev/null | jq -r '.devices | to_entries[] | .value[] | "\(.name) (\(.udid))"'
# 2. Find running apps in simulator (if any simulator is booted)
echo ""
echo "=== Running Simulator Apps ==="
BOOTED_UDID=$(xcrun simctl list devices booted -j 2>/dev/null | jq -r '.devices | to_entries[] | .value[0].udid // empty' | head -1)
if [ -n "$BOOTED_UDID" ]; then
xcrun simctl spawn "$BOOTED_UDID" launchctl list 2>/dev/null | grep UIKitApplication | head -10
else
echo "No booted simulator found"
fi
# 3. Check if user specified an app (look for common app processes)
echo ""
echo "=== Mac Apps (for reference) ==="
pgrep -lf "\.app" 2>/dev/null | grep -vE "com\.apple|Xcode|Simulator|Google|Chrome|Safari|Finder|Dock" | head -5
Ready to profile:
Need user input:
Choose the right instrument based on user request:
| User Says | Instrument | Time Limit |
|-----------|------------|------------|
| "CPU", "slow", "performance", "Time Profiler" | CPU Profiler | 10s |
| "memory", "allocations", "RAM" | Allocations | 30s |
| "leaks", "retain cycle" | Leaks | 30s |
| "SwiftUI", "view updates", "body" | SwiftUI | 10s |
| "launch", "startup", "cold start" | (special workflow) | n/a |
| "concurrency", "actors", "tasks" | Swift Tasks + Swift Actors | 10s |
| (unspecified) | CPU Profiler | 10s |
# Create temp directory for traces
TRACE_DIR="/tmp/axiom-traces"
mkdir -p "$TRACE_DIR"
# Get simulator UUID
SIMULATOR_UDID=$(xcrun simctl list devices booted -j | jq -r '.devices | to_entries[] | .value[0].udid' | head -1)
# Record trace (replace INSTRUMENT and APP_NAME)
xcrun xctrace record \
--instrument 'CPU Profiler' \
--device "$SIMULATOR_UDID" \
--attach 'APP_NAME' \
--time-limit 10s \
--no-prompt \
--output "$TRACE_DIR/profile.trace"
# For app launch profiling, use --launch instead of --attach
# First, find the app bundle
APP_PATH=$(find ~/Library/Developer/CoreSimulator/Devices/*/data/Containers/Bundle/Application -name "*.app" -type d 2>/dev/null | grep -i "AppName" | head -1)
# Or for Mac app
APP_PATH="/Applications/AppName.app"
# Record launch
xcrun xctrace record \
--instrument 'CPU Profiler' \
--time-limit 30s \
--no-prompt \
--output "$TRACE_DIR/launch.trace" \
--launch -- "$APP_PATH"
# For general system profiling (when no specific app)
xcrun xctrace record \
--instrument 'CPU Profiler' \
--device "$SIMULATOR_UDID" \
--all-processes \
--time-limit 10s \
--no-prompt \
--output "$TRACE_DIR/system.trace"
# First, check what data is available
echo "=== Available Tables ==="
xcrun xctrace export --input "$TRACE_DIR/profile.trace" --toc 2>&1 | grep -E '<table|schema'
# Export CPU profile data
xcrun xctrace export \
--input "$TRACE_DIR/profile.trace" \
--xpath '/trace-toc/run[@number="1"]/data/table[@schema="cpu-profile"]' \
> "$TRACE_DIR/cpu-profile.xml" 2>&1
Look for in the exported XML:
<cycle-weight> values# Quick analysis: Find processes with most samples
echo "=== Process Sample Counts ==="
grep -o 'process.*fmt="[^"]*"' "$TRACE_DIR/cpu-profile.xml" | sort | uniq -c | sort -rn | head -10
# Find most common function frames
echo ""
echo "=== Hot Functions ==="
grep -o 'name="[^"]*"' "$TRACE_DIR/cpu-profile.xml" | sort | uniq -c | sort -rn | head -20
Provide a clear, structured report:
## Performance Profile Results
### Recording Summary
- **Instrument**: [CPU Profiler/Allocations/Leaks/SwiftUI]
- **Target**: [App name or "All Processes"]
- **Device**: [Simulator name or "Mac"]
- **Duration**: [10s/30s]
- **Trace file**: [path]
### Key Findings
#### CRITICAL
- [Issue with highest impact]
#### HIGH
- [Significant issues]
#### MEDIUM
- [Notable patterns]
### Top Hot Functions
| Rank | Function | Samples | % of Total |
|------|----------|---------|------------|
| 1 | function_name | 150 | 15% |
| 2 | ... | ... | ... |
### Recommendations
1. [Specific actionable recommendation]
2. [Next investigation step]
### Next Steps
- To investigate further: [specific command or action]
- To open in Instruments GUI: `open [trace path]`
User requests profiling
↓
Run mandatory discovery (simulators, running apps)
↓
├─ User specified app name → Use that name
├─ Multiple options available → Ask user to choose
├─ No targets found → Help user boot simulator or specify app
↓
Determine instrument from user request
↓
├─ CPU/slow/performance → CPU Profiler
├─ Memory/allocations → Allocations
├─ Leaks → Leaks
├─ SwiftUI → SwiftUI
├─ Launch → Launch workflow
├─ Unspecified → CPU Profiler (default)
↓
Record trace (10-30s depending on instrument)
↓
Export to XML
↓
Analyze and report findings
| Error | Cause | Fix | |-------|-------|-----| | "Unable to attach to process" | App not running | Ask user to launch app first | | "No such device" | Wrong UDID | Re-run device discovery | | "Document Missing Template Error" | Used --template | Use --instrument instead | | Empty trace | No activity during recording | Ask user to interact with app during profile | | Permission denied | Privacy settings | Check System Preferences > Privacy |
If you encounter:
After analysis is complete:
# Offer to clean up traces
echo "Traces saved in: $TRACE_DIR"
echo "To open in Instruments: open '$TRACE_DIR/profile.trace'"
echo "To clean up: rm -rf '$TRACE_DIR'"
axiom-performance (skills/xctrace-ref.md) — Full xctrace CLI referenceaxiom-performance (skills/performance-profiling.md) — Manual Instruments workflowsaxiom-performance (skills/memory-debugging.md) — Memory leak diagnosisaxiom-swiftui — SwiftUI-specific profilingdevelopment
Use when building ANY watchOS app — app structure, independent apps, Watch Connectivity, Smart Stack widgets, complications, controls, RelevanceKit, background tasks, ClockKit migration.
development
Use when working with HealthKit, WorkoutKit, health data, workouts, or fitness features on iOS or watchOS. Covers permissions, queries, background delivery, custom workouts, multidevice coordination.
development
Use when building, fixing, or improving ANY SwiftUI UI — views, navigation, layout, animations, performance, architecture, gestures, debugging, iOS 26 features.
content-media
Use when working with camera, photos, audio, haptics, ShazamKit, or Now Playing. Covers AVCaptureSession, PHPicker, PhotosPicker, AVFoundation, Core Haptics, audio recognition, MediaPlayer, CarPlay, MusicKit.