jarekmor

pop_os-skill

Mar 12th, 2026
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 11.20 KB | None | 0 0
  1. # Claude Code Prompt: Build Pop!_OS Diagnosis Skill
  2.  
  3. Paste this entire prompt into Claude Code to build your `popos-diagnosing` skill.
  4.  
  5. ---
  6.  
  7. ## PROMPT START
  8.  
  9. I want to create a Claude Code skill called `popos-diagnosing` for deep system diagnosis on Pop!_OS 24.04 LTS (COSMIC DE, Ubuntu 24.04 base). My main problem right now is unexplained high CPU usage, but I want the skill to cover a comprehensive set of subsystems.
  10.  
  11. Please build this skill following Anthropic's official skill authoring best practices:
  12. - SKILL.md with proper YAML frontmatter (name, description in third person)
  13. - Progressive disclosure architecture: metadata → SKILL.md body → bundled references
  14. - Concise descriptions that trigger reliably
  15. - Bundled reference files for each diagnostic domain
  16. - Python/bash scripts where deterministic steps are needed
  17.  
  18. ---
  19.  
  20. ### SKILL GOAL
  21.  
  22. The skill must guide Claude to perform structured, expert-level Linux system diagnosis on Pop!_OS 24.04 LTS, covering:
  23.  
  24. 1. **CPU** — high usage root-cause analysis (the priority problem)
  25. 2. **RAM & Swap** — pressure, OOM events, swap usage patterns
  26. 3. **I/O Pressure** — disk latency, I/O wait, scheduler analysis
  27. 4. **NVIDIA GPU** — utilization, VRAM, temperature, driver health, process attribution
  28. 5. **Systemd & Services** — failed units, zombie processes, runaway services
  29. 6. **Kernel & Logs** — dmesg anomalies, journald errors, audit events
  30. 7. **Pop!_OS–specific** — COSMIC DE process health, system76-scheduler, pop-upgrade status, firmware (fwupd)
  31. 8. **eBPF/Advanced** — flame graph generation, off-CPU analysis, scheduler latency (optional deep-dive)
  32.  
  33. ---
  34.  
  35. ### DIAGNOSTIC METHODOLOGY
  36.  
  37. For each subsystem, the skill should apply Brendan Gregg's **USE Method** (Utilization, Saturation, Errors) as the analytical framework. Tools to use per domain:
  38.  
  39. **CPU:**
  40. ```bash
  41. # Tier 1 – quick triage
  42. top -b -n1 -o %CPU | head -20
  43. ps aux --sort=-%cpu | head -20
  44. mpstat -P ALL 1 5
  45. pidstat -u 1 5
  46.  
  47. # Tier 2 – scheduler & runqueue
  48. runqlat          # from bcc-tools
  49. runqlen          # from bcc-tools
  50. perf stat -a sleep 5
  51.  
  52. # Tier 3 – flame graphs (deep-dive)
  53. sudo perf record -F 99 -ag -- sleep 30
  54. sudo perf script | stackcollapse-perf.pl | flamegraph.pl > cpu-flame.svg
  55.  
  56. # eBPF one-liners
  57. sudo bpftrace -e 'profile:hz:99 { @[kstack] = count(); } interval:s:10 { print(@); exit(); }'
  58. sudo execsnoop   # catch short-lived CPU-spike processes
  59. ```
  60.  
  61. **RAM & Swap:**
  62. ```bash
  63. free -h
  64. vmstat -s
  65. cat /proc/meminfo | grep -E 'MemTotal|MemFree|Buffers|Cached|SwapTotal|SwapFree|Dirty|Writeback'
  66. swapon --show
  67. sudo slabtop -o          # kernel slab cache
  68. sudo bpftrace -e 'tracepoint:oom:mark_victim { printf("OOM killed: %s PID %d\n", comm, pid); }'
  69. journalctl -k | grep -i 'oom\|killed process'
  70. ```
  71.  
  72. **I/O Pressure:**
  73. ```bash
  74. iostat -xz 1 5
  75. iotop -bod 5 -n 3
  76. cat /proc/pressure/io     # PSI (Pressure Stall Information)
  77. cat /proc/pressure/cpu
  78. cat /proc/pressure/memory
  79. sudo biolatency -m        # from bcc-tools: I/O latency histogram
  80. sudo biosnoop             # per-operation I/O tracing
  81. sudo biotop               # top processes by I/O
  82. lsblk -o NAME,MODEL,ROTA,SCHED,SIZE,MOUNTPOINT
  83. cat /sys/block/*/queue/scheduler
  84. ```
  85.  
  86. **NVIDIA GPU:**
  87. ```bash
  88. nvidia-smi
  89. nvidia-smi --query-gpu=timestamp,name,temperature.gpu,utilization.gpu,utilization.memory,memory.total,memory.free,memory.used,power.draw,pstate --format=csv -l 5
  90. nvidia-smi pmon -s u      # per-process utilization
  91. nvtop                     # interactive GPU monitor (apt install nvtop)
  92. journalctl -k | grep -i nvidia
  93. dmesg | grep -i 'nvidia\|gpu\|xid'   # Xid errors = GPU hardware issues
  94. ```
  95.  
  96. **Systemd & Services:**
  97. ```bash
  98. systemctl --failed
  99. systemctl list-units --state=failed
  100. journalctl -p err -b      # errors since last boot
  101. journalctl -p warning -b --no-pager | tail -50
  102. ps aux | awk '$8 == "Z"'  # zombie processes
  103. systemd-analyze blame | head -20
  104. systemd-analyze critical-chain
  105. ```
  106.  
  107. **Kernel & Logs:**
  108. ```bash
  109. dmesg -T --level=err,warn | tail -50
  110. journalctl -k -b -p warning --no-pager | tail -50
  111. last reboot
  112. uptime
  113. uname -r
  114. ```
  115.  
  116. **Pop!_OS–Specific:**
  117. ```bash
  118. # COSMIC DE process health
  119. ps aux | grep -E 'cosmic|pop-shell|system76'
  120. systemctl --user status cosmic-session 2>/dev/null || true
  121.  
  122. # system76-scheduler (CPU scheduler tuning daemon)
  123. systemctl status system76-scheduler
  124. journalctl -u system76-scheduler -b --no-pager | tail -20
  125.  
  126. # Pop!_OS upgrade daemon
  127. systemctl status pop-upgrade
  128. journalctl -u pop-upgrade -b --no-pager | tail -20
  129.  
  130. # Firmware
  131. fwupdmgr get-updates 2>/dev/null | head -20
  132.  
  133. # NVIDIA driver on Pop (uses system76 NVIDIA scripts)
  134. ls /etc/X11/ | grep nvidia
  135. prime-select query 2>/dev/null || echo "PRIME not available"
  136. ```
  137.  
  138. ---
  139.  
  140. ### SKILL STRUCTURE TO BUILD
  141.  
  142. ```
  143. popos-diagnosing/
  144. ├── SKILL.md                        # frontmatter + orchestration logic
  145. └── references/
  146.     ├── cpu-diagnosis.md            # CPU deep-dive procedures
  147.     ├── memory-swap-diagnosis.md    # RAM/swap procedures
  148.     ├── io-pressure-diagnosis.md    # I/O PSI procedures
  149.     ├── nvidia-diagnosis.md         # GPU procedures
  150.     ├── systemd-logs-diagnosis.md   # services/journal procedures
  151.     └── popos-specific.md           # COSMIC/system76 procedures
  152. ```
  153.  
  154. ---
  155.  
  156. ### SKILL.md FRONTMATTER REQUIREMENTS
  157.  
  158. ```yaml
  159. ---
  160. name: popos-diagnosing
  161. description: >
  162.   Diagnoses Pop!_OS 24.04 LTS (COSMIC DE) system performance issues covering CPU,
  163.   RAM, swap, I/O pressure, NVIDIA GPU, systemd services, kernel logs, and
  164.   Pop!_OS-specific components (system76-scheduler, pop-upgrade, COSMIC DE).
  165.   Use this skill whenever the user mentions high CPU usage, slowdowns, GPU issues,
  166.   system hangs, kernel errors, memory pressure, swap thrashing, I/O wait, failed
  167.   services, dmesg errors, or any Pop!_OS/COSMIC DE problem. Also trigger for
  168.   general Linux performance diagnosis or "my system feels slow" on Ubuntu-based systems.
  169. ---
  170. ```
  171.  
  172. ---
  173.  
  174. ### SKILL ORCHESTRATION LOGIC (SKILL.md body)
  175.  
  176. The SKILL.md body should instruct Claude to:
  177.  
  178. 1. **Triage first** — run a fast 60-second snapshot across all subsystems to identify which area needs deep-dive (never run all deep-dive commands at once)
  179. 2. **Apply USE Method** — for the identified hotspot, check Utilization → Saturation → Errors in order
  180. 3. **Progressive depth** — Tier 1 (built-in tools: top, free, iostat), Tier 2 (bcc-tools: biolatency, runqlat), Tier 3 (eBPF: bpftrace, flame graphs) — only escalate if Tier 1 is inconclusive
  181. 4. **Check prerequisites** — verify tool availability before running (`which bpftrace`, `dpkg -l bcc-tools`)
  182. 5. **Summarize findings** — produce a structured report: Problem | Evidence | Likely Cause | Recommended Fix
  183. 6. **High CPU priority path** — when "high CPU" is the complaint, start with `execsnoop` (catches short-lived processes that vanish before `top` sees them), then `runqlat`, then flame graph
  184.  
  185. ---
  186.  
  187. ### INSTALL PREREQUISITES SCRIPT
  188.  
  189. The skill should include guidance to install missing tools:
  190.  
  191. ```bash
  192. # Essential triage tools (always available on Pop!_OS)
  193. # top, ps, vmstat, iostat (sysstat), free, dmesg, journalctl, systemctl
  194.  
  195. # Install extended tools if missing
  196. sudo apt update
  197. sudo apt install -y \
  198.   sysstat \          # iostat, mpstat, pidstat, sar
  199.   iotop \            # I/O top
  200.   htop \             # enhanced top
  201.   nvtop \            # GPU top
  202.   bpfcc-tools \      # biolatency, biosnoop, runqlat, execsnoop, etc.
  203.   bpftrace \         # eBPF one-liners
  204.   linux-tools-common \  # perf
  205.   linux-tools-$(uname -r) \  # kernel-specific perf
  206.   flamegraph         # flame graph generation (or install from GitHub)
  207. ```
  208.  
  209. ---
  210.  
  211. ### HIGH CPU DIAGNOSIS DECISION TREE
  212.  
  213. Include this in the skill as a decision tree Claude should follow:
  214.  
  215. ```
  216. Is CPU high?
  217. ├── Is it user-space or kernel? (us% vs sy% in top/mpstat)
  218. │   ├── USER-SPACE HIGH
  219. │   │   ├── Run execsnoop → catch short-lived bursts
  220. │   │   ├── Run ps aux --sort=-%cpu → identify top consumer
  221. │   │   ├── Run pidstat -u 1 10 → confirm sustained usage
  222. │   │   └── Generate CPU flame graph for that PID
  223. │   └── KERNEL HIGH (sy% high)
  224. │       ├── Check runqlat → scheduler saturation?
  225. │       ├── Check biolatency → I/O blocking?
  226. │       ├── Check dmesg for kernel errors
  227. │       └── Run bpftrace kernel stack profiler
  228. ├── Is iowait% high? (wa% in top)
  229. │   └── → Switch to I/O Pressure diagnosis path
  230. ├── Is softirq/interrupt high? (si/hi% in top)
  231. │   └── → Check /proc/interrupts, network driver issues, NVIDIA IRQ
  232. └── Is it a specific time pattern?
  233.     └── Check cron jobs, systemd timers: systemctl list-timers
  234. ```
  235.  
  236. ---
  237.  
  238. ### NVIDIA-SPECIFIC HIGH CPU CORRELATION
  239.  
  240. Include this because NVIDIA drivers on Linux often cause CPU spikes:
  241.  
  242. ```bash
  243. # Check if nvidia kernel module is causing CPU overhead
  244. cat /proc/interrupts | grep -i nvidia
  245. # Check Xorg GPU usage
  246. nvidia-smi pmon -s u -d 5
  247. # Check for Xid (GPU error) events which can trigger CPU recovery
  248. dmesg | grep -i 'Xid'
  249. # Common Xid codes: Xid 31 = GPU MMU fault, Xid 79 = GPU hung
  250. ```
  251.  
  252. ---
  253.  
  254. ### OUTPUT FORMAT
  255.  
  256. The skill should instruct Claude to produce findings in this structure:
  257.  
  258. ```
  259. ## Pop!_OS System Diagnosis Report
  260.  
  261. ### Triage Summary
  262. | Subsystem | Status | Key Metric |
  263. |-----------|--------|------------|
  264. | CPU       | 🔴 HIGH | 94% user, pid 1234 (firefox) |
  265. | RAM       | 🟡 OK   | 12.4/16 GB, 2.1 GB swap |
  266. | I/O       | 🟢 OK   | <5ms latency |
  267. | GPU       | 🟢 OK   | 23% util, 55°C |
  268.  
  269. ### Root Cause Analysis
  270. **Subsystem:** CPU
  271. **Evidence:** [command output]
  272. **Likely Cause:** [explanation]
  273. **Recommended Fix:** [actionable steps]
  274.  
  275. ### Commands Run
  276. [list of commands executed]
  277. ```
  278.  
  279. ---
  280.  
  281. ### TEST CASES TO VALIDATE THE SKILL
  282.  
  283. After building the skill, please test it with these prompts:
  284.  
  285. 1. `"My Pop!_OS system has very high CPU usage and I can't find which process is causing it"`
  286. 2. `"System feels sluggish, how do I check if it's RAM or swap pressure?"`
  287. 3. `"My NVIDIA GPU temperature is very high on Pop!_OS, how do I investigate?"`
  288. 4. `"Several systemd services are failing on my Pop!_OS 24.04, help me diagnose"`
  289. 5. `"I'm getting dmesg kernel errors on Pop!_OS, help me understand them"`
  290. 6. `"How do I generate a CPU flame graph on Pop!_OS to find what's using CPU?"`
  291.  
  292. ---
  293.  
  294. ### SKILL AUTHORING CONSTRAINTS (follow strictly)
  295.  
  296. - Keep SKILL.md body under 500 lines; put domain details in `references/` files
  297. - Description must be in **third person** (not "I can help you...")
  298. - Only ~100 tokens loaded at startup (name + description metadata)
  299. - Full SKILL.md loads only when triggered; reference files load on demand
  300. - Include `when to read` annotations on each reference file pointer in SKILL.md
  301. - Never assume tools are installed — always check with `which <tool>` first
  302. - For commands requiring sudo, note it explicitly and explain why
  303.  
  304. Please build the complete skill directory, write all reference files, and then run the test cases above to validate it works correctly. Start with the SKILL.md and the CPU and GPU reference files first, as those cover my immediate problem.
  305.  
  306. ## PROMPT END
Advertisement
Add Comment
Please, Sign In to add comment