Diagnosing mac performance

From rianvdm/product-ai-public · View interactive version

Diagnosing mac performance is an AI agent skill from the GitHub repository rianvdm/product-ai-public. Use when the Mac is slow, hot, or loud, or the user asks what's using CPU, memory, or battery.

How to use this skill

Skill file

Diagnosing Mac Performance Issues

When to Use

Steps

  1. Snapshot system state — run these in parallel:

```bash

# Top processes by CPU

ps -eo pid,pcpu,pmem,comm -r | head -25

# System overview (load avg, memory, swap)

top -l 1 -n 1 -stats pid,command,cpu | head -10

# Memory pressure and swap

sysctl vm.swapusage && memory_pressure

```

  1. Triage into CPU-bound vs memory-bound:
  1. For CPU hogs — identify the category:

| Process type | Normal range | Investigate if | Common fix |

|-------------|-------------|----------------|------------|

| WindowServer | 10-20% | >35% sustained | Usually driven by another app doing excessive redraws. Fix the other app. |

| contactsd / AddressBookManager | <2% | >10% | Stuck sync loop. Check error logs, disable problematic account sync (Gmail CardDAV is a known offender). |

| mds / mds_stores / mdworker | <5% each | >20% or many workers | Spotlight indexing. Usually transient after updates. sudo mdutil -i off / to pause if urgent. |

| kernel_task | varies | >200% | Thermal throttling. Not fixable via software — machine needs cooling. |

| nsurlsessiond / cloudd | <5% | >15% | iCloud sync stuck. Check System Settings > Apple ID > iCloud. |

| trustd | <1% | >10% | Certificate validation loop. Often clears on reboot. |

| Electron apps (Discord, Slack, VS Code, Windsurf) | 2-5% each | >15% | Restart the app. Electron apps leak memory over time. |

  1. For memory pressure — assess severity:

```bash

# Quick summary

sysctl vm.swapusage

# Detailed breakdown

memory_pressure

```

| Indicator | Healthy | Warning | Critical |

|-----------|---------|---------|----------|

| Swap used | <500 MB | 500 MB - 2 GB | >2 GB |

| Compressor | <2 GB | 2-5 GB | >5 GB |

| Pages free | >20,000 | 5,000-20,000 | <5,000 |

| Free percentage | >30% | 10-30% | <10% |

If critical: recommend quitting the heaviest apps. List them with memory percentages so the user can make an informed choice.

  1. For runaway system daemons — pull error logs:

```bash

/usr/bin/log show --predicate 'process == "<daemon_name>" AND (messageType == 16 OR messageType == 17)' --last 5m --style compact 2>&1 | head -50

```

  1. Report findings using this structure:

Top resource consumers:

| Process | CPU % | RAM % | Status |

|---------|-------|-------|--------|

| contactsd | 124% | 0.9% | Stuck — sync loop (see below) |

| WindowServer | 47% | 0.7% | Elevated — driven by contactsd churn |

Memory pressure: Critical — 15 GB / 16 GB used, 4.3 GB swap, 6.5 GB compressor

Diagnosis: contactsd is in a sync error loop caused by [root cause]. This is stuck, not transient.

Recommended fixes (least to most disruptive):

1. [First option]

2. [Second option]

3. [Nuclear option, if applicable]

Adapt the structure to fit — skip sections that don't apply, add detail where it matters. The key is: show the data, state the diagnosis, order the fixes.

Gotcha Section

Constraints

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.