
Git Security Checks
- 66 installs
- 49 repo stars
- Updated August 4, 2026
- laurigates/claude-plugins
Helps with security tasks.
About
git-security-checks is a Claude Code skill for security. It helps solo builders move faster with AI-assisted development.
- git-security-checks
- Security
- AI-coding skill
Git Security Checks by the numbers
- 66 all-time installs (skills.sh)
- +1 installs in the week ending Aug 2, 2026 (Skillselion tracking)
- Ranked #1,203 of 2,203 Security skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/laurigates/claude-plugins --skill git-security-checksAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 66 |
|---|---|
| repo stars | ★ 49 |
| Last updated | August 4, 2026 |
| Repository | laurigates/claude-plugins ↗ |
What it does
Helps with security tasks.
Files
Git Security Checks
When to Use This Skill
| Use this skill when... | Use the alternative when... |
|---|---|
Running gitleaks to scan for secrets before committing | Use git-commit-workflow for general staging and commit-message conventions |
Configuring .gitleaks.toml allowlists and pre-commit integration | Use git-maintain for git fsck integrity checks rather than secret scanning |
| Validating that no credentials leak into a PR | Use git-fix-pr when CI gitleaks scans fail and you need to fix them on branch |
| Setting up pre-commit hooks for credential scanning | Use release-please-protection to detect manual edits to release-managed files |
Expert guidance for pre-commit security validation and secret detection using gitleaks and pre-commit hooks.
Core Expertise
- gitleaks: Scan for hardcoded secrets and credentials using regex + entropy analysis
- Pre-commit Hooks: Automated security validation before commits
- Declarative Allowlisting: Manage false positives via
.gitleaks.tomlconfiguration - Security-First Workflow: Prevent credential leaks before they happen
Quick Security Scan (Recommended)
Run the comprehensive security scan pipeline in one command:
# Full scan: check all tracked files
bash "${CLAUDE_PLUGIN_ROOT}/skills/git-security-checks/scripts/security-scan.sh"
# Staged-only: check only files about to be committed
bash "${CLAUDE_PLUGIN_ROOT}/skills/git-security-checks/scripts/security-scan.sh" --staged-onlyThe script checks: gitleaks scan, sensitive file patterns, .gitignore coverage, high-entropy strings in diffs, and pre-commit hook status. See scripts/security-scan.sh for details.
Gitleaks Workflow
Initial Setup
# Install gitleaks (macOS)
brew install gitleaks
# Install gitleaks (Go)
go install github.com/gitleaks/gitleaks/v8@latest
# Install gitleaks (binary download)
# See https://github.com/gitleaks/gitleaks/releases
# Scan repository
gitleaks detect --source .
# Scan with verbose output
gitleaks detect --source . --verboseConfiguration
Create .gitleaks.toml for project-specific allowlists:
title = "Gitleaks Configuration"
[extend]
useDefault = true
[allowlist]
description = "Project-wide allowlist for false positives"
paths = [
'''test/fixtures/.*''',
'''.*\.test\.(ts|js)$''',
]
regexes = [
'''example\.com''',
'''localhost''',
'''fake-key-for-testing''',
]Pre-commit Scan Workflow
Run gitleaks before every commit:
# Scan for secrets in current state
gitleaks detect --source .
# Scan only staged changes (pre-commit mode)
gitleaks protect --staged
# Scan with specific config
gitleaks detect --source . --config .gitleaks.tomlManaging False Positives
Gitleaks provides three declarative methods for handling false positives:
1. Inline comments — mark specific lines:
# This line is safe
API_KEY = "fake-key-for-testing-only" # gitleaks:allow
# Works in any language
password = "test-fixture" # gitleaks:allow2. Path-based exclusions — in .gitleaks.toml:
[allowlist]
paths = [
'''test/fixtures/.*''',
'''.*\.example$''',
'''package-lock\.json$''',
]3. Regex-based allowlists — for specific patterns:
[allowlist]
regexes = [
'''example\.com''',
'''localhost''',
'''PLACEHOLDER''',
]4. Per-rule allowlists — target specific detection rules:
[[rules]]
id = "generic-api-key"
description = "Generic API Key"
[rules.allowlist]
regexes = ['''test-api-key-.*''']
paths = ['''test/.*''']Complete Pre-commit Security Flow
# 1. Scan for secrets
gitleaks protect --staged
# 2. Run all pre-commit hooks
pre-commit run --all-files --show-diff-on-failure
# 3. Stage your actual changes
git add src/file.ts
# 4. Show what's staged
git status
git diff --cached --stat
# 5. Commit if everything passes
git commit -m "feat(auth): add authentication module"Pre-commit Hook Integration
.pre-commit-config.yaml
Example configuration with gitleaks:
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.22.1
hooks:
- id: gitleaksRunning Pre-commit Hooks
# Run all hooks on all files
pre-commit run --all-files
# Run all hooks on staged files only
pre-commit run
# Run specific hook
pre-commit run gitleaks
# Show diff on failure for debugging
pre-commit run --all-files --show-diff-on-failure
# Install hooks to run automatically on commit
pre-commit installCommon Secret Patterns
Gitleaks ships with 140+ built-in rules covering:
- API Keys: AWS, GitHub, Stripe, Google, Azure, etc.
- Authentication Tokens: JWT, OAuth tokens, session tokens
- Passwords: Hardcoded passwords in config files
- Private Keys: RSA, SSH, PGP private keys
- Database Credentials: Connection strings with passwords
- Generic Secrets: High-entropy strings that look like secrets
Examples of What Gets Detected
# Detected: Hardcoded API key
API_KEY = "sk_live_abc123def456ghi789" # gitleaks:allow
# Detected: AWS credentials
aws_access_key_id = AKIAIOSFODNN7EXAMPLE # gitleaks:allow
# Detected: Database password
DB_URL = "postgresql://user:Pa$$w0rd@localhost/db" # gitleaks:allow
# Detected: Private key # gitleaks:allow
-----BEGIN RSA PRIVATE KEY----- # gitleaks:allow
MIIEpAIBAAKCAQEA... # gitleaks:allowManaging False Positives
Excluding Files
In .gitleaks.toml:
[allowlist]
paths = [
'''package-lock\.json$''',
'''.*\.lock$''',
'''test/.*\.py$''',
]Inline Ignore Comments
# In code, mark false positives
api_key = "test-key-1234" # gitleaks:allow
# Works in any language comment style
password = "fake-password" # gitleaks:allowSecurity Best Practices
Never Commit Secrets
- Use environment variables: Store secrets in .env files (gitignored)
- Use secret managers: AWS Secrets Manager, HashiCorp Vault, etc.
- Use CI/CD secrets: GitHub Secrets, GitLab CI/CD variables
- Rotate leaked secrets: If accidentally committed, rotate immediately
Secrets File Management
# Example .gitignore for secrets
.env
.env.local
.env.*.local
*.pem
*.key
credentials.json
config/secrets.yml
.api_tokensHandling Legitimate Secrets in Repo
For test fixtures or examples:
# 1. Use obviously fake values
API_KEY = "fake-key-for-testing-only" # gitleaks:allow
# 2. Use placeholders
API_KEY = "<your-api-key-here>" # gitleaks:allow
# 3. Add path exclusion in .gitleaks.toml for test fixturesEmergency: Secret Leaked to Git History
If a secret is committed and pushed:
Immediate Actions
# 1. ROTATE THE SECRET IMMEDIATELY
# - Change passwords, revoke API keys, regenerate tokens
# - Do this BEFORE cleaning git history
# 2. Remove from current commit (if just committed)
git reset --soft HEAD~1
# Remove secret from files
git add .
git commit -m "fix(security): remove leaked credentials"
# 3. Force push (if not shared widely)
git push --force-with-lease origin branch-nameFull History Cleanup
# Use git-filter-repo to remove from all history
pip install git-filter-repo
# Remove specific file from all history
git filter-repo --path path/to/secret/file --invert-paths
# Remove specific string from all files
git filter-repo --replace-text <(echo "SECRET_KEY=abc123==>SECRET_KEY=REDACTED")Prevention
# Always run security checks before committing
pre-commit run gitleaks
# Check what's being committed
git diff --cached
# Use .gitignore for sensitive files
echo ".env" >> .gitignore
echo ".api_tokens" >> .gitignoreWorkflow Integration
Daily Development Flow
# Before staging any files
gitleaks protect --staged
pre-commit run --all-files
# Stage changes
git add src/feature.ts
# Final check before commit
git diff --cached # Review changes
gitleaks protect --staged # One more scan
# Commit
git commit -m "feat(feature): add new capability"CI/CD Integration
# Example GitHub Actions workflow
name: Security Checks
on: [push, pull_request]
jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Gitleaks
uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}Troubleshooting
Too Many False Positives
# Check what rules are triggering
gitleaks detect --source . --verbose 2>&1 | head -50
# Add targeted allowlists in .gitleaks.toml
# Use path exclusions for test fixtures
# Use regex exclusions for known safe patterns
# Use inline gitleaks:allow for individual linesPre-commit Hook Failing
# Run pre-commit in verbose mode
pre-commit run gitleaks --verbose
# Check gitleaks config validity
gitleaks detect --source . --config .gitleaks.toml --verbose
# Update pre-commit hooks
pre-commit autoupdateScanning Git History
# Scan entire git history for leaked secrets
gitleaks detect --source . --log-opts="--all"
# Scan specific commit range
gitleaks detect --source . --log-opts="HEAD~10..HEAD"
# Generate JSON report
gitleaks detect --source . --report-format json --report-path gitleaks-report.jsonTools Reference
Gitleaks Commands
# Detect secrets in repository
gitleaks detect --source .
# Protect staged changes (pre-commit mode)
gitleaks protect --staged
# Scan with custom config
gitleaks detect --source . --config .gitleaks.toml
# Verbose output
gitleaks detect --source . --verbose
# JSON report
gitleaks detect --source . --report-format json --report-path report.json
# Scan git history
gitleaks detect --source . --log-opts="--all"
# Scan specific commit range
gitleaks detect --source . --log-opts="main..HEAD"pre-commit Commands
# Install hooks
pre-commit install
# Run all hooks
pre-commit run --all-files
# Run specific hook
pre-commit run gitleaks
# Update hook versions
pre-commit autoupdate
# Uninstall hooks
pre-commit uninstall#!/usr/bin/env bash
# Security Scan Script
# Runs a comprehensive security scan pipeline in one execution.
# Usage: bash security-scan.sh [--staged-only]
#
# Checks: gitleaks, gitignore patterns, sensitive file detection,
# high-entropy strings in staged files.
set -uo pipefail
STAGED_ONLY=false
[ "${1:-}" = "--staged-only" ] && STAGED_ONLY=true
echo "=== SECURITY SCAN ==="
echo "MODE=$([ "$STAGED_ONLY" = true ] && echo "staged-only" || echo "full")"
echo ""
findings=0
# Check 1: gitleaks (if available)
echo "--- GITLEAKS ---"
if command -v gitleaks >/dev/null 2>&1; then
if [ "$STAGED_ONLY" = true ]; then
scan_output=$(gitleaks protect --staged --no-banner 2>&1)
scan_exit=$?
else
scan_output=$(gitleaks detect --source . --no-banner 2>&1)
scan_exit=$?
fi
if [ $scan_exit -ne 0 ]; then
echo "STATUS=secrets_found"
echo "$scan_output" | head -20
findings=$((findings + 1))
else
echo "STATUS=clean"
fi
# Check for .gitleaks.toml config
if [ -f ".gitleaks.toml" ]; then
echo "CONFIG=present"
else
echo "CONFIG=missing"
echo "HINT: Create .gitleaks.toml for project-specific allowlists"
fi
else
echo "STATUS=not_installed"
echo "HINT: brew install gitleaks (or go install github.com/gitleaks/gitleaks/v8@latest)"
fi
echo ""
# Check 2: Sensitive file patterns in staged/tracked files
echo "--- SENSITIVE FILES ---"
sensitive_patterns=(
".env"
".env.local"
".env.production"
"credentials.json"
"service-account.json"
"*.pem"
"*.key"
"*.p12"
"*.pfx"
"id_rsa"
"id_ed25519"
".api_tokens"
"secrets.yml"
"secrets.yaml"
".gcp-credentials.json"
)
if [ "$STAGED_ONLY" = true ]; then
file_list=$(git diff --cached --name-only 2>/dev/null)
else
file_list=$(git ls-files 2>/dev/null)
fi
echo "FOUND:"
for pattern in "${sensitive_patterns[@]}"; do
matches=$(echo "$file_list" | grep -E "(^|/)${pattern}$" 2>/dev/null || true)
if [ -n "$matches" ]; then
while IFS= read -r line; do printf ' - %s\n' "$line"; done <<< "$matches"
findings=$((findings + 1))
fi
done
[ $findings -eq 0 ] && echo " none"
echo ""
# Check 3: Gitignore coverage
echo "--- GITIGNORE COVERAGE ---"
if [ -f ".gitignore" ]; then
echo "GITIGNORE=present"
missing_patterns=()
for pattern in ".env" "*.pem" "*.key" "credentials.json" ".api_tokens"; do
if ! grep -qF "$pattern" .gitignore 2>/dev/null; then
missing_patterns+=("$pattern")
fi
done
if [ ${#missing_patterns[@]} -gt 0 ]; then
echo "MISSING_PATTERNS:"
printf ' - %s\n' "${missing_patterns[@]}"
findings=$((findings + 1))
else
echo "COVERAGE=good"
fi
else
echo "GITIGNORE=missing"
echo "HINT: Create .gitignore with sensitive file patterns"
findings=$((findings + 1))
fi
echo ""
# Check 4: High-entropy strings in staged files (simple heuristic)
echo "--- HIGH ENTROPY STRINGS ---"
if [ "$STAGED_ONLY" = true ]; then
diff_content=$(git diff --cached 2>/dev/null)
else
diff_content=$(git diff 2>/dev/null)
fi
if [ -n "$diff_content" ]; then
# Look for common secret patterns in diffs
suspect_lines=$(echo "$diff_content" | grep -n "^+" | grep -iE "(api[_-]?key|secret|token|password|credential|private[_-]?key)\s*[:=]" 2>/dev/null | grep -v "^+++ " | head -10)
if [ -n "$suspect_lines" ]; then
echo "SUSPECT_PATTERNS:"
echo "$suspect_lines" | sed 's/^/ /' | head -10
findings=$((findings + 1))
else
echo "STATUS=clean"
fi
else
echo "STATUS=no_diff"
fi
echo ""
# Check 5: Pre-commit hook status
echo "--- PRE-COMMIT STATUS ---"
if [ -f ".pre-commit-config.yaml" ]; then
echo "CONFIG=present"
gitleaks_hook=$(grep -A2 "gitleaks" .pre-commit-config.yaml 2>/dev/null | head -3)
if [ -n "$gitleaks_hook" ]; then
echo "GITLEAKS_HOOK=configured"
else
echo "GITLEAKS_HOOK=not_configured"
echo "HINT: Add gitleaks hook to .pre-commit-config.yaml"
fi
# Check if hooks are installed
if [ -f ".git/hooks/pre-commit" ] && grep -q "pre-commit" .git/hooks/pre-commit 2>/dev/null; then
echo "HOOKS_INSTALLED=true"
else
echo "HOOKS_INSTALLED=false"
echo "HINT: Run 'pre-commit install'"
fi
else
echo "CONFIG=missing"
echo "HINT: Create .pre-commit-config.yaml with security hooks"
fi
echo ""
# Summary
echo "=== SCAN SUMMARY ==="
echo "TOTAL_FINDINGS=$findings"
if [ $findings -eq 0 ]; then
echo "STATUS=PASS"
else
echo "STATUS=FINDINGS_DETECTED"
fi
echo "=== SCAN COMPLETE ==="
exit "$([ $findings -gt 0 ] && echo 1 || echo 0)"