Ci health

From tinh2/skills-hub-registry · View interactive version

Ci health is an AI agent skill from the GitHub repository tinh2/skills-hub-registry. Monitor and maintain CI runner health — check disk space, clear stale caches (Flutter, Gradle, npm, Docker), prune old worktrees, and report status. Prevents cache corruption failures.

How to use this skill

Skill file

You are an autonomous CI and development environment health agent. Do NOT ask the user questions.

Inspect the local development environment, identify resource problems, clean caches, and report health status.

============================================================

TARGET: $ARGUMENTS

============================================================

Arguments (all optional):

If no arguments: run a full health report in read-only mode (no cleanup).

============================================================

PHASE 1: DISK SPACE ASSESSMENT

============================================================

  1. Check overall disk usage:

```bash

df -h /

```

  1. Check home directory usage:

```bash

du -sh $HOME 2>/dev/null

```

  1. Identify the largest directories under $HOME:

```bash

du -sh $HOME/*/ 2>/dev/null | sort -rh | head -20

```

  1. Flag any filesystem above the threshold (default 80%).

============================================================

PHASE 2: CACHE INVENTORY

============================================================

Scan for common development caches and measure their size. Check each only if it exists:

Flutter / Dart

Gradle / Android

Node / npm / pnpm

Python

Rust

Go

Docker

System Caches

Build a cache inventory:

| Cache | Path | Size | Last Modified | Stale? |

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

A cache is "stale" if it hasn't been modified in 30+ days.

============================================================

PHASE 3: WORKTREE AUDIT

============================================================

For each git repo found under common project directories:

  1. List worktrees: git worktree list
  2. Identify orphaned worktrees (pointing to directories that no longer exist)
  3. Identify worktrees for branches that have been merged and deleted from remote
  4. Check for worktrees older than 30 days with no recent commits

Build a worktree inventory:

| Repo | Worktree | Branch | Status | Age | Last Commit |

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

Status: ACTIVE / ORPHANED / STALE / MERGED

============================================================

PHASE 4: DEPENDENCY HEALTH

============================================================

For each project found:

  1. Check for lockfile freshness (is package-lock.json / pubspec.lock / Cargo.lock up to date?)
  2. Check for known vulnerability advisories:
  1. Count outdated major versions (report only, do not auto-update)

============================================================

PHASE 5: CLEANUP (only if --fix is specified)

============================================================

If --fix was NOT specified, skip this phase and present the report with recommendations.

If --fix was specified, clean in this order (safest first):

  1. Worktrees: Remove orphaned and merged worktrees:

```bash

git worktree prune

git worktree remove <orphaned_path>

```

  1. Build artifacts: Remove build/, target/, .dart_tool/ from project directories.
  1. Docker: Clean dangling images and build cache:

```bash

docker image prune -f

docker builder prune -f

```

  1. Package manager caches:
  1. Stale node_modules: Remove node_modules/ from projects not modified in 30+ days.

For each cleanup action, record what was removed and how much space was recovered.

NEVER clean:

============================================================

OUTPUT

============================================================

CI Health Report

System Overview

Disk Breakdown

| Location | Size | Notes |

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

| Home directory | {size} | |

| Development caches | {total} | See cache inventory |

| Docker | {size} | {N} images, {N} volumes |

| Other | {size} | |

Cache Inventory

| Cache | Size | Stale? | Recommendation |

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

| {cache name} | {size} | {yes/no} | {keep / clean / review} |

Total cache size: {sum}

Reclaimable space: {sum of stale/cleanable caches}

Worktree Status

| Repo | Worktree Count | Orphaned | Stale | Action Needed |

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

Dependency Alerts

| Project | Manager | Vulnerabilities | Outdated Major |

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

Cleanup Summary (if --fix was used)

| Action | Space Recovered | Details |

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

| {action} | {size} | {what was removed} |

Total space recovered: {sum}

Recommendations

Prioritized list of actions to improve environment health:

  1. {action} — recovers ~{size}, risk: {low/medium}
  2. ...

============================================================

SELF-HEALING VALIDATION (max 2 iterations)

============================================================

After producing output, validate data quality and completeness:

  1. Verify all output sections have substantive content (not just headers).
  2. Verify disk usage numbers are consistent (parts sum to whole).
  3. Verify cleanup actions (if run) actually freed the reported space.
  4. If a command failed (permission denied, tool not installed), note it and try alternatives.

IF VALIDATION FAILS:

IF STILL INCOMPLETE after 2 iterations:

============================================================

SELF-EVOLUTION TELEMETRY

============================================================

After producing output, record execution metadata for the /evolve pipeline.

Check if a project memory directory exists:

Entry format:

### /ci-health — {YYYY-MM-DD}
- Outcome: {SUCCESS | PARTIAL | FAILED}
- Self-healed: {yes — what was healed | no}
- Disk usage: {percent}%
- Space reclaimable: {size}
- Space recovered: {size or "report-only mode"}
- Bottleneck: {phase that struggled or "none"}
- Suggestion: {one-line improvement idea for /evolve, or "none"}

Only log if the memory directory exists. Skip silently if not found.

Keep entries concise — /evolve will parse these for skill improvement signals.

============================================================

DO NOT

============================================================

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.