GitHub Audit
Comprehensive GitHub repo audit → auto-fix → quality gate → (confirmed) deploy → record.
Tracks decisions in .planning/github-audit-history.md for cross-run consistency.
allowed-tools above PRE-APPROVES safe/common tools (it does NOT restrict — every
tool stays callable). git push, gh pr merge, and any deploy command are
deliberately NOT pre-approved, and Phase 4 is gated by an explicit confirmation.
Run mode (from $ARGUMENTS)
$0 selects scope (default = full):
audit-only → Phases 0, 1, 5 only. Report findings; make NO changes, NO deploy.
fix → Phases 0–3 + 5. Fix + quality gate; STOP before deploy.
deploy or empty → all phases (Phase 4 still requires the confirmation gate).
Execution rules
- Auto-fix only safe/small items that match a Saved Policy; otherwise STOP and discuss via
AskUserQuestion.
- Quality gate: zero tolerance — fix ALL errors/warnings/failures (a known flaky test must pass in isolation to count as green).
- Deploy: sequential gates; each step must succeed before the next; never without the Phase 4 confirmation.
- Prefer a platform MCP/API over scraping CLI output when one is available (e.g. a hosting or backend MCP for deployment/env status).
Phase 0 — Initialize
- Read
.planning/github-audit-history.md (Saved Policies + last audits). If it has an IN_PROGRESS block, ask the user to resume or start fresh.
git remote -v, git branch --show-current. Derive owner/repo.
- Detect the project's toolchain (package manager + scripts) from
package.json, lockfiles, Makefile, or the CI config — don't assume one. Note the run mode. Record an IN_PROGRESS entry (timestamp + phase) in the history file.
Phase 1 — Audit (read-only; run checks in parallel)
- Security:
gh api repos/{o}/{r}/dependabot/alerts (open, by severity + package), .../code-scanning/alerts, .../secret-scanning/alerts.
- CI/CD:
gh api .../actions/workflows + recent gh run list; read each workflow YAML for stale matrices, missing perms, unpinned actions, broken auth secrets.
- Branch protection:
gh api .../branches/{default}/protection — required checks, strict, enforce_admins, force-push/deletions, reviews.
- PRs:
gh pr list --state open — categorize Dependabot (dev/patch = low, prod/major = high) vs human/bot.
- Community:
gh api .../community/profile + presence of SECURITY.md, CONTRIBUTING.md, CODE_OF_CONDUCT.md, templates, README, LICENSE.
- Traffic/activity: views/clones (flag anomalies), stars/forks, open issues.
- Config hygiene:
dependabot.yml ignore rules vs actual deps; linter ignore files; stale CI references.
Compute health score (rubric below) and a severity-tagged findings list (auto-fix / discuss / info).
Health rubric (start at 100, floor 0)
- secret-scanning alert: −20 each · critical dep alert: −15 · high: −8 · moderate: −3 · low: −1
- failing required CI on default branch: −15 · no branch protection: −10 · no required checks: −5 · missing SECURITY.md: −5
- community profile <100%: −(100−profile)/5 · open Dependabot PR >30d old: −2 each
Record
health_before; recompute health_after post-fix.
Phase 2 — Fix (skip if mode = audit-only)
- Auto-fix items matching a Saved Policy (community files, stale workflow config, stale ignore rules). Log each.
- Dependabot (Saved Policy seed): prefer a bulk dependency update via the project's package manager (
npm update / pnpm update / yarn upgrade — caret-safe) plus overrides for stubborn transitive CVEs, then run the audit (npm audit / pnpm audit / yarn npm audit) until clean; close the grouped Dependabot PRs as superseded rather than rebase-merging each. Confirm new policies with the user and save them.
- Discuss (via
AskUserQuestion) anything medium/breaking: production major bumps, permission/branch-protection changes, anything that could break the build. Offer to save each decision as a policy.
Phase 3 — Quality gate (skip if mode = audit-only)
Run the project's quality scripts (detect them from package.json scripts / Makefile / CI), then fix and loop until clean. Typical order:
- typecheck 2. test 3. build (e.g.
npm run typecheck && npm test && npm run build, adapting to the detected commands)
- A failing test that's a known parallel-flake: re-run it in isolation; an isolated pass counts as green.
- Never suppress warnings — fix them. Stuck after 3 attempts → stop and ask.
Phase 4 — Deploy (only if mode = deploy/empty; otherwise STOP and report)
CONFIRMATION GATE (mandatory): before any push/deploy, present an AskUserQuestion summarizing exactly: files to commit, the commit message, whether it pushes to the default branch, and whether a deploy will run. Proceed only on explicit approval (honor any "always deploy"/"never auto-deploy" Saved Policy).
Then, sequentially (stop on any failure):
- Commit — stage only audit-changed files:
git add <files> → git commit. Skip if nothing changed.
- Push —
git push origin <branch>; verify with git status.
- Backend/migration deploy — CONDITIONAL: only if the change touches backend/infra that needs a separate deploy step (a backend service, DB migrations, etc.). Otherwise skip (frontend-only changes usually don't need it). Run the project's documented deploy command.
- Verify the hosting deploy — if the repo auto-deploys on push (e.g. a connected hosting provider), confirm the deployment reached a ready/healthy state via the platform's MCP, CLI, or dashboard. Report the final URL + status.
Phase 5 — Record & prune
Append an Audit N entry and prune to the last 3 full audits (preserve Saved Policies; compress older to one-line summaries). Full template + rules: see reference/history-format.md.
Then report: health before→after, what was fixed, deploy status, deferred items.
Error handling
| Situation |
Action |
| GitHub API fails |
gh auth status; retry once; then report |
| Quality gate loops >3× |
Stop; show what's failing; ask |
| Deploy step fails |
Stop immediately; do NOT proceed; report |
| Resumed run (IN_PROGRESS) |
Re-read checkpoint sub-steps; guard against double commit/push/deploy (verify the commit isn't already pushed) before re-running Phase 4 |
| History file missing/corrupted |
Back up; create fresh structure; warn |
| No remote |
Help add one or skip remote-dependent checks |
1---2name: github-audit3description: Audit GitHub repo health, auto-fix safe issues, run quality gates, deploy, and record decisions across runs. Use when asked to audit a repo, check repo/CI/dependency health, run pre-deploy quality checks, or ship after an audit.4---56# GitHub Audit78Comprehensive GitHub repo audit → auto-fix → quality gate → (confirmed) deploy → record.9Tracks decisions in `.planning/github-audit-history.md` for cross-run consistency.1011> `allowed-tools` above PRE-APPROVES safe/common tools (it does NOT restrict — every12> tool stays callable). `git push`, `gh pr merge`, and any deploy command are13> deliberately NOT pre-approved, and Phase 4 is gated by an explicit confirmation.1415## Run mode (from `$ARGUMENTS`)1617`$0` selects scope (default = full):18- **`audit-only`** → Phases 0, 1, 5 only. Report findings; make NO changes, NO deploy.19- **`fix`** → Phases 0–3 + 5. Fix + quality gate; STOP before deploy.20- **`deploy`** or empty → all phases (Phase 4 still requires the confirmation gate).2122## Execution rules23- Auto-fix only safe/small items that match a Saved Policy; otherwise STOP and discuss via `AskUserQuestion`.24- Quality gate: zero tolerance — fix ALL errors/warnings/failures (a known flaky test must pass in isolation to count as green).25- Deploy: sequential gates; each step must succeed before the next; **never** without the Phase 4 confirmation.26- Prefer a platform MCP/API over scraping CLI output when one is available (e.g. a hosting or backend MCP for deployment/env status).2728---2930## Phase 0 — Initialize311. Read `.planning/github-audit-history.md` (Saved Policies + last audits). If it has an `IN_PROGRESS` block, ask the user to **resume** or **start fresh**.322. `git remote -v`, `git branch --show-current`. Derive `owner/repo`.333. Detect the project's toolchain (package manager + scripts) from `package.json`, lockfiles, `Makefile`, or the CI config — don't assume one. Note the run mode. Record an `IN_PROGRESS` entry (timestamp + phase) in the history file.3435## Phase 1 — Audit (read-only; run checks in parallel)36- **Security:** `gh api repos/{o}/{r}/dependabot/alerts` (open, by severity + package), `.../code-scanning/alerts`, `.../secret-scanning/alerts`.37- **CI/CD:** `gh api .../actions/workflows` + recent `gh run list`; read each workflow YAML for stale matrices, missing perms, unpinned actions, broken auth secrets.38- **Branch protection:** `gh api .../branches/{default}/protection` — required checks, strict, enforce_admins, force-push/deletions, reviews.39- **PRs:** `gh pr list --state open` — categorize Dependabot (dev/patch = low, prod/major = high) vs human/bot.40- **Community:** `gh api .../community/profile` + presence of SECURITY.md, CONTRIBUTING.md, CODE_OF_CONDUCT.md, templates, README, LICENSE.41- **Traffic/activity:** views/clones (flag anomalies), stars/forks, open issues.42- **Config hygiene:** `dependabot.yml` ignore rules vs actual deps; linter ignore files; stale CI references.4344Compute **health score** (rubric below) and a severity-tagged findings list (auto-fix / discuss / info).4546### Health rubric (start at 100, floor 0)47- secret-scanning alert: −20 each · critical dep alert: −15 · high: −8 · moderate: −3 · low: −148- failing required CI on default branch: −15 · no branch protection: −10 · no required checks: −5 · missing SECURITY.md: −549- community profile <100%: −(100−profile)/5 · open Dependabot PR >30d old: −2 each50Record `health_before`; recompute `health_after` post-fix.5152## Phase 2 — Fix *(skip if mode = audit-only)*53- **Auto-fix** items matching a Saved Policy (community files, stale workflow config, stale ignore rules). Log each.54- **Dependabot (Saved Policy seed):** prefer a **bulk dependency update** via the project's package manager (`npm update` / `pnpm update` / `yarn upgrade` — caret-safe) plus overrides for stubborn transitive CVEs, then run the audit (`npm audit` / `pnpm audit` / `yarn npm audit`) until clean; **close the grouped Dependabot PRs as superseded** rather than rebase-merging each. Confirm new policies with the user and save them.55- **Discuss** (via `AskUserQuestion`) anything medium/breaking: production major bumps, permission/branch-protection changes, anything that could break the build. Offer to save each decision as a policy.5657## Phase 3 — Quality gate *(skip if mode = audit-only)*58Run the project's quality scripts (detect them from `package.json` scripts / `Makefile` / CI), then fix and loop until clean. Typical order:591. typecheck 2. test 3. build *(e.g. `npm run typecheck && npm test && npm run build`, adapting to the detected commands)*60- A failing test that's a known parallel-flake: re-run it in isolation; an isolated pass counts as green.61- Never suppress warnings — fix them. Stuck after 3 attempts → stop and ask.6263## Phase 4 — Deploy *(only if mode = deploy/empty; otherwise STOP and report)*64**CONFIRMATION GATE (mandatory):** before any push/deploy, present an `AskUserQuestion` summarizing exactly: files to commit, the commit message, whether it pushes to the default branch, and whether a deploy will run. Proceed only on explicit approval (honor any "always deploy"/"never auto-deploy" Saved Policy).6566Then, sequentially (stop on any failure):671. **Commit** — stage only audit-changed files: `git add <files>` → `git commit`. Skip if nothing changed.682. **Push** — `git push origin <branch>`; verify with `git status`.693. **Backend/migration deploy — CONDITIONAL:** only if the change touches backend/infra that needs a separate deploy step (a backend service, DB migrations, etc.). Otherwise skip (frontend-only changes usually don't need it). Run the project's documented deploy command.704. **Verify the hosting deploy** — if the repo auto-deploys on push (e.g. a connected hosting provider), confirm the deployment reached a ready/healthy state via the platform's MCP, CLI, or dashboard. Report the final URL + status.7172## Phase 5 — Record & prune73Append an `Audit N` entry and prune to the **last 3 full audits** (preserve Saved Policies; compress older to one-line summaries). Full template + rules: see [reference/history-format.md](reference/history-format.md).7475Then report: health before→after, what was fixed, deploy status, deferred items.7677---7879## Error handling80| Situation | Action |81|---|---|82| GitHub API fails | `gh auth status`; retry once; then report |83| Quality gate loops >3× | Stop; show what's failing; ask |84| Deploy step fails | Stop immediately; do NOT proceed; report |85| Resumed run (IN_PROGRESS) | Re-read checkpoint sub-steps; **guard against double commit/push/deploy** (verify the commit isn't already pushed) before re-running Phase 4 |86| History file missing/corrupted | Back up; create fresh structure; warn |87| No remote | Help add one or skip remote-dependent checks |