agentleFS
thinkyou0714thinkyou0714/github-flow-kit/gh-pr-perm-audit/SKILL.md

gh-pr-perm-audit

Skill0 starsChanged 5 months agoMITView on GitHub

Security-first audit of the per-repo GitHub setting "Allow GitHub Actions to create and approve pull requests" (can_approve_pull_request_reviews) across an account. Flags repos where Actions CAN approve PRs — a required-review bypass risk (OpenSSF) — unless you intentionally allow them. Read-only: it never changes settings; it prints the exact gh command for you to run. Use when you ask: "audit Actions PR permissions", "can GitHub Actions approve PRs?", "PR approval setting check", "Actions PR 権限監査", "review-bypass チェック". DO NOT USE FOR: creating PRs, changing branch protection, or writing code.

  • Reads credentials

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Run gh auth status — if not authenticated, output:

    line 20
  2. Very specific:

    If a repo legitimately needs Actions to create (not approve) PRs, prefer leaving this false and using a dedicated GitHub App / fine-grained …

    line 81

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

GitHub Actions PR-Approval Permission Audit

Find every repo where GitHub Actions can create and approve pull requests — a known way to bypass required reviews — and report it security-first. false is the secure default; true is an exposure to justify per repo. Read-only: this skill never changes settings; it prints the exact command for you to run. See references/openssf.md for the why + sources.

Setup Check

Run gh auth status — if not authenticated, output:

⚠️ gh CLI not authenticated. Run: gh auth login

and stop.

Step 1: Resolve scope

  • --owner <name>: audit that account. Otherwise: OWNER=$(gh api user --jq .login).
  • --allow <repo,repo>: comma-separated repos you INTENTIONALLY allow to have the setting true (e.g. a repo whose CI legitimately opens PRs via GITHUB_TOKEN). Anything not listed is expected to be false.

List repos (skip archived; they can't be changed):

gh repo list "$OWNER" --no-archived --limit 200 --json name --jq '.[].name'

Step 2: Read the setting per repo

For each repo:

gh api "repos/$OWNER/$REPO/actions/permissions/workflow" \
  --jq '[.default_workflow_permissions, (.can_approve_pull_request_reviews|tostring)] | @tsv'

The second field is the audited flag.

Step 3: Classify

can_approvein --allow?Status
truenoRISK(unexpected) — review-bypass exposure
trueyesOK(allowlisted) — intentional
false—OK(secure-default)
(error)—ERR(skip) — no access / archived

Step 4: Report

# Actions PR-Approval Audit — <owner> — <DATE>

> Generated by github-flow-kit/gh-pr-perm-audit
> `false` = secure default. `true` = a workflow can self-approve PRs and bypass required reviews.

| Repo | default perms | can approve PR | Status |
|---|---|---|---|
| <repo> | read | false | OK(secure-default) |
| <repo> | read | true  | 🔴 RISK(unexpected) |

## 🔴 Exposed repos (un-allowlisted `true`): <N>
- <repo> — a workflow here can approve its own PR and merge past required reviews.

Step 5: Recommend (you run the mutation — never auto-applied)

For each RISK repo, print the secure-default revert command and let the user run it:

# Revert to the secure default (recommended):
gh api -X PUT repos/<owner>/<repo>/actions/permissions/workflow \
  -f default_workflow_permissions=read -F can_approve_pull_request_reviews=false

If a repo legitimately needs Actions to create (not approve) PRs, prefer leaving this false and using a dedicated GitHub App / fine-grained PAT for PR creation, or require a review from someone other than the actor (so a self-approval still can't merge). Only enable intentionally:

gh api -X PUT repos/<owner>/<repo>/actions/permissions/workflow \
  -f default_workflow_permissions=read -F can_approve_pull_request_reviews=true

Summary Output

✅ Actions PR-Approval Audit — <N> repos

  🔴 RISK (un-allowlisted true) : <n>
  🟢 secure-default (false)     : <n>
  ⚪ allowlisted true           : <n>

📋 Next: run the revert command above for each RISK repo, or add it to --allow if intentional.

⭐ Found this useful? Star → https://github.com/thinkyou0714/github-flow-kit

Error Handling

CodeConditionExit
GP-001gh not authenticated2
GP-002owner has no repos0
GP-003per-repo API error (no admin / archived)skip that repo, continue
GP-004API rate limitedstop, show reset time

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.