AGENT SKILL

github-repo-go-public-preflight-scan

Scan for secrets in BOTH the working tree and the full git history before flipping a GitHub repo from private to public. Use when the user asks to run "gh repo edit --visibility public", "make this repo public", "open-source this", "publish this repo" on a repo that was ever private, or is about to accept the "--accept-visibility-change-consequences" prompt. Also fires when open-sourcing an internal/forked project, or publishing a repo other people have committed to. A working-tree-only scan (or a prior code review of just the diff) is not enough — secrets committed and later deleted remain fully cloneable/indexable the instant the repo goes public, and flipping back to private does not undo it.

License 许可
MIT
最近更新
2026-11-07
Stars
★ 1
Forks
1

01 前言 Front Matter

name
github-repo-go-public-preflight-scan
description
Scan for secrets in BOTH the working tree and the full git history before flipping a GitHub repo from private to public. Use when the user asks to run "gh repo edit --visibility public", "make this repo public", "open-source this", "publish this repo" on a repo that was ever private, or is about to accept the "--accept-visibility-change-consequences" prompt. Also fires when open-sourcing an internal/forked project, or publishing a repo other people have committed to. A working-tree-only scan (or a prior code review of just the diff) is not enough — secrets committed and later deleted remain fully cloneable/indexable the instant the repo goes public, and flipping back to private does not undo it.

03 SKILL.md 正文

GitHub repo private → public: scan history, not just HEAD

When to use

  • Any request to run gh repo edit --visibility public (or the GitHub UI equivalent) on a repo that was ever private.
  • Open-sourcing an internal tool or a fork.
  • Publishing a repo that other people also committed to — you likely don't know everything they added and removed.
  • Anywhere gh is about to require --accept-visibility-change-consequences. That flag existing at all is the signal this is a one-way door: treat it like a production deploy gate, not a formality.

Do this even if a code review "already found nothing" — that review almost certainly covered the current diff or HEAD, not every commit ever made.

