Secret Scanning
GitHubOfficialFirst committed by VeVarunSharmaDistributed by GitHub
- Skill
- Tool integration
- Security
- MIT
- Low risk
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a comprehensive guide to GitHub's secret scanning features. It covers the configuration of repository-level secret protection, the implementation of push protection to block secrets before they are committed, and the creation of custom regex patterns to detect organization-specific secrets. It also details alert remediation workflows, including validity checks and metadata analysis, to help teams prioritize and resolve security incidents effectively.
What it does
- Enables secret scanning and push protection for repositories and organizations.
- Defines custom secret patterns using regular expressions with dry-run capabilities.
- Provides workflows for triaging, dismissing, and remediating detected secret alerts.
- Supports validity checks to determine if a leaked secret is active or inactive.
- Integrates with AI coding agents via the Advanced Security plugin for pre-commit scanning.
- Configures exclusions to reduce noise in secret scanning results.
When to use it
- When you need to secure a repository against accidental credential exposure.
- When you want to block developers from pushing secrets to your codebase.
- When you need to detect proprietary or custom secret formats.
- When you are triaging existing secret scanning alerts and need to determine their validity.
- When you want to automate pre-commit secret checks within an AI coding agent environment.
Advantages
- Prevents secrets from entering the Git history through proactive push protection.
- Reduces alert fatigue by validating the status of detected secrets.
- Provides deep visibility into secret ownership and scope via extended metadata.
- Allows for flexible, scalable security policies across repositories, organizations, and enterprises.
Usage examples
- “How do I enable push protection for my repository?”
- The agent will guide you to Settings > Advanced Security and instruct you to enable 'Push protection' under the Secret Protection section.
- “I need to detect a specific internal API key format. How do I add a custom pattern?”
- The agent will explain how to navigate to the Custom patterns section, define your regex, perform a dry run to check for false positives, and publish the pattern.
- “How can I check if a detected secret is actually active?”
- The agent will explain how to enable validity checks in your settings, which allows GitHub to periodically test the secret against provider APIs and report its status.
- “How do I scan my local code for secrets before I commit?”
- The agent will provide instructions to install the advanced-security plugin and use the /secret-scanning command within your AI coding agent.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/github/secret-scanning/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip secret-scanning.zip -d .agents/skills
Documentation by VeVarunSharma
Secret Scanning
This skill provides procedural guidance for configuring GitHub secret scanning — detecting leaked credentials, preventing secret pushes, defining custom patterns, and managing alerts.
When to Use This Skill
Use this skill when the request involves:
Enabling or configuring secret scanning for a repository or organization
Setting up push protection to block secrets before they reach the repository
Defining custom secret patterns with regular expressions
Resolving a blocked push from the command line
Triaging, dismissing, or remediating secret scanning alerts
Configuring delegated bypass for push protection
Excluding directories from secret scanning via
secret_scanning.ymlUnderstanding alert types (user, partner, push protection)
Enabling validity checks or extended metadata checks
Scanning local code changes for secrets before committing (via MCP / AI coding agent) — see the Pre-Commit Scanning via AI Coding Agents section below for the recommended plugin
How Secret Scanning Works
Secret scanning automatically detects exposed credentials across:
Entire Git history on all branches
Issue descriptions, comments, and titles (open and closed)
Pull request titles, descriptions, and comments
GitHub Discussions titles, descriptions, and comments
Wikis and secret gists
Availability
| Repository Type | Availability |
|---|---|
| Public repos | Automatic, free |
| Private/internal (org-owned) | Requires GitHub Secret Protection on Team/Enterprise Cloud |
| User-owned | Enterprise Cloud with Enterprise Managed Users |
Core Workflow — Enable Secret Scanning
Step 1: Enable Secret Protection
Navigate to repository Settings → Advanced Security
Click Enable next to "Secret Protection"
Confirm by clicking Enable Secret Protection
For organizations, use security configurations to enable at scale:
Settings → Advanced Security → Global settings → Security configurations
Step 2: Enable Push Protection
Push protection blocks secrets during the push process — before they reach the repository.
Navigate to repository Settings → Advanced Security
Enable "Push protection" under Secret Protection
Push protection blocks secrets in:
Command line pushes
GitHub UI commits
File uploads
REST API requests
REST API content creation endpoints
Step 3: Configure Exclusions (Optional)
Create .github/secret_scanning.yml to auto-close alerts for specific directories:
paths-ignore:
- "docs/**"
- "test/fixtures/**"
- "**/*.example"Limits:
Maximum 1,000 entries in
paths-ignoreFile must be under 1 MB
Excluded paths also skip push protection checks
Best practices:
Be as specific as possible with exclusion paths
Add comments explaining why each path is excluded
Review exclusions periodically — remove stale entries
Inform the security team about exclusions
Step 4: Enable Additional Features (Optional)
Non-provider patterns — detect private keys, connection strings, generic API keys:
Settings → Advanced Security → enable "Scan for non-provider patterns"
AI-powered generic secret detection — uses Copilot to detect unstructured secrets like passwords:
Settings → Advanced Security → enable "Use AI detection"
Validity checks — verify if detected secrets are still active:
Settings → Advanced Security → enable "Validity checks"
GitHub periodically tests detected credentials against provider APIs
Status shown in alert:
active,inactive, orunknown
Extended metadata checks — additional context about who owns a secret:
Requires validity checks to be enabled first
Helps prioritize remediation and identify responsible teams
Core Workflow — Resolve Blocked Pushes
When push protection blocks a push from the command line:
Option A: Remove the Secret
If the secret is in the latest commit:
# Remove the secret from the file
# Then amend the commit
git commit --amend --all
git pushIf the secret is in an earlier commit:
# Find the earliest commit containing the secret
git log
# Start interactive rebase before that commit
git rebase -i <COMMIT-ID>~1
# Change 'pick' to 'edit' for the offending commit
# Remove the secret, then:
git add .
git commit --amend
git rebase --continue
git pushOption B: Bypass Push Protection
Visit the URL returned in the push error message (as the same user)
Select a bypass reason:
It's used in tests — alert created and auto-closed
It's a false positive — alert created and auto-closed
I'll fix it later — open alert created
Click Allow me to push this secret
Re-push within 3 hours
Option C: Request Bypass Privileges
If delegated bypass is enabled and you lack bypass privileges:
Visit the URL from the push error
Add a comment explaining why the secret is safe
Click Submit request
Wait for email notification of approval/denial
If approved, push the commit; if denied, remove the secret
For detailed bypass and delegated bypass workflows, search
references/push-protection.md.
Custom Patterns
Define organization-specific secret patterns using regular expressions.
Quick Setup
Settings → Advanced Security → Custom patterns → New pattern
Enter pattern name and regex for secret format
Add a sample test string
Click Save and dry run to test (up to 1,000 results)
Review results for false positives
Click Publish pattern
Optionally enable push protection for the pattern
Scopes
Custom patterns can be defined at:
Repository level — applies to that repo only
Organization level — applies to all repos with secret scanning enabled
Enterprise level — applies across all organizations
Copilot-Assisted Pattern Generation
Use Copilot secret scanning to generate regex from a text description of the secret type, including optional example strings.
For detailed custom pattern configuration, search
references/custom-patterns.md.
Alert Management
Alert Types
| Type | Description | Visibility |
|---|---|---|
| User alerts | Secrets found in repository | Security tab |
| Push protection alerts | Secrets pushed via bypass | Security tab (filter: bypassed: true) |
| Partner alerts | Secrets reported to provider | Not shown in repo (provider-only) |
Alert Lists
Default alerts — supported provider patterns and custom patterns
Generic alerts — non-provider patterns and AI-detected secrets (limited to 5,000 per repo)
Remediation Priority
Rotate the credential immediately — this is the critical action
Review the alert for context (location, commit, author)
Check validity status:
active(urgent),inactive(lower priority),unknownRemove from Git history if needed (time-intensive, often unnecessary after rotation)
Dismissing Alerts
Dismiss with a documented reason:
False positive — detected string is not a real secret
Revoked — credential has already been revoked
Used in tests — secret is only in test code
For detailed alert types, validity checks, and REST API, search
references/alerts-and-remediation.md.
Pre-Commit Scanning via AI Coding Agents
For scanning code changes for secrets inside an AI coding agent before committing, install the Advanced Security plugin which provides the run_secret_scanning MCP tool and a dedicated scanning skill.
GitHub Copilot CLI:
/plugin install advanced-security@copilot-pluginsVisual Studio Code:
In Copilot Chat, open Chat: Plugins (or use
@agentPlugins) and install theadvanced-securitypluginThen run
/secret-scanningin Copilot Chat
See: Advanced Security Plugin — Secret Scanning Skill
Announced in Secret scanning in AI coding agents via the GitHub MCP Server (March 2026)
Reference Files
For detailed documentation, load the following reference files as needed:
references/push-protection.md— Push protection mechanics, bypass workflow, delegated bypass, user push protectionSearch patterns:
bypass,delegated,bypass request,command line,REST API,user push protection
references/custom-patterns.md— Custom pattern creation, regex syntax, dry runs, Copilot regex generation, scopesSearch patterns:
custom pattern,regex,dry run,publish,organization,enterprise,Copilot
references/alerts-and-remediation.md— Alert types, validity checks, extended metadata, generic alerts, secret removal, REST APISearch patterns:
user alert,partner alert,validity,metadata,generic,remediation,git history,REST API
Files
- ATTRIBUTION.mdAdded by AutoGineer873 B
- LICENSELicence file added by AutoGineer1.0 KiB
- SKILL.md9.4 KiB
- references/alerts-and-remediation.md7.3 KiB
- references/custom-patterns.md5.5 KiB
- references/push-protection.md5.9 KiB
references/push-protection.md
Push Protection Reference
Detailed reference for GitHub push protection — preventing secrets from reaching repositories, bypass workflows, and delegated bypass configuration.
How Push Protection Works
Push protection scans for secrets during the push process and blocks pushes containing detected secrets. It operates as a preventative control, unlike standard secret scanning which detects secrets after commit.
What Gets Scanned
| Surface | Scanned |
|---|---|
| Command line pushes | ✅ |
| GitHub UI commits | ✅ |
| File uploads to repo | ✅ |
| REST API content creation requests | ✅ |
Types of Push Protection
Repository push protection:
Requires GitHub Secret Protection enabled
Disabled by default; enabled by repo admin, org owner, or security manager
Generates alerts for bypasses in the Security tab
Can be enabled at repository, organization, or enterprise level
User push protection:
Enabled by default for all GitHub.com accounts
Blocks pushes to public repositories containing supported secrets
Does NOT generate alerts when bypassed (unless repo also has push protection enabled)
Managed via personal account settings
Resolving Blocked Pushes — Command Line
When push protection blocks a push, the error message includes:
The secret type detected
Commit SHAs containing the secret
File paths and line numbers
A URL to bypass (if permitted)
Remove Secret from Latest Commit
# Edit the file to remove the secret
# Amend the commit
git commit --amend --all
# Push again
git pushRemove Secret from Earlier Commits
# 1. Review the push error for all commits containing the secret
# 2. Find the earliest commit with the secret
git log
# 3. Interactive rebase before that commit
git rebase -i <EARLIEST-COMMIT>~1
# 4. Change 'pick' to 'edit' for the offending commit(s)
# 5. Remove the secret from the file
# 6. Stage and amend
git add .
git commit --amend
# 7. Continue rebase
git rebase --continue
# 8. Push
git pushBypass Push Protection
Visit the URL from the error message (must be the same user who pushed)
Select a reason:
It's used in tests → creates a closed alert (resolved as "used in tests")
It's a false positive → creates a closed alert (resolved as "false positive")
I'll fix it later → creates an open alert
Click Allow me to push this secret
Re-push within 3 hours (after that, repeat the bypass process)
A bypass reason is required when the repo has secret scanning enabled. For public repos with only user push protection (no repo push protection), no reason is needed and no alert is generated.
Resolving Blocked Pushes — GitHub UI
When creating or editing a file in the GitHub UI:
A banner appears warning about the detected secret
Options to remove the secret or bypass are presented inline
Same bypass reasons apply as command line
Resolving Blocked Pushes — REST API
Push protection also applies to REST API content creation endpoints. When blocked:
The API returns an error response with details about the detected secret
Include the bypass reason in the request to proceed
Delegated Bypass
Delegated bypass gives organizations fine-grained control over who can bypass push protection.
How It Works
Organization owners/repo admins create a bypass list of users, roles, or teams
Users on the bypass list can bypass push protection directly (with a reason)
All other contributors must submit a bypass request for review
Bypass requests appear in the Security tab → "Push protection bypass" page
Requests expire after 7 days if not reviewed
Who Can Always Bypass (Without Request)
Organization owners
Security managers
Users in teams/roles added to the bypass list
Users with custom role having "review and manage secret scanning bypass requests" permission
Enabling Delegated Bypass
Repository level:
Settings → Advanced Security → Push protection
Enable "Restrict who can bypass push protection"
Add users, teams, or roles to the bypass list
Organization level:
Organization Settings → Advanced Security → Global settings
Configure delegated bypass in security configuration
Managing Bypass Requests
Designated reviewers:
Navigate to repository Security tab → "Push protection bypass"
Review pending requests (includes the secret, commit, and contributor's comment)
Approve — contributor can push the secret and any future commits with the same secret
Deny — contributor must remove the secret before pushing
Bypass Request Flow (Contributor Perspective)
Push is blocked; visit the URL from the error message
Add a comment explaining why the secret is safe to push
Click Submit request
Wait for email notification of approval/denial
If approved: push the commit
If denied: remove the secret and push again
Push Protection Patterns
Push protection supports a subset of secret scanning patterns. Not all detected secret types trigger push protection blocks.
Key considerations:
Older/legacy token formats may not be supported by push protection
Some patterns have higher false positive rates and are excluded from push protection
Custom patterns can have push protection enabled after publishing
For the full list of patterns supported by push protection, see Supported secret scanning patterns.
Configuring Push Protection for Custom Patterns
After publishing a custom pattern:
Navigate to the custom pattern in Settings → Advanced Security
Click Enable next to push protection
The pattern will now block pushes containing matching secrets
Push protection for custom patterns only applies to repos that have push protection enabled. Enabling push protection for commonly found patterns can be disruptive to contributors.
Requirements and compatibility
Written for: GitHub Copilot
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs an MCP server, Needs an API key, Needs a command-line tool
Security
What our scanner noticed· Low risk
- Instructions that use the network
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- First committed by
VeVarunSharma
- Publisher
- GitHub (Official)
- Distributed by
- GitHub
- Source
- github/awesome-copilot · skills/secret-scanning · commit 797337f
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
- Contributors
- VeVarunSharma, felickz
AutoGineer is not affiliated with or endorsed by VeVarunSharma or GitHub.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download secret-scanning.zip