finops-overview

📁 laurigates/claude-plugins 📅 4 days ago
1
总安装量
1
周安装量
#48251
全站排名
安装命令
npx skills add https://github.com/laurigates/claude-plugins --skill finops-overview

Agent 安装分布

mcpjam 1
claude-code 1
replit 1
junie 1
windsurf 1
zencoder 1

Skill 文档

/finops:overview

Display a quick FinOps summary including org-level billing (if admin) and current repository workflow/cache statistics.

Context

  • Current repo: !gh repo view --json nameWithOwner --jq '.nameWithOwner' 2>/dev/null
  • Repo org/owner: !gh repo view --json owner --jq '.owner.login' 2>/dev/null

Parameters

Parameter Description Default
org GitHub organization name Current repo’s owner

Execution

1. Determine organization:

If $1 provided, use it. Otherwise extract from current repo:

ORG="${1:-$(gh repo view --json owner --jq '.owner.login')}"

2. Org-level billing (may fail if not admin):

echo "=== Org Billing: $ORG ==="
gh api /orgs/$ORG/settings/billing/actions \
  --jq '"Minutes: \(.total_minutes_used)/\(.included_minutes) included, \(.total_paid_minutes_used) paid"'

3. Org-level cache usage:

echo ""
echo "=== Org Cache Usage ==="
gh api /orgs/$ORG/actions/cache/usage \
  --jq '"\(.total_active_caches_count) caches, \(.total_active_caches_size_in_bytes / 1024 / 1024 | floor)MB total"'

4. Current repo stats (if in a repo):

REPO=$(gh repo view --json nameWithOwner --jq '.nameWithOwner')

echo ""
echo "=== Repo: $REPO ==="

# Cache usage
echo "Cache:"
gh api "/repos/$REPO/actions/cache/usage" \
  --jq '"  \(.active_caches_count) caches, \(.active_caches_size_in_bytes / 1024 / 1024 | floor)MB"'

# Recent workflow runs (last 30 days)
echo ""
echo "Workflows (last 30 days):"
gh api "/repos/$REPO/actions/runs?per_page=100" \
  --jq '.workflow_runs | group_by(.name) |
        map({name: .[0].name, runs: length,
             success: ([.[] | select(.conclusion == "success")] | length),
             failure: ([.[] | select(.conclusion == "failure")] | length),
             skipped: ([.[] | select(.conclusion == "skipped")] | length)}) |
        sort_by(-.runs)[] |
        "  \(.name): \(.runs) runs (\(.success) ok, \(.failure) fail, \(.skipped) skip)"'

5. Quick waste indicators:

echo ""
echo "=== Waste Indicators ==="

# Count skipped runs
SKIPPED=$(gh api "/repos/$REPO/actions/runs?per_page=100" \
  --jq '[.workflow_runs[] | select(.conclusion == "skipped")] | length')
TOTAL=$(gh api "/repos/$REPO/actions/runs?per_page=100" --jq '.workflow_runs | length')

echo "Skipped runs: $SKIPPED/$TOTAL"

# Check for missing concurrency in workflow files
if [ -d ".github/workflows" ]; then
  MISSING_CONCURRENCY=$(ls .github/workflows/*.yml .github/workflows/*.yaml 2>/dev/null | while read f; do
    grep -L "concurrency:" "$f" 2>/dev/null
  done | wc -l | tr -d ' ')
  echo "Workflows missing concurrency: $MISSING_CONCURRENCY"
fi

Output Format

=== Org Billing: orgname ===
Minutes: 1234/2000 included, 0 paid

=== Org Cache Usage ===
45 caches, 2340MB total

=== Repo: orgname/reponame ===
Cache:
  12 caches, 450MB

Workflows (last 30 days):
  CI: 45 runs (40 ok, 3 fail, 2 skip)
  Deploy: 12 runs (12 ok, 0 fail, 0 skip)
  CodeQL: 30 runs (28 ok, 0 fail, 2 skip)

=== Waste Indicators ===
Skipped runs: 4/87
Workflows missing concurrency: 2

Post-actions

Suggest next steps based on findings:

  • High skipped runs → /finops:waste
  • High cache usage → /finops:caches
  • Want detailed workflow analysis → /finops:workflows
  • Compare across repos → /finops:compare