--- name: github-org-audit description: > This skill should be used when the user asks to "audit my repos", "clean up the org", "which repos are stale", "what open PRs do we have", "find exposed secrets", "repo health check", "triage the org", "which repos are missing READMEs", or wants a cross-repository sweep of an organization or account. Also triggers on "org audit", "repo inventory", "dead repos", and "security sweep". metadata: version: "0.1.0" --- # Org-Wide Repo Audit Sweep every repository under an owner and return a ranked, actionable cleanup list — not a data dump. ## Inventory first `search_repositories` with `org:` or `user:`, `minimal_output: false`, `perPage: 100`, paginating until exhausted. Owner-qualified queries work; bare keyword queries do not. Add `fork:true` to include forks — omitting it silently drops them. Record per repo: name, private/public, default branch, `updated_at`, `pushed_at`, open issues count, archived flag, fork flag, stars. State the total count found. If it is far below what the user expects, the token's scope is the cause — a read-only OAuth app sees only public personal repos. Say that instead of reporting a clean bill of health on an incomplete set. ## Audit dimensions Run these in parallel across the inventory. For an org with 50+ repos, fan out with subagents by repo batch rather than serially. **Staleness** — `pushed_at` older than 180 days and not archived. These should be archived or deleted; an unarchived dead repo still shows up in searches and dependency graphs. **Abandoned work** — open PRs older than 30 days (`list_pull_requests` state `open`, sorted by created), and branches with no PR whose last commit is older than 90 days. Both are merge-conflict debt accruing interest. **Secret exposure** — `run_secret_scanning` where available. Additionally `search_code` across the owner for high-signal patterns: `ghp_`, `github_pat_`, `hf_`, `sk-`, `AKIA`, `PRIVATE KEY`, `SUPABASE_SERVICE_ROLE`, `.env` files committed to the tree. A hit here outranks every other finding in this audit. **Dependency risk** — Dependabot alerts by severity (`dependabot` toolset). Report Critical and High only; Moderate and Low are noise at org scale. **Code scanning** — open code-scanning alerts, Critical and High only. **Hygiene** — missing README, missing LICENSE, missing description, no topics, no default branch protection on repos with more than one contributor, `.github/workflows` present but last run failed. **Duplication** — near-identical repo names or descriptions (forks of the same upstream, `-copy`, `-old`, `-backup`, hash-suffixed names). These are usually accidental and safe to consolidate. ## Ranking Order the output by expected cost of inaction, not by severity label: 1. Exposed live credential — rotate immediately, named repo and file path. 2. Critical dependency or code-scanning alert on a repo that is actually deployed. 3. Missing branch protection on a production repo. 4. Open PR older than 90 days on an active repo. 5. Stale/dead repo to archive. 6. Cosmetic hygiene gaps, batched into one line. A finding without a named repo and a next action does not belong in the output. ## Output format A table for the ranked findings, then a short "batch actions" section listing the fixes that can be applied in bulk (archive these 12, add README to these 8). Offer to execute the batch — do not execute it unprompted. Archiving is not reversible from this session. Close with the count of repos scanned versus the count the token could see, so the coverage gap is explicit. ## Cost discipline An org sweep can consume enormous context. Keep `minimal_output: true` on every search that is not the initial inventory, cap `perPage` at 100, never read file contents during the sweep — search only — and summarize per repo to a single row before moving on. If the owner has more than 100 repos, confirm scope with the user before starting.