Public Repository Git Gate
Treat Git commits, remote pushes, and pull requests as sequential public-content
gates. .gitignore is not a security boundary; inspect what Git will actually
commit or has already put under version control.
Keep checks read-only by default. Passing a check does not authorize a commit,
push, PR creation, or remote-branch update. The user must explicitly request
those actions, which must also follow the repository's branch and approval
rules.
Run the script
Run the script from this skill directory. The three checks are not repeated
full scans: commit checks inspect the index, push checks inspect changes from
the base, and CI independently verifies the final PR head.
python3 scripts/public_repo_check.py --repo /path/to/repository --staged --require-feature-branch
Run the staged check before committing and the change/remote check before
pushing:
python3 scripts/public_repo_check.py --repo /path/to/repository --staged --require-feature-branch
python3 scripts/public_repo_check.py --repo /path/to/repository --changed-since origin/main --check-remote
Use --all for a full baseline when introducing the gate, changing its rule
configuration, recovering from an accidental push, or preparing a Release.
Projects can add scoped exceptions and rules with
--config path/to/public-repo-gate.json. Keep the default rules conservative;
document each intentionally public special resource in project configuration
instead of disabling the entire check.
For a large repository, replace origin/main with the PR's exact base SHA. Do
not use an old local base. If the ref is missing, fail the check and synchronize
the base first rather than assuming that there are no changes.
Layered check strategy
| Stage |
Scope |
Checks |
Target duration |
| commit |
staged files |
Paths, secrets, diff format, feature branch |
Seconds, offline |
| push |
base...HEAD changes |
Incremental public-content scan and remote/branch/upstream checks |
Seconds; no full test suite |
| PR |
final head |
Full CI security scan, lint, test, build, and PR diff review |
CI-owned |
| Release |
final artifacts and live state |
Archives, licenses, tag, deployment, and attachments |
Separate gate |
A passing commit check cannot replace remote push/PR confirmation, and an
incremental push check cannot replace PR CI. Each layer should cover only its
own responsibility.
Commit gate
- Confirm the repository visibility first. Treat the remote repository, branch,
PR, Preview, and history as public content by default.
- Check
git status --short --branch, the current branch, and the target PR
base. Do not commit ordinary changes directly to main or master.
- Stage only the necessary files. Inspect staged names, status, and the full
diff, not just a summary.
- Run the script's
--staged check and git diff --cached --check. This is a
fast gate; do not require the full test suite for every commit.
- For higher-risk code, run targeted tests required by the project. Let PR CI
own complete lint, test, build, security, and license checks.
- Confirm that the commit message, version files, public documentation, tests,
and configuration are synchronized. Keep internal plans, legal opinions,
business strategy, customer data, and private agent configuration out of
public commits.
Push gate
- Reconfirm the remote URL, repository visibility, target branch, upstream, and
PR head before pushing. Do not infer remote state from memory.
- Run
--changed-since origin/main --check-remote, then inspect recent commits
on the branch for content that should not be public. The script cannot prove
the hosting platform's repository visibility; confirm that setting manually.
- In the ordinary workflow, push only a feature branch, never
main directly.
Do not use --force to overwrite someone else's branch. History cleanup is
an exception requiring a local backup and an explicit recorded reason.
- After pushing, confirm through the remote platform that the branch exists,
the commit SHA matches, the PR base/head is correct, and no other PR was
accidentally created or updated.
- If an accidental push is found, stop pushing immediately. Preserve a backup
reference, pause or close the PR, rotate exposed secrets, rebuild from a
clean public base, and follow the hosting platform's process for historical
objects and caches.
PR gate
- Set
main as the PR base and the feature branch as the head. Describe the
scope, risks, verification results, and unfinished work in the title and
body.
- Recheck the PR file list and full diff, especially new files, generated
artifacts, hidden directories, configuration, licenses, and documentation.
- Require CI to pass with a full public-content scan of the final head and the
project's lint, test, build, security, and license checks. Add real
environment evidence for database, deployment, third-party-resource, or
release changes. Passing CI does not prove that a production migration ran.
- List incremental local checks, full CI checks, project tests/build, security
checks, and license checks in the PR body. Explain every failed or skipped
check.
- Do not treat the author's own PR as an independent review. Obtain at least
one appropriate review and request security or legal review when needed.
- Reconfirm before merging that no internal material, personal data, secrets,
or unnecessary public content remains. After merging, delete the feature
branch and independently verify the final
main commit.
When a check fails
Stop the current commit, push, or merge; do not commit first and explain later.
Classify the finding as a false positive, a project-specific public resource,
or content that should not be public. For a false positive, add the smallest
scoped project configuration and retain the reason. For a real issue, unstage
the content or remove it from the commit. Treat exposed secrets, personal data,
or internal material as a security incident; rewriting branch history alone is
not sufficient.
Boundary with the Release gate
This skill covers commits, pushes, and PRs. Use the sibling
public-release-gate skill for tags, final installers, archives, GitHub
Release attachments, and production-deployment acceptance. Only both gates
together constitute a complete release review. Do not repeat the Release
artifact scan at every commit, push, and PR layer.
1---2name: public-repo-git-gate3description: Run the public-repository gates for Git commits, pushes, and pull requests. Check staged and untracked scope, secrets and personal data, internal material, branches and remotes, PR base/head, CI, and merge prerequisites. Use when the user asks to commit, push, open a PR, review public repository content, or run the complete public-repository gate.4---56# Public Repository Git Gate78Treat Git commits, remote pushes, and pull requests as sequential public-content9gates. `.gitignore` is not a security boundary; inspect what Git will actually10commit or has already put under version control.1112Keep checks read-only by default. Passing a check does not authorize a commit,13push, PR creation, or remote-branch update. The user must explicitly request14those actions, which must also follow the repository's branch and approval15rules.1617## Run the script1819Run the script from this skill directory. The three checks are not repeated20full scans: commit checks inspect the index, push checks inspect changes from21the base, and CI independently verifies the final PR head.2223```bash24python3 scripts/public_repo_check.py --repo /path/to/repository --staged --require-feature-branch25```2627Run the staged check before committing and the change/remote check before28pushing:2930```bash31python3 scripts/public_repo_check.py --repo /path/to/repository --staged --require-feature-branch32python3 scripts/public_repo_check.py --repo /path/to/repository --changed-since origin/main --check-remote33```3435Use `--all` for a full baseline when introducing the gate, changing its rule36configuration, recovering from an accidental push, or preparing a Release.37Projects can add scoped exceptions and rules with38`--config path/to/public-repo-gate.json`. Keep the default rules conservative;39document each intentionally public special resource in project configuration40instead of disabling the entire check.4142For a large repository, replace `origin/main` with the PR's exact base SHA. Do43not use an old local base. If the ref is missing, fail the check and synchronize44the base first rather than assuming that there are no changes.4546## Layered check strategy4748| Stage | Scope | Checks | Target duration |49| --- | --- | --- | --- |50| commit | staged files | Paths, secrets, diff format, feature branch | Seconds, offline |51| push | `base...HEAD` changes | Incremental public-content scan and remote/branch/upstream checks | Seconds; no full test suite |52| PR | final head | Full CI security scan, lint, test, build, and PR diff review | CI-owned |53| Release | final artifacts and live state | Archives, licenses, tag, deployment, and attachments | Separate gate |5455A passing commit check cannot replace remote push/PR confirmation, and an56incremental push check cannot replace PR CI. Each layer should cover only its57own responsibility.5859## Commit gate60611. Confirm the repository visibility first. Treat the remote repository, branch,62 PR, Preview, and history as public content by default.632. Check `git status --short --branch`, the current branch, and the target PR64 base. Do not commit ordinary changes directly to `main` or `master`.653. Stage only the necessary files. Inspect staged names, status, and the full66 diff, not just a summary.674. Run the script's `--staged` check and `git diff --cached --check`. This is a68 fast gate; do not require the full test suite for every commit.695. For higher-risk code, run targeted tests required by the project. Let PR CI70 own complete lint, test, build, security, and license checks.716. Confirm that the commit message, version files, public documentation, tests,72 and configuration are synchronized. Keep internal plans, legal opinions,73 business strategy, customer data, and private agent configuration out of74 public commits.7576## Push gate77781. Reconfirm the remote URL, repository visibility, target branch, upstream, and79 PR head before pushing. Do not infer remote state from memory.802. Run `--changed-since origin/main --check-remote`, then inspect recent commits81 on the branch for content that should not be public. The script cannot prove82 the hosting platform's repository visibility; confirm that setting manually.833. In the ordinary workflow, push only a feature branch, never `main` directly.84 Do not use `--force` to overwrite someone else's branch. History cleanup is85 an exception requiring a local backup and an explicit recorded reason.864. After pushing, confirm through the remote platform that the branch exists,87 the commit SHA matches, the PR base/head is correct, and no other PR was88 accidentally created or updated.895. If an accidental push is found, stop pushing immediately. Preserve a backup90 reference, pause or close the PR, rotate exposed secrets, rebuild from a91 clean public base, and follow the hosting platform's process for historical92 objects and caches.9394## PR gate95961. Set `main` as the PR base and the feature branch as the head. Describe the97 scope, risks, verification results, and unfinished work in the title and98 body.992. Recheck the PR file list and full diff, especially new files, generated100 artifacts, hidden directories, configuration, licenses, and documentation.1013. Require CI to pass with a full public-content scan of the final head and the102 project's lint, test, build, security, and license checks. Add real103 environment evidence for database, deployment, third-party-resource, or104 release changes. Passing CI does not prove that a production migration ran.1054. List incremental local checks, full CI checks, project tests/build, security106 checks, and license checks in the PR body. Explain every failed or skipped107 check.1085. Do not treat the author's own PR as an independent review. Obtain at least109 one appropriate review and request security or legal review when needed.1106. Reconfirm before merging that no internal material, personal data, secrets,111 or unnecessary public content remains. After merging, delete the feature112 branch and independently verify the final `main` commit.113114## When a check fails115116Stop the current commit, push, or merge; do not commit first and explain later.117Classify the finding as a false positive, a project-specific public resource,118or content that should not be public. For a false positive, add the smallest119scoped project configuration and retain the reason. For a real issue, unstage120the content or remove it from the commit. Treat exposed secrets, personal data,121or internal material as a security incident; rewriting branch history alone is122not sufficient.123124## Boundary with the Release gate125126This skill covers commits, pushes, and PRs. Use the sibling127`public-release-gate` skill for tags, final installers, archives, GitHub128Release attachments, and production-deployment acceptance. Only both gates129together constitute a complete release review. Do not repeat the Release130artifact scan at every commit, push, and PR layer.