macos-perf
Activity Monitor, Instruments, top/htop, memory pressure, thermal state, powermetrics, profiling
What this skill does
# macos-perf
## Purpose
This skill enables monitoring and profiling macOS system performance using native tools, focusing on CPU, memory, thermal, and power metrics to identify bottlenecks and optimize applications.
## When to Use
Use this skill for diagnosing high CPU usage in apps, investigating memory leaks, profiling resource-intensive processes, checking thermal states during heavy workloads, or analyzing power consumption on macOS devices.
## Key Capabilities
- Monitor real-time system metrics via Activity Monitor or `top/htop` for CPU, memory, and network usage.
- Profile applications with Instruments, capturing detailed traces for CPU, memory, and energy.
- Check memory pressure using `vm_stat` to detect low-memory conditions.
- Query thermal state via `powermetrics` for CPU/GPU temperatures and fan speeds.
- Analyze power metrics with `powermetrics` to measure battery drain and efficiency.
- Use command-line tools like `top -o cpu` for sorted process lists or `instruments -s devices` for available templates.
## Usage Patterns
Invoke this skill in scripts for automated monitoring or integrate into AI workflows for real-time analysis. For example, run periodic checks in a loop for server-like macOS setups, or trigger profiling when an app exceeds resource thresholds. Always specify exact tools and flags based on the task; e.g., use `top` for quick views and Instruments for deep dives. If integrating with automation, export data to JSON for parsing.
## Common Commands/API
- Use `top -o cpu -s 1` to display processes sorted by CPU usage, updating every second; pipe output to `grep` for filtering, e.g., `top -o cpu | grep "MyApp"`.
- Check memory pressure with `vm_stat | grep "Pages"` to get free pages; sample code:
```
output = subprocess.run(['vm_stat'], capture_output=True).stdout
free_pages = int(re.search(r'free:\s+(\d+)', output.decode()).group(1))
```
- Run `powermetrics --samplers cpu,thermal -i 1000` for CPU and thermal data every 1 second.
- Launch Instruments via CLI: `instruments -w <device> -t Time Profiler -D output.trace /path/to/app`; use exported .trace files for analysis.
- For thermal state, use `ioreg -l | grep "Ambient" ` to parse ambient temperature from system registry.
- No API keys required for these tools; they run natively on macOS.
## Integration Notes
Integrate by wrapping commands in Python or shell scripts; set environment variables for custom paths, e.g., export `INSTRUMENTS_PATH=/Applications/Xcode.app/Contents/Developer/usr/bin/instruments`. For data export, use `plutil` to convert .plist outputs to JSON. If combining with other skills, ensure macOS version compatibility (e.g., Instruments requires Xcode); check via `sw_vers -productVersion`. Avoid running multiple intensive tools simultaneously to prevent resource contention.
## Error Handling
Check command exit codes; for example, if `top` fails, verify with `echo $?` and handle by logging errors or retrying. For Instruments, parse stderr for messages like "Template not found" and fallback to alternatives. Use try-except in scripts, e.g.:
```
try:
result = subprocess.run(['instruments', '-t', 'Time Profiler'], check=True)
except subprocess.CalledProcessError as e:
print(f"Error: {e.returncode} - {e.output}")
```
Common issues include permission errors (run with sudo) or missing dependencies (install Xcode command line tools via `xcode-select --install`).
## Concrete Usage Examples
1. To monitor CPU usage of a specific process: Run `top -pid <processID> -o cpu` in a loop script, then analyze output to alert if usage > 80%; example script line: `while true; do top -pid 1234 -l 1 | grep CPU; sleep 5; done`.
2. For profiling an app's memory: Use `instruments -t Allocations -D profile.trace /Applications/MyApp.app`, then open the trace in Instruments GUI to identify leaks; integrate by scripting: `instruments ... && open profile.trace`.
## Graph Relationships
- Related to: macos cluster (e.g., macos-core for basic system ops), performance tag (links to general profiling skills), profiling tag (connects to app optimization tools).
- Dependencies: Requires macos cluster skills for foundational access; no direct API links.
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.