system-health-check
# System Health Check & Cleanup Skill
What this skill does
# System Health Check & Cleanup Skill
**Version**: 1.0.0
**Category**: System Administration / Performance Optimization
**Author**: Claude Code
**Last Updated**: November 22, 2025
## Overview
Automated system health monitoring and cleanup workflow. Diagnoses performance issues, identifies resource bottlenecks, fixes orphaned services, kills stale processes, and cleans cache bloat. Designed for archimedes (32c/125GB) but works on any Linux system.
## Features
### 1. **System Diagnostics**
- Memory usage (free, used, buffers, cache)
- Disk usage (mounted filesystems)
- CPU load average and core count
- Process analysis (top CPU/memory consumers)
- Service health (running, failed, crashed)
- Systemd journal errors
### 2. **Issue Detection**
- **Crash loops**: Services repeatedly failing to start
- **Orphaned services**: Missing directories/executables
- **Process age**: Long-running claude/python processes (>15 min)
- **Cache bloat**: Large development caches (pip, go-build, npm)
- **Failed services**: Systemd units in failed state
- **Log spam**: Error entries in journal (potential I/O bottlenecks)
### 3. **Automated Cleanup**
- Disable crashing services
- Kill old claude/python processes
- Clean development caches:
- pip cache (18GB typical)
- go-build cache (3.3GB typical)
- Mozilla/Firefox (1.5GB typical)
- Playwright browsers (126MB typical)
- Electron cache (442MB typical)
- Wave Terminal updater (150MB typical)
- Vacuum systemd journal
- Reload systemd configuration
### 4. **Performance Metrics**
- Before/after disk space comparison
- Memory efficiency improvements
- Load average reduction
- Process count normalization
## Usage
### Quick Health Check (No Changes)
```bash
/system-health
```
**Output**: Comprehensive diagnosis showing:
- Memory/disk/CPU status
- Top resource consumers
- Failed services
- Cache sizes
- Recommendations
### Full Cleanup (Automated Fix)
```bash
/system-cleanup
```
**Output**:
- Disables crashing services
- Kills processes >15 min old
- Cleans all caches
- Optimizes journal
- Shows before/after metrics
- Confirms all fixes applied
## Real-World Example
### Scenario: System Glitching After Extended Uptime
**Before Cleanup**:
```
Load: 1.41 (with crash loop)
Memory: 6.4GB / 125GB used
Disk: 275GB / 915GB (32%)
Cache: 25GB
Processes: 80+ including stale claude instances
Failed Services: backend-api looping every 5 seconds
Journal Size: 1.2GB with error spam
```
**Issues Detected**:
- ❌ backend-api.service fails every 5 seconds (directory missing)
- ❌ 2 claude processes: 50% CPU, 21% CPU (14+ min old)
- ❌ 23GB cache bloat (pip, go-build, mozilla)
- ❌ Log spam from repeated service restarts
**After Cleanup**:
```
Load: 0.96 (smooth operation)
Memory: 6.4GB / 125GB used
Disk: 250GB / 915GB (29%) — 25GB freed
Cache: 2GB
Processes: 45 (lean system)
Failed Services: None
Journal Size: 100MB (optimized)
```
**Results**: ✅ Glitching eliminated, system responsive, 25GB freed
## Skill Parameters
### Scope
- **diagnosis-only**: Check health without changes
- **safe-cleanup**: Disable services + kill old processes
- **full-cleanup**: Includes cache purging (default)
### Output Format
- **summary**: Table format (concise)
- **detailed**: Full command output
- **json**: Machine-readable metrics
### Process Age Threshold
- Default: 15 minutes
- Configurable per run
- Only kills claude/python processes (safe)
## Technical Details
### Service Crash Detection
Monitors for:
- `Restart=on-failure` loops (5 second intervals)
- Missing WorkingDirectory or ExecStart paths
- `systemctl list-units --failed` status
- journalctl error spam from same PID
### Cache Cleanup Strategy
**Safe to clean (zero impact)**:
- pip cache (regenerated on first pip command)
- go-build cache (rebuilt on compilation)
- Mozilla/Firefox cache (recreated automatically)
- Playwright browsers (downloaded on first use)
- Electron updates (downloaded if needed)
**Not touched**:
- project dependencies (venv/)
- user data (Documents, Downloads, Projects)
- git repositories
- configuration files
### Process Cleanup
**Kills only**:
- claude processes >15 min old
- Not in use by active terminal
- Confirmed via STAT field (Sl+ = active, Sl = background)
**Preserves**:
- System services (systemd, kernel)
- Active shells (pts, tty)
- Essential daemons (nginx, mysql, etc.)
## Integration with Other Skills
### With memory-keeper
```
System Health Check → Detects issues
→ Reports to /update-memory
→ Triggers cleanup
→ Saves results to CLAUDE.md
```
### With development workflows
```
Before running long jobs:
/system-health (check capacity)
↓
After long jobs:
/system-cleanup (reclaim resources)
↓
Continue development
```
## Output Examples
### Diagnostic Output
```
=== SYSTEM HEALTH REPORT ===
Memory: 6.4GB / 125GB (5% used) ✓
Disk: 250GB / 915GB (29%) ✓
CPU Cores: 32 (load avg: 0.96) ✓
TOP PROCESSES:
1. claude (pts/1) 46.7% CPU - 10 min old ⚠ OLD
2. claude (pts/3) 33.6% CPU - 1 min old ✓
3. firefox 12.7% CPU
4. syncthing 6.5% CPU
5. kitty 3.2% CPU
ISSUES DETECTED:
❌ backend-api.service crash loop (5s restart interval)
❌ claude process PID 3663 is 10+ minutes old
⚠ Cache at 25GB (pip: 18GB, go-build: 3.3GB)
✓ No failed systemd services
RECOMMENDATIONS:
1. Run /system-cleanup to fix all issues
2. Consider increasing cache cleanup frequency
3. Monitor CPU usage if claude processes >50%
```
### Cleanup Summary
```
=== CLEANUP COMPLETE ===
✅ Disabled backend-api.service
✅ Killed 1 old claude process (PID 3663, age 15+ min)
✅ Cleaned pip cache (18GB freed)
✅ Cleaned go-build (3.3GB freed)
✅ Cleaned firefox cache (1.5GB freed)
✅ Cleaned playwright (126MB freed)
✅ Cleaned electron (442MB freed)
✅ Vacuumed journal to 100MB
BEFORE:
Disk: 275GB (32%)
Cache: 25GB
Load: 1.41
AFTER:
Disk: 250GB (29%) — 25GB freed ✅
Cache: 2GB — 23GB freed ✅
Load: 0.96 — smoother ✅
System responsive and optimized!
```
## Troubleshooting
### Issue: Permission Denied on Cache Cleanup
**Solution**: Skill uses askpass helper for sudo auth
- Automatically configured via SUDO_ASKPASS
- Falls back to interactive prompt if helper fails
### Issue: Can't Kill Processes (EPERM)
**Solution**: Process is owned by root or system
- Skill only targets user-owned processes
- System services skipped for safety
### Issue: Service Disabled But Still Running
**Solution**: Service may have been started manually
```bash
systemctl --user stop backend-api.service
systemctl --user disable backend-api.service
```
## Performance Impact
### Runtime
- **Diagnostic only**: ~5 seconds
- **Process cleanup**: ~10 seconds
- **Full cleanup with caches**: ~30-60 seconds
### System Impact
- Non-blocking (spawns background processes)
- I/O intensive during cache deletion (expected)
- Safe to run during active development
## Parameters & Customization
### Command: `/system-health`
- `--verbose`: Show all processes and services
- `--format json`: Output JSON metrics
- `--threshold 30`: Change process age to 30 minutes
### Command: `/system-cleanup`
- `--keep-caches`: Skip cache cleanup
- `--keep-processes`: Skip process cleanup
- `--dry-run`: Show what would be deleted (no changes)
## Known Limitations
1. **Single machine**: Works on archimedes; euclid requires euclid-specific cleanup
2. **Development-focused**: Assumes standard development environment layout
3. **No backup verification**: Deleted caches cannot be recovered (but regenerate automatically)
4. **Sudo required**: Needs passwordless sudo or askpass configured
## Future Enhancements
- [ ] Real-time performance monitoring dashboard
- [ ] Automatic cleanup scheduling (systemd timer)
- [ ] Remote monitoring (euclid + vegetius)
- [ ] Custom cleanup rules (YAML config)
- [ ] Docker/container support
- [ ] Trend analysis (track cleanup frequency)
## References
### System ARelated 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.