Generated banner for Secret Scanning
Generated logo for Secret Scanning

Secret Scanning

GitHubOfficialFirst committed by VeVarunSharmaDistributed by GitHub

  • Skill
  • Tool integration
  • Security
  • MIT
  • Low risk

From the author

Guide for configuring and managing GitHub secret scanning, push protection, custom patterns, and secret alert remediation. For pre-commit secret scanning in AI coding agents via the GitHub MCP Server, this skill references the Advanced Security plugin (`advanced-security@copilot-plugins`). Use this skill when enabling secret scanning, setting up push protection, defining custom patterns, triaging alerts, resolving blocked pushes, or when an agent needs to scan code for secrets before committing.
— the description by VeVarunSharma

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

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/github/secret-scanning/download
  2. Unzip 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.yml

  • Understanding 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 TypeAvailability
Public reposAutomatic, free
Private/internal (org-owned)Requires GitHub Secret Protection on Team/Enterprise Cloud
User-ownedEnterprise Cloud with Enterprise Managed Users

Core Workflow — Enable Secret Scanning

Step 1: Enable Secret Protection
  1. Navigate to repository Settings → Advanced Security

  2. Click Enable next to "Secret Protection"

  3. 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.

  1. Navigate to repository Settings → Advanced Security

  2. 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-ignore

  • File 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, or unknown

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 push

If 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 push
Option B: Bypass Push Protection
  1. Visit the URL returned in the push error message (as the same user)

  2. 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

  3. Click Allow me to push this secret

  4. Re-push within 3 hours

Option C: Request Bypass Privileges

If delegated bypass is enabled and you lack bypass privileges:

  1. Visit the URL from the push error

  2. Add a comment explaining why the secret is safe

  3. Click Submit request

  4. Wait for email notification of approval/denial

  5. 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
  1. Settings → Advanced Security → Custom patterns → New pattern

  2. Enter pattern name and regex for secret format

  3. Add a sample test string

  4. Click Save and dry run to test (up to 1,000 results)

  5. Review results for false positives

  6. Click Publish pattern

  7. 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
TypeDescriptionVisibility
User alertsSecrets found in repositorySecurity tab
Push protection alertsSecrets pushed via bypassSecurity tab (filter: bypassed: true)
Partner alertsSecrets reported to providerNot 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
  1. Rotate the credential immediately — this is the critical action

  2. Review the alert for context (location, commit, author)

  3. Check validity status: active (urgent), inactive (lower priority), unknown

  4. Remove 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-plugins

Visual Studio Code:

  • In Copilot Chat, open Chat: Plugins (or use @agentPlugins) and install the advanced-security plugin

  • Then run /secret-scanning in 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 protection

    • Search 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, scopes

    • Search 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 API

    • Search patterns: user alert, partner alert, validity, metadata, generic, remediation, git history, REST API

Files

references/custom-patterns.md

Custom Patterns Reference

Detailed reference for defining custom secret scanning patterns using regular expressions at the repository, organization, and enterprise level.

Overview

Custom patterns extend secret scanning to detect organization-specific secrets not covered by default patterns. They are defined as regular expressions and can optionally enforce push protection.

Pattern Definition

Required Fields
FieldDescription
Pattern nameHuman-readable name for the pattern
Secret formatRegular expression matching the secret
Optional Fields (via "More options")
FieldDescription
Before secretRegex for content that must appear before the secret
After secretRegex for content that must appear after the secret
Additional match requirementsExtra constraints on the match
Sample test stringExample string to validate the regex
Regex Syntax

Custom patterns use standard regular expressions. Common patterns:

# API key with prefix
MYAPP_[A-Za-z0-9]{32}

# Connection string
Server=[\w.]+;Database=\w+;User Id=\w+;Password=[^;]+

# Internal token format
myorg-token-[a-f0-9]{64}

# JWT-like pattern
eyJ[A-Za-z0-9_-]+\.eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+

Use filter patterns similar to GitHub Actions workflow syntax for glob-style matching in before/after fields.

Defining Patterns by Scope

Repository Level
  1. Repository Settings → Advanced Security

  2. Under "Secret Protection" → Custom patterns → New pattern

  3. Enter pattern name, regex, and optional fields

  4. Save and dry run to test

  5. Review results (up to 1,000 matches)

  6. Publish pattern when satisfied

  7. Optionally enable push protection

Prerequisite: Secret Protection must be enabled on the repository.

Organization Level
  1. Organization Settings → Advanced Security → Global settings

  2. Under "Custom patterns" → New pattern

  3. Enter pattern details

  4. Save and dry run — select repositories for testing:

    • All repositories in the organization, or

    • Up to 10 selected repositories

  5. Publish pattern when satisfied

  6. Optionally enable push protection

Notes:

  • Push protection for org-level custom patterns only applies to repos with push protection enabled

  • Organization owners and repo admins receive alerts

Enterprise Level
  1. Enterprise settings → Policies → Advanced Security → Security features

  2. Under "Secret scanning custom patterns" → New pattern

  3. Enter pattern details

  4. Save and dry run — select up to 10 repositories

  5. Publish pattern when satisfied

  6. Optionally enable push protection

Notes:

  • Only the pattern creator can edit or dry-run enterprise-level patterns

  • Dry runs require admin access to the selected repositories

  • Push protection requires enterprise-level secret scanning push protection to be enabled

Dry Run Process

Dry runs test patterns against repository content without creating alerts.

  1. Click Save and dry run after defining the pattern

  2. Select target repositories (org/enterprise level)

  3. Click Run

  4. Review up to 1,000 sample results

  5. Identify false positives

  6. Edit pattern and re-run if needed

  7. Publish pattern only when false positive rate is acceptable

Dry runs are essential — always test before publishing to avoid alert noise.

Managing Published Patterns

Editing Patterns

After publishing, patterns can be edited:

  1. Navigate to the custom pattern

  2. Modify the regex or optional fields

  3. Save and dry run to validate changes

  4. Publish the updated pattern

Enabling Push Protection

Push protection can only be enabled after a pattern is published:

  1. Navigate to the published pattern

  2. Click Enable next to push protection

Caution: Enabling push protection for commonly found patterns can disrupt contributor workflows.

Disabling or Deleting Patterns
  • Disable: stops new alert generation but retains existing alerts

  • Delete: removes the pattern and stops all scanning for it

Copilot-Assisted Pattern Generation

Use Copilot secret scanning to generate regex automatically:

  1. Navigate to custom pattern creation

  2. Select "Generate with Copilot" (if available)

  3. Provide a text description of the secret type (e.g., "internal API key starting with MYORG_ followed by 40 hex characters")

  4. Optionally provide example strings that should match

  5. Copilot generates a regex pattern

  6. Review and refine the generated regex

  7. Test with dry run before publishing

Pattern Inheritance

ScopeApplies To
RepositoryThat repository only
OrganizationAll repos in the org with secret scanning enabled
EnterpriseAll repos across all orgs with secret scanning enabled

Organization and enterprise patterns automatically apply to new repositories when secret scanning is enabled.

Best Practices

  1. Always dry run before publishing — review for false positives

  2. Start specific — narrow regexes reduce false positives

  3. Use before/after context — adds precision without overly complex regex

  4. Test with real examples — include sample strings that should and shouldn't match

  5. Document patterns — name patterns clearly so teams understand what they detect

  6. Review periodically — remove or update patterns that no longer apply

  7. Be cautious with push protection — enable only for patterns with low false positive rates

  8. Consider Copilot — let AI generate the initial regex, then refine manually

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
GitHub avatar of VeVarunSharmaVeVarunSharma
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