
Security Check
- 2 installs
- 2.2k repo stars
- Updated July 27, 2026
- alibaba/loongcollector
security-check is a Claude skill that scans staged changes and commits for leaked API keys and tokens before commit or push and blocks the action if secrets are found.
About
This skill scans code for sensitive information such as API keys and access tokens before a commit or push. A developer uses it to run a pre-commit check on the staging area and a pre-push check across commits, detecting patterns like sk-, AIzaSy, and pk_ keys. If secrets are found it requires replacing them with placeholders or environment variables and refusing the commit or push, and it can clean git history.
- Scans staged changes and commits for secrets before commit/push
- Detects API keys and tokens like sk-, AIzaSy, and pk_ prefixes
- Refuses the commit/push and can clean history when secrets are found
Security Check by the numbers
- 2 all-time installs (skills.sh)
- +1 installs in the week ending Jun 23, 2026 (Skillselion tracking)
- Ranked #1,788 of 2,203 Security skills by installs in the Skillselion catalog
- Data as of Aug 4, 2026 (Skillselion catalog sync)
security-check capabilities & compatibility
- Capabilities
- security audit
- Works with
- github
- Use cases
- security audit
- Pricing
- Free
What security-check says it does
Security scanning before commit/push. Checks for sensitive information like API keys and tokens.
API Keys starting with `sk-` (OpenAI, Anthropic, Alibaba Cloud, etc.)
npx skills add https://github.com/alibaba/loongcollector --skill security-checkAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 2 |
|---|---|
| repo stars | ★ 2.2k |
| Last updated | July 27, 2026 |
| Repository | alibaba/loongcollector ↗ |
What it does
Scan staged changes and commits for leaked API keys and tokens before committing or pushing.
Who is it for?
Preventing accidental commits of API keys and access tokens by scanning staging and commit history
When should I use this skill?
Before committing or pushing code, to check for leaked secrets
What you get
A blocked commit/push when secrets are detected, with guidance to replace them and clean history
- secret scan result
- blocked commit/push on detection
- cleaned git history
By the numbers
- Detects 3 named key prefixes (sk-, AIzaSy, pk_)
Files
Security Check Rules
Before committing or pushing code, must check for sensitive information, especially API Keys and access tokens.
What to Check
API Keys and Access Tokens
- API Keys starting with
sk-(OpenAI, Anthropic, Alibaba Cloud, etc.) - Google API Keys starting with
AIzaSy - Public keys starting with
pk_ - Other common API token formats
Before Commit
Run Check First
Run bash .claude/skills/security-check/scripts/security_check.sh commit to check the staging area for sensitive information. If it does NOT output staging area is clear, sensitive information was found.
If Sensitive Information Found
1. Immediately delete or replace: Replace real API Keys with placeholders 2. Use environment variables: Move sensitive info to environment variables 3. Add to .gitignore: Ensure files with sensitive info are not committed 4. Must refuse the commit/push action
Before Push
Run Check First
Run bash .claude/skills/security-check/scripts/security_check.sh push to check each commit for sensitive information. If it does NOT output all commits are clear, sensitive information was found. The commit hashes are written to task/sensitive_commits.txt.
If Sensitive Information Found
1. Immediately delete or replace: Replace real API Keys with placeholders 2. Use environment variables: Move sensitive info to environment variables 3. Add to .gitignore: Ensure files with sensitive info are not committed 4. Must use the script below to clean history
# Reset based on results in task/sensitive_commits.txt to avoid leaking commits
bash .claude/skills/security-check/scripts/security_reset.sh5. Must refuse the commit/push action
#!/bin/bash
set -euo pipefail
SENSITIVE_PATTERNS="(sk-[a-zA-Z0-9]{20,}|AIzaSy[a-zA-Z0-9_-]{30,}|pk_[a-zA-Z0-9]{10,}|ghp_[a-zA-Z0-9]{36,}|gho_[a-zA-Z0-9]{36,}|ghu_[a-zA-Z0-9]{36,}|ghs_[a-zA-Z0-9]{36,}|ghr_[a-zA-Z0-9]{36,})"
MODE="${1:-}"
if [ "$MODE" != "commit" ] && [ "$MODE" != "push" ]; then
echo "Usage: $0 [commit|push]"
exit 2
fi
if [ "$MODE" == "commit" ]; then
# 检查暂存区中的 API Keys
echo "checking staging area"
if git diff --cached --no-prefix | grep '^+' | grep -E "$SENSITIVE_PATTERNS"; then
echo "⚠️ staging area contains SENSITIVE information"
else
echo "✅ staging area is clear"
fi
elif [ "$MODE" == "push" ]; then
# 检查所有要推送的 commit
is_clear=true
upstream=$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null) || upstream="origin/main"
mkdir -p task
> task/sensitive_commits.txt # 清空文件
while read -r commit; do
commit_hash=$(echo "$commit" | cut -d' ' -f1)
echo "checking commit: $commit"
if git show "$commit_hash" --no-commit-id --unified=0 | grep '^+' | grep -E "$SENSITIVE_PATTERNS"; then
echo "⚠️ commit $commit contains SENSITIVE information"
echo "$commit_hash" >> task/sensitive_commits.txt
is_clear=false
fi
echo "---"
done < <(git log "${upstream}"..HEAD --oneline)
if [ "$is_clear" = true ]; then
echo "✅ all commits are clear"
fi
fi#!/bin/bash
# 智能squash脚本 - 自动检测并清理包含敏感信息的commits
echo "🔍 开始清理包含敏感信息的commits..."
# 1. 检查task/sensitive_commits.txt文件是否存在且非空
if [ ! -f "task/sensitive_commits.txt" ] || [ ! -s "task/sensitive_commits.txt" ]; then
echo "❌ 未找到敏感commits列表,请先运行push前检查"
exit 1
fi
# 读取敏感commits列表
readarray -t sensitive_commits < task/sensitive_commits.txt
# 2. 如果发现敏感信息,进行智能squash
if [ ${#sensitive_commits[@]} -gt 0 ]; then
echo "🚨 发现 ${#sensitive_commits[@]} 个包含敏感信息的commits,开始清理..."
# 检查工作区是否干净
git status --porcelain | read -r _ && {
echo "⚠️ 工作区或暂存区有未提交的更改,先进行stash..."
git stash push -u -m "security-cleanup-backup-$(date +%Y%m%d-%H%M%S)"
stashed=true
} || stashed=false
# 获取要reset的目标commit
# 找到最早的敏感commit(数组最后一个),并获取其父commit
earliest_sensitive="${sensitive_commits[${#sensitive_commits[@]}-1]}"
parent_commit=$(git rev-parse --quiet "${earliest_sensitive}^")
# 获取所有需要被squash的commits(从最早的敏感commit的parent到HEAD)
if [ -n "$parent_commit" ]; then
commits_to_squash=($(git rev-list --reverse "${parent_commit}..HEAD"))
else
# 如果没有parent,说明最早的敏感commit是root commit
echo "⚠️ 最早的敏感commit是仓库的第一个commit"
commits_to_squash=($(git rev-list --reverse HEAD))
fi
if [ ${#commits_to_squash[@]} -eq 0 ]; then
echo "❌ 无法确定要squash的commit范围"
if [ "$stashed" = true ]; then
git stash pop
fi
exit 1
fi
# 获取所有要重新提交的commits的信息
echo "📝 提取所有commit messages..."
all_commit_details=""
main_subject=""
for commit_hash in "${commits_to_squash[@]}"; do
# 获取commit信息
subject=$(git log --format=%s -n 1 "$commit_hash")
body=$(git log --format=%b -n 1 "$commit_hash")
# 主题行用第一个commit的主题
if [ -z "$main_subject" ]; then
main_subject="$subject"
fi
subject_marker="$subject"
# 按GitHub squash格式添加commit详情
if [ -n "$body" ]; then
all_commit_details="${all_commit_details}* ${subject_marker}\n\n${body}\n\n"
else
all_commit_details="${all_commit_details}* ${subject_marker}\n\n"
fi
done
# 创建GitHub风格的squash commit message
new_message="${main_subject}\n\n${all_commit_details}"
# 执行squash
echo "🔄 执行squash操作..."
if [ -n "$parent_commit" ]; then
git reset --soft "$parent_commit"
else
echo "❌ 检测到最早敏感 commit 为 root commit,自动清理会涉及高风险历史重写,已中止。"
echo "请手动执行更安全流程(例如 orphan 分支重建)后再提交。"
if [ "$stashed" = true ]; then
echo "⚠️ 已为你恢复之前的工作区更改。"
git stash pop
fi
exit 1
fi
# 显示需要手动清理的文件
echo "📋 需要手动清理的文件:"
git status --porcelain | grep '^[AM]' | cut -c4-
echo ""
echo "✅ Squash完成!请执行以下步骤:"
echo "1. 手动清理上述文件中的敏感信息"
echo "2. 运行: git add ."
echo "3. 运行: git commit"
if [ "$stashed" = true ]; then
echo "4. 如需恢复之前的工作区更改: git stash pop"
fi
echo ""
echo "📝 新的commit message预览:"
echo "────────────────────────────────────────"
echo -e "$new_message"
echo "────────────────────────────────────────"
else
echo "✅ 未发现包含敏感信息的commits"
fi
Related skills
FAQ
What secret patterns does it detect?
API keys starting with sk-, Google keys starting with AIzaSy, public keys starting with pk_, and other common token formats.
What happens if a secret is found?
The skill requires replacing the secret with a placeholder or environment variable, adding it to .gitignore, and refusing the commit or push.