In the last post, I shared my diagnose-mac function that dumps CPU, memory, thermal, and powermetrics output into Gemini CLI so it can tell me which process is cooking my laptop. It worked great until I hit my gemini-3.1-pro-preview limits for the day. Then the whole flow broke.
I wanted to keep the exact same one-command workflow even when Pro was exhausted. So I updated the script to support both Pro and Flash models, with a simple flag switch and an optional clipboard mode.
The Updated diagnose-mac Function
The new version keeps three ideas in mind:
- Default to Pro. Use
gemini-3.1-pro-previewwhen there is quota. - Fall back fast. Use
--flashto switch togemini-3.1-flash-previewwhen Pro is tapped out. - Optional clipboard. Use
-cor--copy-datato just capture the full diagnostics blob into the clipboard if you want to paste it into another tool.
# Load shared shell functions
source ~/.zsh_functions
# diagnose-mac history
# 2026-03-09: v1, Pro-only version with optional --copy-data flag
# 2026-03-13: v2, add --flash / --pro model switches and keep clipboard flag
diagnose-mac () {
local copy_to_clipboard=false
local model="gemini-3.1-pro-preview" # Default model
# Parse arguments
while [[ "$#" -gt 0 ]]; do
case "$1" in
-c | --copy-data)
copy_to_clipboard=true
shift
;;
--flash)
model="gemini-3.1-flash-preview"
shift
;;
--pro)
model="gemini-3.1-pro-preview"
shift
;;
*)
echo "Unknown option: $1"
return 1
;;
esac
done
echo "Collecting diagnostic data (requires sudo for powermetrics)..."
echo "Using model: $model"
local diagnostics
diagnostics=$(
echo -e "Please figure out what's wrong with my computer. Why is it running hot and/or slow today, and why are the fans acting up? Are there any CPU or RAM hogs?\n\n"
echo -e "<output cmd="top_cpu">\n$(top -l 2 -o cpu -n 15)\n</output>\n"
echo -e "<output cmd="top_mem">\n$(top -l 1 -o mem -n 15)\n</output>\n"
echo -e "<output cmd="pmset">\n$(pmset -g therm)\n</output>\n"
echo -e "<output cmd="powermetrics">\n$(sudo powermetrics -n 1)\n</output>"
)
if [ "$copy_to_clipboard" = true ]; then
echo "$diagnostics" | pbcopy
echo "Data saved to clipboard."
fi
cd /tmp && echo "$diagnostics" | gemini -m "$model" -p "Analyze these diagnostics for performance issues using your deep reasoning/thinking capabilities. Identify the specific PID or process causing issues."
echo -e "\nAnalysis complete."
}
How I Actually Use It
On a normal day, I just run:
diagnose-mac
The script gathers all the metrics, sends them to Gemini Pro, and tells me exactly which PID is misbehaving. If I see Pro hitting its daily limit, I can immediately fall back to Flash without changing anything else in my workflow:
diagnose-mac --flash
And if Gemini CLI itself is being flaky or I want to paste the blob into another tool (or a web interface), I can run:
diagnose-mac --copy-data
That copies the entire diagnostics payload to the clipboard so I can drop it straight into a chat window without rerunning top or powermetrics.
Enjoyed this post?
Get notified when I publish something new. No spam, unsubscribe anytime.