Steps

  1. Scan the current tree for high-signal secret shapes and sensitive filenames still present today:

    git grep -nIE '(AKIA[0-9A-Z]{16}|-----BEGIN [A-Z ]*PRIVATE KEY-----|ghp_[A-Za-z0-9]{36}|xox[baprs]-[0-9A-Za-z-]{10,}|sk-(live|proj|ant)[A-Za-z0-9_-]{16,})'
    git ls-files | grep -iE '(^|/)(\.env($|\.)|.*\.(pem|p12|key|keystore)$|id_rsa|secrets?\.(json|ya?ml|toml))'
    
  2. Scan the full history, across all branches, for any sensitive file path that was ever added — including files later deleted. This is the step a working-tree-only scan skips entirely:

    git log --all --diff-filter=A --name-only --pretty=format: \
      | sort -u \
      | grep -iE '(^|/)(\.env($|\.)|.*\.(pem|p12|key|keystore)$|id_rsa|credential|secrets?\.(json|ya?ml|toml))'
    
  3. Scan the full history for secret CONTENT. Step 2 checks file names only; a secret committed in an ordinary file and later removed is invisible to it. Search every commit's diffs for the same secret shapes as step 1:

    git log --all -p -E -G'(AKIA[0-9A-Z]{16}|-----BEGIN [A-Z ]*PRIVATE KEY-----|ghp_[A-Za-z0-9]{36}|xox[baprs]-[0-9A-Za-z-]{10,}|sk-(live|proj|ant)[A-Za-z0-9_-]{16,})'
    # or, per-commit tree search (same regex as above):
    git rev-list --all | xargs -n 50 git grep -nIE '(AKIA[0-9A-Z]{16}|-----BEGIN [A-Z ]*PRIVATE KEY-----|ghp_[A-Za-z0-9]{36}|xox[baprs]-[0-9A-Za-z-]{10,}|sk-(live|proj|ant)[A-Za-z0-9_-]{16,})'
    

    -E is required: without it, glibc BRE treats (, | and {16} literally and matches nothing. In the xargs form, do not read the exit status: xargs exits 123 when ANY batch exits 1, and git grep exits 1 on no match. Judge by printed output: any printed line is a finding.

  4. PII sweep (working tree only) — emails other than the intended public contact. Plain git grep reads the current tree, not history; for history, reuse the step 3 git log --all -p -E -G'<email regex>' form:

    git grep -hoIE '[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}' \
      | sort -u | grep -viE '(your-public-contact@|noreply|example\.com)'
    
  5. Prefer a real scanner over the greps above when one is installed — gitleaks detect or trufflehog (both scan full history by default) catch secret shapes the regexes above don't enumerate. Treat the greps as the always-available fallback, not the ceiling.

  6. If anything turns up in history: stop before flipping visibility.

    • Rotate the exposed credential regardless of how old the commit is — assume it's burned the moment it could go public.
    • Remove it from history (git filter-repo or equivalent) or recreate the repo from a clean history before publishing. Deleting the file in a new commit is not sufficient; the old commit is still reachable.
  7. Only once all scans above are clean, flip visibility with explicit consent and verify it took effect:

    gh repo edit OWNER/REPO --visibility public --accept-visibility-change-consequences
    gh repo view OWNER/REPO --json visibility -q .visibility   # expect PUBLIC
    

Hard rules

  • Never treat a working-tree/diff scan as sufficient for this decision — the threat model is "every commit ever made," not "what's on disk now."
  • Never flip visibility while steps 2-3 (history scans) are still pending or have unresolved hits.
  • If history contains a secret, rotating it is mandatory even if you plan to scrub history — don't rely on the scrub alone.
  • This step is irreversible in practice: flipping back to private after exposure does not un-clone, un-cache, or un-index the history that was public in the interim. Treat it as a one-way door and get explicit user confirmation before proceeding, not just before typing the command.

Related skills

  • core-workflow:github-solo-branch-protection-codeowners — harden main at the same go-public moment.

04 同仓库更多 Skills

abhijitbansal
abhijitbansal/claude-skills

second-wind

Orchestrate long unattended Claude Code runs across multiple repos with the wind CLI. Use when the user wants to run Claude Code overnight, resume sessions after the 5-hour usage limit, run Claude in many repos at once via tmux, or says "set up second wind", "wind up", "overnight run", "resume after limit", "usage limit orchestrator".

★ 1
abhijitbansal
abhijitbansal/claude-skills

structured-output-adaptive-thinking-token-bloat

A Claude API call using output_config.format (json_schema structured outputs) with thinking:{type:"adaptive"} burns most of its output budget on thinking (observed ~21k of ~24k tokens) without improving JSON quality, making the run up to ~5x more expensive than the same call with thinking omitted — use when calling the Messages API with a json_schema output format for extraction, ranking, classification, or summarization tasks, or when a schema-constrained call's usage.output_tokens is far larger than the returned JSON.

★ 1
abhijitbansal
abhijitbansal/claude-skills

review

Apply a code-review lens to a diff, branch, or file — find correctness bugs, security issues, and quality problems, ranked by severity, with a concrete fix for each. Use when the user says "review this", "review my diff", "check this PR", "look this over before I commit", or "is this safe". Skip when the user wants the code written, not reviewed.

★ 1
abhijitbansal
abhijitbansal/claude-skills

refresh

Rebuild the prompt-craft command registry and usage profile, and print a summary of installed commands and your personalized recommendations. Use when you install or update plugins and want the advisor to pick them up immediately, or say "refresh prompt-craft", "rebuild the command registry".

★ 1
abhijitbansal
abhijitbansal/claude-skills

refactor

Apply a refactoring lens — restructure code without changing behavior, guarded by tests that pass before and after. Use when the user says "refactor", "clean this up", "extract this", "simplify this", "reduce duplication", or "make this readable" on existing working code. Skip when the change is meant to alter behavior (that's a feature or a fix).

★ 1
abhijitbansal
abhijitbansal/claude-skills

plan

Decompose a non-trivial task into an explicit, tracked plan with goals and per-step acceptance criteria before writing code. Use when the user says "plan this", "break this down", "what's the plan", or asks for a multi-step feature/refactor that touches more than one file. Pairs with plan mode. Skip for single-edit changes that need no decomposition.

★ 1