Install
openclaw skills install code-security-checkAudit the current project for sensitive information leaks before pushing to public repositories. This skill should be used when the user asks to check for security issues, scan for secrets, review .gitignore coverage, audit a project before open-sourcing, or when they mention keywords like "安全检查", "敏感信息", "泄露", "gitignore", "密钥", "API key leak", "before pushing to GitHub", "开源检查". It scans the working tree for exposed credentials, API keys, tokens, private keys, and misconfigured .gitignore files.
openclaw skills install code-security-checkScan the current project for sensitive information leaks that could be exposed when pushing to a public repository. This skill uses AI directly to read and analyze files — no scripts, no regex database to maintain. The AI understands context, recognizes novel key formats, and avoids the brittleness of pattern matching.
Trigger this skill when the user says things like:
The audit proceeds in six phases. Complete each phase before moving to the next.
CRITICAL — Phase 0 MUST run first. It determines whether a full audit is even necessary. Do not skip it. Do not lead with "let me scan your code" — first check if there's any real risk.
Goal: Determine whether the project has any public exposure risk. If not, exit early with a friendly reminder — do NOT bother the user with a full detailed scan. Only non-public / local projects have no leak risk.
Step 1 — Check if this is a git repo:
Run git status in the project root. If the command fails (not a git repo):
🟢 这是一个本地项目,未使用 Git 管理。本地文件不存在公开泄露风险,无需担心。
→ EXIT. Do not proceed to further phases. Do not ask to fix anything.
Step 2 — Check for remote (for git repos only):
Run git remote -v. If no remote is configured:
🟢 这是一个本地 Git 仓库,尚未关联远程仓库(没有 remote),代码不会被推送到任何公开位置,不存在泄露风险。 💡 友情提醒:如果未来要推送到公开仓库,建议提前配置
.gitignore防止构建产物和依赖被提交。
→ EXIT. Do not proceed to further phases. Do not ask to fix anything — a quick reminder is enough.
Step 3 — Check remote visibility (for repos with a remote):
If the remote appears to be on GitHub, try to check its visibility:
gh repo view --json visibility 2>/dev/null || echo "CANNOT_DETERMINE"
visibility is PRIVATE:🟢 远程仓库是私有仓库(private),非公开项目不存在泄露风险。 💡 友情提醒:确保
.gitignore配置正确,以防将来改为公开仓库时出现意外。
→ EXIT. Do not proceed to further phases. A friendly reminder is sufficient.
visibility is PUBLIC → proceed to full audit (Phase 1–5).CANNOT_DETERMINE (not GitHub, or gh CLI not available) → proceed to full audit with a caveat:
⚠️ 无法确定远程仓库的可见性,按公开仓库标准进行完整检查。
Goal: Understand what kind of project this is and what files exist.
package.json → Node.js / TypeScriptrequirements.txt, pyproject.toml, Pipfile → Pythongo.mod → Gopom.xml, build.gradle, build.gradle.kts → Java / KotlinGemfile → RubyCargo.toml → Rustcomposer.json → PHPDockerfile, docker-compose.yml → Docker*.tf → Terraform.firebaserc → Firebasegit ls-files --others --exclude-standard to list untracked files. These are
high-risk because they slip past .gitignore and could be accidentally committed.Goal: Check if .gitignore exists and whether it covers the basics.
Read .gitignore if it exists. If not, this is a critical finding — note it.
For the detected tech stack, check whether essential patterns are covered. Key patterns by stack:
| Stack | Must-have in .gitignore |
|---|---|
| Node.js | .env, .env.*, node_modules/ |
| Python | .env, .env.*, __pycache__/, venv/, *.pyc |
| Go | .env, .env.*, *.exe, *.test |
| Java | .env, .env.*, *.class, target/ |
| Ruby | .env, .env.*, *.gem, vendor/bundle/ |
| Rust | .env, .env.*, target/ |
| Docker | .env, .env.* |
| Terraform | *.tfstate, *.tfstate.*, .terraform/, terraform.tfvars |
| Firebase | google-services.json, GoogleService-Info.plist, .env |
| Any | *.pem, *.key, *.p12, *.pfx, credentials.json, *.log |
Note any missing patterns as findings.
Goal: Find files that might contain secrets, then use AI to analyze them.
Step 1 — Structural scan (fast, no content reading yet):
Use Glob to find files that commonly hold secrets:
**/.env
**/.env.*
**/.npmrc
**/credentials.json
**/credentials.*.json
**/service-account.json
**/service-account-*.json
**/google-services.json
**/GoogleService-Info.plist
**/secrets.yaml
**/secrets.yml
**/secret*
**/terraform.tfvars
**/*.tfstate
**/*.tfstate.backup
**/config/database.yml
**/config/secrets.yml
**/config/master.key
**/.aws/credentials
**/aws-credentials.json
Also look for private key files: id_rsa, id_ed25519, id_ecdsa, *.pem, *.key, *.p12, *.pfx.
Step 2 — Quick content pre-filter (optional, use Grep):
For efficiency on larger projects, run a few broad Grep queries to narrow down which text files are worth reading:
# Files that look like they contain API keys or tokens
(sk-|ghp_|github_pat_|AKIA|AIza|xox[baprs]-|sk_live_|eyJ|-----BEGIN)
Step 3 — AI Analysis of suspicious files:
Read each identified file. For each file, analyze its content and determine:
.gitignore?git ls-files to check)Be thorough but smart — skip obvious false positives like:
YOUR_API_KEY, changeme, xxxx).gitignorePresent findings to the user in a clear, organized format.
Report structure:
Project summary: Tech stack detected, total files scanned.
.gitignore status: Exists? Coverage gaps?
Findings table with columns:
| Severity | File | Line | What was found |
|---|---|---|---|
| 🔴 Critical | config.js | 12 | GitHub personal access token |
| 🟡 High | .env | 3 | OpenAI API key |
| 🟢 Medium | app.config | 5 | Database password |
Overall verdict: SAFE / CAUTION / DANGER with explanation.
Severity definitions:
| Level | Criteria |
|---|---|
| 🔴 Critical | Production API keys, private keys, GitHub tokens, database credentials that would grant real access |
| 🟡 High | Service tokens, internal API keys, any credential in a file not in .gitignore |
| 🟢 Medium | Suspicious assignments, configuration with credentials, files missing from .gitignore that should be ignored |
Important — never display full secrets. Redact them: show first 4 and last 4 characters
with **** between. E.g., ghp_****abcd.
After presenting the report, ask the user whether to proceed with fixes. Do NOT modify any files until the user explicitly confirms.
If user confirms, proceed with:
.gitignore: Generate or update it.
.gitignore with patterns for the detected tech stack.Untrack files already committed: For sensitive files tracked by git, suggest:
git rm --cached <file> # stop tracking, keep local copy
Then add the pattern to .gitignore.
Best practices reminders:
.env.example with placeholder values instead of committing real .envdetect-secrets, gitleaks, or git-secretsnode_modules/, vendor/, .venv/, target/, etc..gitignore — files already ignored are not a risk (but an untracked .env that
is NOT in .gitignore IS a risk).