secrets-gitleaks
Skill2 starsChanged 24 days agoMITView on GitHub
Hardcoded secret detection and prevention in git repositories and codebases using Gitleaks. Identifies passwords, API keys, tokens, and credentials through regex-based pattern matching and entropy analysis. Use when: (1) Scanning repositories for exposed secrets and credentials, (2) Implementing pre-commit hooks to prevent secret leakage, (3) Integrating secret detection into CI/CD pipelines, (4) Auditing codebases for compliance violations (PCI-DSS, SOC2, GDPR), (5) Establishing baseline secret detection and tracking new exposures, (6) Remediating historical secret exposures in git history.
- Reads credentials
- Deletes or force-pushes
- Installs packages
- Commits and pushes
2 other projects use a version of this, 2 of them edited.
Adopted by
Most recently taken up by
- matheus-rib1108/meu-kit-claude-codeedited, first seen Oct 17, 2026
- morshed272/claude-build-workflowedited, first seen Jan 18, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 2
- morshed272/claude-build-workflow★ 176% same
- matheus-rib1108/meu-kit-claude-code★ 076% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository28 other files it gives its agents.
- AGENTS.mdAGENTS.md
- ai-newsSkill
- break-uiSkill
- ci-cd-and-automationSkill
- clickup-task-breakdownSkill
- client-facing-docsSkill
- codebase-designSkill
- design-auditSkill
- diagnosing-bugsSkill
- domain-modelingSkill
- express-prisma-patternSkill
- frontend-designSkill
- game-assetsSkill
- game-design-docSkill
- grillingSkill
- improve-codebase-architectureSkill
- motion-dictionarySkill
- playwright-cliSkill
- prisma-schema-conventionsSkill
- rag-architectSkill
- rbac-designSkill
- redesign-existing-projectsSkill
- screenshot-to-codeSkill
- security-auditSkill
- sentry-setup-ai-monitoringSkill
- tddSkill
- token-efficiencySkill
- web-design-guidelinesSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
19 rules. About 0 are common, 9 are distinctive, and 10 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 153
Create custom .gitleaks.toml configuration:
- Very specific: line 186
Secret Redaction: Always use --redact flag in logs and reports to prevent accidental secret exposure
- Distinctive: line 189
Credential Rotation: All exposed secrets must be rotated immediately, even if removed from code
- Distinctive: line 210
CWE-798: Use of Hard-coded Credentials
- Distinctive: line 211
CWE-259: Use of Hard-coded Password
- Distinctive: line 290
Add organization-specific secret patterns:
- Very specific: line 310
GitHub Actions: Use gitleaks/gitleaks-action@v2 for native integration with Security tab
- Distinctive: line 319
Vulnerability Management: Import SARIF reports into Snyk, SonarQube, or Checkmarx
- Very specific: line 329
Add to allowlist in .gitleaks.toml:
- Distinctive: line 335
Use commit allowlists for specific false positives:
- Very specific: line 344
Use --log-opts to limit git history: gitleaks detect --log-opts="--since=2024-01-01"
- Distinctive: line 346
Use baseline approach to scan only recent changes
- Very specific: line 347
Consider shallow clone for initial scans: git clone --depth=1000
- Very specific: line 352
Add inline comment to bypass hook: # gitleaks:allow
- Very specific: line 353
Update .gitleaks.toml allowlist for the specific pattern
- Very specific: line 354
Use --redact to safely review findings: gitleaks protect --staged --redact
- Distinctive: line 367
Document incident in security audit log
- Very specific: line 373
Add custom rule to .gitleaks.toml
- Distinctive: line 375
Consider entropy threshold if pattern is ambiguous:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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.
Files
<!-- Fonte: github.com/majiayu000/claude-skill-registry-data, security/secrets-gitleaks/SKILL.md
(autor atribuído: SirAppSec; repo agregador sem LICENSE próprio detectado no GitHub — conteúdo é
documentação de uso de uma ferramenta open-source real, gitleaks/gitleaks, sem claim de autoria
original sobre o gitleaks em si). Copiado verbatim 2026-09-01 após leitura completa (duas vezes,
mesmo veredito). Ver skills-radar.md (seção H).
CAVEAT confirmado na cópia: a seção "Bundled Resources" abaixo lista scripts/references/assets
que NÃO EXISTEM no repo de origem (só SKILL.md + metadata.json de fato existem) — são aspiracionais,
não copiados aqui. Os comandos inline (gitleaks CLI, YAML de CI, pre-commit manual) são reais e
usáveis como estão; não tente rodar `./scripts/install_precommit.sh` — escreva o hook inline
seguindo o exemplo em "Pre-Commit Hook Protection" abaixo. -->Secrets Detection with Gitleaks
Overview
Gitleaks is a secret detection tool that scans git repositories, files, and directories for hardcoded credentials including passwords, API keys, tokens, and other sensitive information. It uses regex-based pattern matching combined with Shannon entropy analysis to identify secrets that could lead to unauthorized access if exposed.
This skill provides comprehensive guidance for integrating Gitleaks into DevSecOps workflows, from pre-commit hooks to CI/CD pipelines, with emphasis on preventing secret leakage before code reaches production.
Quick Start
Scan current repository for secrets:
# Install gitleaks
brew install gitleaks # macOS
# or: docker pull zricethezav/gitleaks:latest
# Scan current git repository
gitleaks detect -v
# Scan specific directory
gitleaks detect --source /path/to/code -v
# Generate report
gitleaks detect --report-path gitleaks-report.json --report-format jsonCore Workflows
1. Repository Scanning
Scan existing repositories to identify exposed secrets:
# Full repository scan with verbose output
gitleaks detect -v --source /path/to/repo
# Scan with custom configuration
gitleaks detect --config .gitleaks.toml -v
# Generate JSON report for further analysis
gitleaks detect --report-path findings.json --report-format json
# Generate SARIF report for GitHub/GitLab integration
gitleaks detect --report-path findings.sarif --report-format sarifWhen to use: Initial security audit, compliance checks, incident response.
2. Pre-Commit Hook Protection
Prevent secrets from being committed in the first place:
# Install pre-commit hook (run in repository root)
cat << 'EOF' > .git/hooks/pre-commit
#!/bin/sh
gitleaks protect --verbose --redact --staged
EOF
chmod +x .git/hooks/pre-commitWhen to use: Developer workstation setup, team onboarding, mandatory security controls.
3. CI/CD Pipeline Integration
GitHub Actions
name: gitleaks
on: [push, pull_request]
jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}GitLab CI
gitleaks:
image: zricethezav/gitleaks:latest
stage: test
script:
- gitleaks detect --report-path gitleaks.json --report-format json --verbose
artifacts:
paths:
- gitleaks.json
when: always
allow_failure: falseWhen to use: Automated security gates, pull request checks, release validation.
4. Baseline and Incremental Scanning
Establish security baseline and track only new secrets:
# Create initial baseline
gitleaks detect --report-path baseline.json --report-format json
# Subsequent scans detect only new secrets
gitleaks detect --baseline-path baseline.json --report-path new-findings.json -vWhen to use: Legacy codebase remediation, phased rollout, compliance tracking.
5. Configuration Customization
Create custom .gitleaks.toml configuration:
title = "Custom Gitleaks Configuration"
[extend]
# Extend default config with custom rules
useDefault = true
[[rules]]
id = "custom-api-key"
description = "Custom API Key Pattern"
regex = '''(?i)(custom_api_key|custom_secret)[\s]*[=:][\s]*['"][a-zA-Z0-9]{32,}['"]'''
tags = ["api-key", "custom"]
[allowlist]
description = "Global allowlist"
paths = [
'''\.md$''', # Ignore markdown files
'''test/fixtures/''', # Ignore test fixtures
]
stopwords = [
'''EXAMPLE''', # Ignore example keys
'''PLACEHOLDER''',
]When to use: Reducing false positives, adding proprietary secret patterns, organizational standards.
Security Considerations
Sensitive Data Handling
- Secret Redaction: Always use
--redactflag in logs and reports to prevent accidental secret exposure - Report Security: Gitleaks reports contain detected secrets - treat as confidential, encrypt at rest
- Git History: Detected secrets in git history require complete removal using tools like
git filter-repoorBFG Repo-Cleaner - Credential Rotation: All exposed secrets must be rotated immediately, even if removed from code
Access Control
- CI/CD Permissions: Gitleaks scans require read access to repository content and git history
- Report Access: Restrict access to scan reports containing sensitive findings
- Baseline Files: Baseline JSON files contain secret metadata - protect with same controls as findings
Audit Logging
Log the following for compliance and incident response:
- Scan execution timestamps and scope (repository, branch, commit range)
- Number and types of secrets detected
- Remediation actions taken (credential rotation, commit history cleanup)
- False positive classifications and allowlist updates
Compliance Requirements
- PCI-DSS 3.2.1: Requirement 6.5.3 - Prevent hardcoded credentials in payment applications
- SOC2: CC6.1 - Logical access controls prevent unauthorized credential exposure
- GDPR: Article 32 - Appropriate security measures for processing personal data credentials
- CWE-798: Use of Hard-coded Credentials
- CWE-259: Use of Hard-coded Password
- OWASP A07:2021: Identification and Authentication Failures
Common Patterns
Pattern 1: Initial Repository Audit
First-time secret scanning for security assessment:
# 1. Clone repository with full history
git clone --mirror https://github.com/org/repo.git audit-repo
cd audit-repo
# 2. Run comprehensive scan
gitleaks detect --report-path audit-report.json --report-format json -v
# 3. Review findings and classify false positives
# Edit .gitleaks.toml to add allowlist entries
# 4. Create baseline for future scans
cp audit-report.json baseline.jsonPattern 2: Developer Workstation Setup
Protect developers from accidental secret commits:
# 1. Install gitleaks locally
brew install gitleaks # macOS
# or use package manager for your OS
# 2. Install pre-commit hook (see "Pre-Commit Hook Protection" above)
# 3. Test hook with dummy commit
echo "api_key = 'EXAMPLE_KEY_12345'" > test.txt
git add test.txt
git commit -m "test" # Should be blocked by gitleaks
# 4. Clean up test
git reset HEAD~1
rm test.txtPattern 3: CI/CD Pipeline with Baseline
Progressive secret detection in continuous integration:
# In CI pipeline script:
# 1. Check if baseline exists
if [ -f ".gitleaks-baseline.json" ]; then
# Incremental scan - only new secrets
gitleaks detect \
--baseline-path .gitleaks-baseline.json \
--report-path new-findings.json \
--report-format json \
--exit-code 1 # Fail on new secrets
else
# Initial scan - create baseline
gitleaks detect \
--report-path .gitleaks-baseline.json \
--report-format json \
--exit-code 0 # Don't fail on first scan
fi
# 2. Generate SARIF for GitHub Security tab
if [ -f "new-findings.json" ] && [ -s "new-findings.json" ]; then
gitleaks detect \
--baseline-path .gitleaks-baseline.json \
--report-path results.sarif \
--report-format sarif
fiPattern 4: Custom Rule Development
Add organization-specific secret patterns:
# Add to .gitleaks.toml
[[rules]]
id = "acme-corp-api-key"
description = "ACME Corp Internal API Key"
regex = '''(?i)acme[_-]?api[_-]?key[\s]*[=:][\s]*['"]?([a-f0-9]{40})['"]?'''
secretGroup = 1
tags = ["api-key", "acme-internal"]
# Test custom rules
# gitleaks detect --config .gitleaks.toml -vIntegration Points
CI/CD Integration
- GitHub Actions: Use
gitleaks/gitleaks-action@v2for native integration with Security tab - GitLab CI: Docker-based scanning with artifact retention for audit trails
- Jenkins: Execute via Docker or installed binary in pipeline stages
- CircleCI: Docker executor with orb support
- Azure Pipelines: Task-based integration with results publishing
Security Tools Ecosystem
- SIEM Integration: Export JSON findings to Splunk, ELK, or Datadog for centralized monitoring
- Vulnerability Management: Import SARIF reports into Snyk, SonarQube, or Checkmarx
- Secret Management: Integrate findings with HashiCorp Vault or AWS Secrets Manager rotation workflows
- Ticketing Systems: Automated Jira/ServiceNow ticket creation for remediation tracking
Troubleshooting
Issue: Too Many False Positives
Solution:
- Review findings to identify patterns:
grep -i "example\|test\|placeholder" gitleaks-report.json - Add to allowlist in
.gitleaks.toml:[allowlist] paths = ['''test/''', '''examples/''', '''\.md$'''] stopwords = ["EXAMPLE", "PLACEHOLDER", "YOUR_API_KEY_HERE"] - Use commit allowlists for specific false positives:
[allowlist] commits = ["commit-sha-here"]
Issue: Performance Issues on Large Repositories
Solution:
- Use
--log-optsto limit git history:gitleaks detect --log-opts="--since=2024-01-01" - Scan specific branches:
gitleaks detect --log-opts="origin/main" - Use baseline approach to scan only recent changes
- Consider shallow clone for initial scans:
git clone --depth=1000
Issue: Pre-commit Hook Blocking Valid Commits
Solution:
- Add inline comment to bypass hook:
# gitleaks:allow - Update
.gitleaks.tomlallowlist for the specific pattern - Use
--redactto safely review findings:gitleaks protect --staged --redact - Temporary bypass (use with caution):
git commit --no-verify - Review with security team if pattern is genuinely needed
Issue: Secrets Found in Git History
Solution:
- Rotate compromised credentials immediately (highest priority)
- For public repositories, consider full history rewrite using:
git filter-repo(recommended):git filter-repo --path-glob '*.env' --invert-paths- BFG Repo-Cleaner:
bfg --delete-files credentials.json
- Force-push cleaned history:
git push --force - Notify all contributors to rebase/re-clone
- Document incident in security audit log
Issue: Custom Secret Patterns Not Detected
Solution:
- Develop regex pattern: Test at regex101.com with sample secrets
- Add custom rule to
.gitleaks.toml - Test pattern:
gitleaks detect --config .gitleaks.toml -v --no-git - Consider entropy threshold if pattern is ambiguous:
[[rules.Entropies]] Min = "3.5" Max = "7.0" Group = "1"
Advanced Configuration
Entropy-Based Detection
For secrets without clear patterns, use Shannon entropy analysis:
[[rules]]
id = "high-entropy-strings"
description = "High entropy strings that may be secrets"
regex = '''[a-zA-Z0-9]{32,}'''
entropy = 4.5 # Shannon entropy threshold
secretGroup = 0Composite Rules (v8.28.0+)
Detect secrets spanning multiple lines or requiring context:
[[rules]]
id = "multi-line-secret"
description = "API key with usage context"
regex = '''api_key[\s]*='''
[[rules.composite]]
pattern = '''initialize_client'''
location = "line" # Must be within same line proximity
distance = 5 # Within 5 linesGlobal vs Rule-Specific Allowlists
# Global allowlist (highest precedence)
[allowlist]
description = "Organization-wide exceptions"
paths = ['''vendor/''', '''node_modules/''']
# Rule-specific allowlist
[[rules]]
id = "generic-api-key"
[rules.allowlist]
description = "Exceptions only for this rule"
regexes = ['''key\s*=\s*EXAMPLE''']References
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
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.

