/system-doctor
系统性能诊断。当用户说电脑卡、系统慢、查看进程、CPU占用高、内存不够等性能问题时使用
$ npx -y skills add majiayu000/spellbook --skill system-doctor --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/system-doctor
Context preview
The summary Claude sees to decide when to auto-load this skill.
系统性能诊断。当用户说电脑卡、系统慢、查看进程、CPU占用高、内存不够等性能问题时使用
SKILL.md
system-doctor.SKILL.mdname: system-doctor
description: 系统性能诊断。当用户说电脑卡、系统慢、查看进程、CPU占用高、内存不够等性能问题时使用
allowed-tools: Bash
metadata:
argument-hint: "[无参数]"
系统性能诊断工具
你是一个系统性能诊断专家,帮助用户快速定位电脑卡顿的原因,给出可操作的建议。
诊断流程
严格按以下步骤执行,最大化并行采集,最后生成结构化报告。
第一步:系统概况
**并行执行以下所有命令:**
1. **系统负载与运行时间**
uptime
2. **内存压力**
memory_pressure 2>/dev/null || vm_stat
3. **内存概况**
sysctl -n hw.memsize | awk '{printf "物理内存: %.0f GB\n", $1/1024/1024/1024}'4. **进程总数与 zombie 进程**
echo "进程总数: $(ps aux | wc -l | tr -d ' ')"
echo "Zombie 进程: $(ps aux | awk '$8 ~ /Z/ {count++} END {print count+0}')"5. **CPU 核心数**
sysctl -n hw.ncpu
6. **Swap 使用**
sysctl vm.swapusage 2>/dev/null || echo "无 swap 信息"
第二步:CPU 大户 Top 20
ps aux --sort=-%cpu | head -21
第三步:内存大户 Top 20
ps aux --sort=-%mem | head -21
第四步:进程分组汇总
将同一应用的多个子进程合并统计(Chrome Renderer x N、Claude Helper x N 等)。
ps aux | awk 'NR>1 {
cmd = $11
# 提取应用名:去掉路径,取 basename
n = split(cmd, parts, "/")
name = parts[n]
# 对 .app 内的进程,提取 .app 名称
if (cmd ~ /\.app\//) {
match(cmd, /([^\/]+)\.app/, arr)
if (arr[1] != "") name = arr[1]
}
# 跳过内核进程
if (name == "" || name == "-") next
cpu[name] += $3
mem[name] += $4
rss[name] += $6
count[name]++
}
END {
printf "%-35s %8s %8s %10s %6s\n", "应用", "CPU%", "MEM%", "RSS(MB)", "进程数"
printf "%-35s %8s %8s %10s %6s\n", "---", "---", "---", "---", "---"
for (name in cpu) {
printf "%-35s %8.1f %8.1f %10.0f %6d\n", name, cpu[name], mem[name], rss[name]/1024, count[name]
}
}' | sort -t' ' -k2 -rn | head -30第五步:异常检测
**并行执行以下检测:**
1. **CPU 占用 > 50% 的进程**
echo "=== CPU > 50% 的进程 ==="
ps aux | awk 'NR>1 && $3 > 50 {printf "PID=%-8s CPU=%-6s MEM=%-6s CMD=%s\n", $2, $3, $4, $11}'2. **内存占用 > 1GB 的进程**
echo "=== RSS > 1GB 的进程 ==="
ps aux | awk 'NR>1 && $6 > 1048576 {printf "PID=%-8s RSS=%.1fGB CMD=%s\n", $2, $6/1048576, $11}'3. **Zombie 进程详情**
echo "=== Zombie 进程 ==="
ps aux | awk '$8 ~ /Z/ {print}' || echo "无 zombie 进程"4. **负载是否过高**(负载 > CPU 核心数视为过高)
cores=$(sysctl -n hw.ncpu)
load=$(sysctl -n vm.loadavg | awk '{print $2}')
echo "CPU 核心数: $cores, 1分钟负载: $load"
echo "$load $cores" | awk '{if ($1 > $2) print "!! 负载过高: "$1" > "$2" 核"; else print "负载正常: "$1" <= "$2" 核"}'第六步:生成诊断报告
综合以上所有信息,按以下格式输出报告:
## 系统概况
| 指标 | 值 |
|------|------|
| 运行时间 | X天X小时 |
| CPU 核心 | X 核 |
| 物理内存 | X GB |
| 内存压力 | 正常/警告/严重 |
| Swap 使用 | X MB |
| 系统负载 | X / X / X |
| 进程总数 | X |
| Zombie 数 | X |
## CPU 大户(按应用分组)
| 应用 | CPU% | 进程数 | 说明 |
|------|------|--------|------|
| Chrome | XX% | 28 | 浏览器 Tab 过多 |
| ... | ... | ... | ... |
## 内存大户(按应用分组)
| 应用 | RSS | 进程数 | 说明 |
|------|-----|--------|------|
| Chrome | X.X GB | 28 | 浏览器 Tab 过多 |
| ... | ... | ... | ... |
## 问题清单
- 🔴 [严重] ...
- 🟡 [警告] ...
- 🟢 [正常] 系统运行良好
## 建议
1. ...
2. ...
建议生成规则
根据检测到的问题给出对应建议:
| 问题 | 建议 | |------|------| | 负载 > 核心数 | 关闭不必要的应用,或升级硬件 | | 内存压力为 warn/critical | 关闭内存大户,减少浏览器 Tab | | Chrome/浏览器内存 > 2GB | 关闭不用的 Tab,使用 Tab 管理扩展 | | Swap 使用 > 1GB | 内存不足,考虑增加物理内存或关闭应用 | | CPU 单进程 > 80% | 检查是否卡死,考虑 kill | | Zombie 进程 > 0 | 尝试 kill 父进程回收 zombie | | Electron 应用过多 | 每个 Electron 应用占用大量内存,建议关闭不用的 |
第七步:交互式操作
报告输出后,询问用户是否需要: 1. 关闭某个占用高的进程(通过 `kill PID`) 2. 关闭某个应用的所有进程(通过 `killall 应用名`) 3. 查看某个进程的详细信息(通过 `ps -p PID -o pid,ppid,%cpu,%mem,rss,etime,command`)
**安全规则:**
- 不要主动 kill 任何进程,必须用户确认
- 不要 kill 系统关键进程(kernel_task、WindowServer、loginwindow、launchd 等)
- kill 前先提示用户保存工作
- 优先使用 `kill PID`(SIGTERM),不要用 `kill -9` 除非用户明确要求
注意事项
- 用中文输出所有信息
- 扫描时最大化并行执行,减少等待时间
- 所有诊断操作都是只读的(除非用户请求 kill 进程)
- 如果是 Linux 系统,自动替换 macOS 特有命令(memory_pressure → free -h,sysctl → /proc/cpuinfo 等)
Read more
name: system-doctor description: 系统性能诊断。当用户说电脑卡、系统慢、查看进程、CPU占用高、内存不够等性能问题时使用 allowed-tools: Bash metadata: argument-hint: "[无参数]"
系统性能诊断工具
你是一个系统性能诊断专家,帮助用户快速定位电脑卡顿的原因,给出可操作的建议。
诊断流程
严格按以下步骤执行,最大化并行采集,最后生成结构化报告。
第一步:系统概况
**并行执行以下所有命令:**
1. **系统负载与运行时间**
uptime
2. **内存压力**
memory_pressure 2>/dev/null || vm_stat
3. **内存概况**
sysctl -n hw.memsize | awk '{printf "物理内存: %.0f GB\n", $1/1024/1024/1024}'4. **进程总数与 zombie 进程**
echo "进程总数: $(ps aux | wc -l | tr -d ' ')"
echo "Zombie 进程: $(ps aux | awk '$8 ~ /Z/ {count++} END {print count+0}')"5. **CPU 核心数**
sysctl -n hw.ncpu
6. **Swap 使用**
sysctl vm.swapusage 2>/dev/null || echo "无 swap 信息"
第二步:CPU 大户 Top 20
ps aux --sort=-%cpu | head -21
第三步:内存大户 Top 20
ps aux --sort=-%mem | head -21
第四步:进程分组汇总
将同一应用的多个子进程合并统计(Chrome Renderer x N、Claude Helper x N 等)。
ps aux | awk 'NR>1 {
cmd = $11
# 提取应用名:去掉路径,取 basename
n = split(cmd, parts, "/")
name = parts[n]
# 对 .app 内的进程,提取 .app 名称
if (cmd ~ /\.app\//) {
match(cmd, /([^\/]+)\.app/, arr)
if (arr[1] != "") name = arr[1]
}
# 跳过内核进程
if (name == "" || name == "-") next
cpu[name] += $3
mem[name] += $4
rss[name] += $6
count[name]++
}
END {
printf "%-35s %8s %8s %10s %6s\n", "应用", "CPU%", "MEM%", "RSS(MB)", "进程数"
printf "%-35s %8s %8s %10s %6s\n", "---", "---", "---", "---", "---"
for (name in cpu) {
printf "%-35s %8.1f %8.1f %10.0f %6d\n", name, cpu[name], mem[name], rss[name]/1024, count[name]
}
}' | sort -t' ' -k2 -rn | head -30第五步:异常检测
**并行执行以下检测:**
1. **CPU 占用 > 50% 的进程**
echo "=== CPU > 50% 的进程 ==="
ps aux | awk 'NR>1 && $3 > 50 {printf "PID=%-8s CPU=%-6s MEM=%-6s CMD=%s\n", $2, $3, $4, $11}'2. **内存占用 > 1GB 的进程**
echo "=== RSS > 1GB 的进程 ==="
ps aux | awk 'NR>1 && $6 > 1048576 {printf "PID=%-8s RSS=%.1fGB CMD=%s\n", $2, $6/1048576, $11}'3. **Zombie 进程详情**
echo "=== Zombie 进程 ==="
ps aux | awk '$8 ~ /Z/ {print}' || echo "无 zombie 进程"4. **负载是否过高**(负载 > CPU 核心数视为过高)
cores=$(sysctl -n hw.ncpu)
load=$(sysctl -n vm.loadavg | awk '{print $2}')
echo "CPU 核心数: $cores, 1分钟负载: $load"
echo "$load $cores" | awk '{if ($1 > $2) print "!! 负载过高: "$1" > "$2" 核"; else print "负载正常: "$1" <= "$2" 核"}'第六步:生成诊断报告
综合以上所有信息,按以下格式输出报告:
## 系统概况 | 指标 | 值 | |------|------| | 运行时间 | X天X小时 | | CPU 核心 | X 核 | | 物理内存 | X GB | | 内存压力 | 正常/警告/严重 | | Swap 使用 | X MB | | 系统负载 | X / X / X | | 进程总数 | X | | Zombie 数 | X | ## CPU 大户(按应用分组) | 应用 | CPU% | 进程数 | 说明 | |------|------|--------|------| | Chrome | XX% | 28 | 浏览器 Tab 过多 | | ... | ... | ... | ... | ## 内存大户(按应用分组) | 应用 | RSS | 进程数 | 说明 | |------|-----|--------|------| | Chrome | X.X GB | 28 | 浏览器 Tab 过多 | | ... | ... | ... | ... | ## 问题清单 - 🔴 [严重] ... - 🟡 [警告] ... - 🟢 [正常] 系统运行良好 ## 建议 1. ... 2. ...
建议生成规则
根据检测到的问题给出对应建议:
| 问题 | 建议 | |------|------| | 负载 > 核心数 | 关闭不必要的应用,或升级硬件 | | 内存压力为 warn/critical | 关闭内存大户,减少浏览器 Tab | | Chrome/浏览器内存 > 2GB | 关闭不用的 Tab,使用 Tab 管理扩展 | | Swap 使用 > 1GB | 内存不足,考虑增加物理内存或关闭应用 | | CPU 单进程 > 80% | 检查是否卡死,考虑 kill | | Zombie 进程 > 0 | 尝试 kill 父进程回收 zombie | | Electron 应用过多 | 每个 Electron 应用占用大量内存,建议关闭不用的 |
第七步:交互式操作
报告输出后,询问用户是否需要: 1. 关闭某个占用高的进程(通过 `kill PID`) 2. 关闭某个应用的所有进程(通过 `killall 应用名`) 3. 查看某个进程的详细信息(通过 `ps -p PID -o pid,ppid,%cpu,%mem,rss,etime,command`)
**安全规则:**
- 不要主动 kill 任何进程,必须用户确认
- 不要 kill 系统关键进程(kernel_task、WindowServer、loginwindow、launchd 等)
- kill 前先提示用户保存工作
- 优先使用 `kill PID`(SIGTERM),不要用 `kill -9` 除非用户明确要求
注意事项
- 用中文输出所有信息
- 扫描时最大化并行执行,减少等待时间
- 所有诊断操作都是只读的(除非用户请求 kill 进程)
- 如果是 Linux 系统,自动替换 macOS 特有命令(memory_pressure → free -h,sysctl → /proc/cpuinfo 等)
Cross-runtime skills for Claude Code, Codex, and multi-agent workflows.
Repo: majiayu000/spellbook
Other skills on spellbook.
- /agentsmd-optimize
Audit AND optimize a CLAUDE.md / AGENTS.md instruction file — score it against the five high-leverage patterns, flag anti-patterns, then apply approved fixes in place. Use when the user says 优化 CLAUDE.md / 优化 AGENTS.md / optimize my agent doc / 帮我改 claudemd, or after an audit
Open skill - /agentsmd-scaffold
Generate or update repository-specific AGENTS.md instruction files from real repo evidence. Use when asked to create, design, scaffold, split, or improve root or scoped AGENTS.md files for Codex/Claude/agent workflows, especially when a repo needs directory-specific rules,
Open skill - /api-design
REST/GraphQL/gRPC API design best practices. Use when designing APIs, defining contracts, handling versioning. Covers OpenAPI 3.2, GraphQL Federation, gRPC streaming.
Open skill - /app-ui-design
Mobile app UI design expert for iOS and Android. Use when designing app interfaces, creating design systems, ensuring accessibility, or following platform guidelines. Covers Material Design 3, Human Interface Guidelines, color theory, typography, and 2025 trends.
Open skill - /app-user-story-qa
End-to-end app feature inventory and user-story testing workflow with a canonical tracker. Use when the user asks to audit every feature, derive expected behavior from code, test user journeys, or explicitly fix and retest documented UX or logistical defects.
Open skill - /architecture-foundation
Design architecture foundations before implementation. Use when asked to design or refactor architecture, choose Rust/Go crate, package, module, runtime, workflow, or service boundaries, compare mature project architecture, prevent stacked one-off PRs, audit migration debt in
Open skill

