security-scan · cloudai-x — Claude Code command: secrets, CVEs, risky patterns
security-scan is a command for Claude Code that checks a repository for hardcoded secrets, vulnerable dependencies, injection, XSS and weak config before a commit or PR.
MIT ★ 1,424 updated 2026-10-06
.claude/commands/security-scan.mdWhat security-scan does
Four passes over the repo. The first one greps for credentials typed straight into source: passwords, tokens, API keys, across JS, TS, Python, Go, Java, Ruby, JSON and YAML files. It also looks at .env* files with templates skipped, AWS key IDs and private key files such as *.pem, *.key and id_rsa.
Then a dependency audit runs through whatever the project already uses: npm audit or yarn audit, pip-audit or safety check, govulncheck ./..., cargo audit. After that the command reads code for injection and XSS shapes: SQL built by string concatenation, exec, system or subprocess fed with user input, innerHTML and dangerouslySetInnerHTML left unsanitised, file paths taken from input without a .. check.
The last pass is a config checklist: debug mode off in production, HTTPS only, CORS, headers like CSP and X-Frame-Options, no default passwords. Results come back as PASS, FAIL or WARNINGS with counts. Each finding carries a file, a line and a fix; vulnerable packages get severity, CVE number and the version that resolves them.
Those audit tools have to be installed, and their stderr goes to 2>/dev/null. A missing pip-audit or cargo audit leaves that section empty, so the report ends up looking cleaner than the code.
What it helps with
- catch a token pasted into source before it reaches a push
- check dependencies for known CVEs before a release
- spot SQL string concatenation and
execcalls fed with user input - walk the config checklist: debug mode, HTTPS, CORS, headers
- get a report with file and line instead of a vague warning
Example prompts for the agent
- Run
/project-starter:security-scanon the repo before I commit. - Run
/project-starter:security-scanand show only the critical findings. - Run
/project-starter:security-scan, then tell me which versions fix the CVEs it found.
How to install security-scan
Manually: put the files in place
.claude/commands/security-scan.mdCall it with /security-scan. For all projects use ~/.claude/commands/
Manually: put the files in place
~/.codex/prompts/security-scan.mdCall it with /prompts:security-scan. Codex marks this format deprecated in favour of skills
Manually: put the files in place
.github/prompts/security-scan.prompt.mdManually: put the files in place
.gemini/commands/security-scan.tomlGemini stores commands as TOML: the prompt text goes into the prompt field
Questions about security-scan
How do I install security-scan in Claude Code?
Place the command file at .claude/commands/security-scan.md and it becomes available in the project. Inside the project-starter plugin you call it with the namespace: /project-starter:security-scan.
What does security-scan do?
It looks for hardcoded secrets, audits dependencies for known vulnerabilities, reviews code for injection and XSS, and checks config against a checklist. The output is a report marked PASS, FAIL or WARNINGS.
What does the dependency audit need?
An audit tool for the project's language: npm audit or yarn audit, pip-audit or safety check, govulncheck, cargo audit. Without one installed that check returns nothing, since its error is sent to 2>/dev/null.
Source text
security-scan.md · MIT
---
description: Security-focused code scan. Checks for hardcoded secrets, vulnerable dependencies, and common security issues.
---
# Security Scan
Security-focused code scanning. Run before commits and PRs to catch vulnerabilities.
## Phase 1: Secret Detection
Scan for hardcoded credentials:
```bash
# Common secret patterns (-E: extended regex, so ? and {n} work)
grep -rnE "(password|passwd|secret|token|api[_-]?key)[[:space:]]*[=:][[:space:]]*['\"]" --include="*.js" --include="*.jsx" --include="*.ts" --include="*.tsx" --include="*.py" --include="*.go" --include="*.java" --include="*.rb" --include="*.json" --include="*.yml" --include="*.yaml" --exclude-dir=node_modules --exclude-dir=.git . 2>/dev/null
# Secrets in .env files (templates excluded)
grep -rnE "^[A-Za-z0-9_]*(PASSWORD|SECRET|TOKEN|API_KEY)[A-Za-z0-9_]*=.+" --include=".env*" --exclude=".env.example" --exclude=".env.template" --exclude=".env.sample" --exclude-dir=node_modules --exclude-dir=.git . 2>/dev/null
# AWS keys
grep -rnE "AKIA[0-9A-Z]{16}" --exclude-dir=node_modules --exclude-dir=.git . 2>/dev/null
# Private keys
find . \( -name "*.pem" -o -name "*.key" -o -name "id_rsa" \) -not -path "./node_modules/*" -not -path "./.git/*" 2>/dev/null
```
## Phase 2: Dependency Audit
Check for vulnerable dependencies:
### Node.js
```bash
npm audit --json 2>/dev/null | head -100
# or
yarn audit --json 2>/dev/null | head -100
```
### Python
```bash
pip-audit 2>/dev/null || safety check 2>/dev/null
```
### Go
```bash
govulncheck ./... 2>/dev/null
```
### Rust
```bash
cargo audit 2>/dev/null
```
## Phase 3: Code Pattern Analysis
Check for dangerous patterns:
### SQL Injection
- String concatenation in SQL queries
- Unparameterized queries
- Dynamic table/column names from user input
### Command Injection
- Shell execution with user input (`exec`, `system`, `subprocess`)
- Unsanitized path construction
### XSS Vulnerabilities
- `innerHTML` with user data
- `dangerouslySetInnerHTML` without sanitization
- Unescaped template variables
### Path Traversal
- User input in file paths without sanitization
- Missing `..` checks
## Phase 4: Configuration Check
Verify security settings:
- [ ] Debug mode disabled in production configs
- [ ] HTTPS enforced (no HTTP URLs in prod)
- [ ] CORS properly configured
- [ ] Security headers present (CSP, X-Frame-Options, etc.)
- [ ] No default/weak passwords in configs
## Output Format
```
## Security Scan: [PASS/FAIL/WARNINGS]
### Secrets Detected: [count]
1. **CRITICAL** - `file:line`
- Type: [API key/password/token/private key]
- Action: Remove immediately and rotate credential
### Vulnerable Dependencies: [count]
1. **[package@version]** - Severity: [Critical/High/Medium/Low]
- CVE: [CVE number if available]
- Fixed in: [version]
- Action: Update to [version]
### Code Vulnerabilities: [count]
1. **[Vulnerability Type]** - `file:line`
- Risk: [description]
- Fix: [remediation steps]
### Configuration Issues: [count]
1. **[Issue]**
- Current: [state]
- Recommended: [secure state]
### Recommendations
1. [Prioritized action items]
```
## NEVER Commit If
- Secrets detected in code (rotate and remove)
- Critical CVEs in dependencies (update first)
- Obvious injection vulnerabilities (fix first)
## Usage
This command ships with the project-starter plugin. Invoke with: `/project-starter:security-scan`
© CloudAI-X · MIT · CloudAI-X/claude-workflow-v2
Similar slash commands
All slash commands for Security →security-scan by other authors comes first.