Treasures
Scan the current project for security vulnerabilities, code quality issues, dead code, and hidden oddities. Output a severity-ranked report.
Important
- Scan the ENTIRE project unless
$ARGUMENTS specifies a scope (e.g., auth/, src/api/)
- Never modify any files. This is a read-only audit
- Rank every finding by severity: CRITICAL, HIGH, MEDIUM, LOW, INFO, FUN
- Be specific — include file paths and line numbers for every finding
- Do not report style issues (formatting, naming). Focus on correctness and security
- False positives are worse than missed findings. Only report things you are confident about
Instructions
Step 1: Map the project
Read the project structure. Identify:
- Language/framework (package.json, requirements.txt, go.mod, Cargo.toml, etc.)
- Entry points (main files, route definitions, CLI entry)
- Configuration files (.env.example, config/, settings files)
- Test directories
Step 2: Security scan
Search for these patterns across the codebase:
CRITICAL / HIGH:
- Auth bypass flags or backdoors (
bypass, skip_auth, admin.*true, debug.*mode.*prod)
- Hardcoded secrets, API keys, passwords (
password\s*=, secret\s*=, api_key\s*=, token\s*= with actual values)
- SQL injection vectors (string concatenation in queries, f-strings in SQL)
- Command injection (
exec(, eval(, child_process.exec with user input)
- Unauthenticated endpoints that should require auth
- Deprecated crypto (MD5, SHA1 for authentication/signing, DES)
- Permissive CORS (
Access-Control-Allow-Origin: * on authenticated endpoints)
- Missing rate limiting on auth endpoints
MEDIUM:
- Secrets in example/template files (
.env.example with real values)
- Hidden feature flags (
DARK_LAUNCH, FEATURE_FLAG, BETA)
- Overly permissive file permissions in scripts
- Missing input validation on user-facing endpoints
- Unencrypted sensitive data in logs
LOW / INFO:
- Dead routes (defined but no callers)
- Unused exports/functions (exported but never imported elsewhere)
- TODO/HACK/FIXME comments that indicate known issues
- Commented-out code blocks (>10 lines)
- Stale dependencies (check for known-vulnerable versions if lockfile exists)
FUN:
- Easter eggs, hidden messages, joke comments
- Unusual file names or directories
Step 3: Dead code detection
Search for:
- Exported functions/classes never imported by other files
- Route handlers with no corresponding client calls (if both client and server are in repo)
- Config values defined but never read
- Test files for deleted source files
Step 4: Compile report
Output findings in this format:
TREASURES — [project-name] — [N] findings
CRITICAL ([count])
* [file:line] [description]
Evidence: [the matching code or pattern]
Risk: [what could go wrong]
HIGH ([count])
* [file:line] [description]
...
MEDIUM ([count])
...
LOW ([count])
...
INFO ([count])
...
FUN ([count])
...
SUMMARY: [1-2 sentence overall assessment]
Step 5: Offer next steps
After the report, offer:
- "Fix critical/high issues now" — walk through fixes one at a time
- "Create GitHub issues for HIGH+" — generate issue descriptions (if gh CLI available)
- "Re-scan [specific area]" — deeper dive into a flagged area
Error Handling
- No source code found: Report "No scannable source files found in [path]. Is this the right directory?"
- Scope argument doesn't exist: Report "Directory
$ARGUMENTS not found. Available top-level directories: [list]"
- Very large project (>1000 files): Scan top-level structure first, then focus on the most likely areas (auth, API, config, database)
Examples
Example 1: Full project scan
Input: /code-security
Process: Scans entire project, finds 3 HIGH issues in auth module, 2 MEDIUM in config, 1 FUN easter egg
Output: Severity-ranked report with file:line references
Example 2: Scoped scan
Input: /code-security src/auth/
Process: Deep scan of auth directory only
Output: Focused report on auth-related findings
Example 3: Clean project
Input: /code-security
Output: "TREASURES — acme-api — 0 critical/high findings. 2 LOW items (stale TODOs). Looking solid."
1---2name: code-security3description: Scan the current project for security issues, dead code, deprecated patterns, forgotten debug code, secrets in config, and hidden oddities. Use when user says 'scan for issues', 'find security problems', 'codebase audit', 'treasures', 'what's wrong with this codebase', 'find dead code', or 'security scan'. Do NOT use for code review of specific PRs (use review for that). Do NOT use for refactoring suggestions (use code-review for that).4---56# Treasures78Scan the current project for security vulnerabilities, code quality issues, dead code, and hidden oddities. Output a severity-ranked report.910## Important1112- Scan the ENTIRE project unless `$ARGUMENTS` specifies a scope (e.g., `auth/`, `src/api/`)13- Never modify any files. This is a read-only audit14- Rank every finding by severity: CRITICAL, HIGH, MEDIUM, LOW, INFO, FUN15- Be specific — include file paths and line numbers for every finding16- Do not report style issues (formatting, naming). Focus on correctness and security17- False positives are worse than missed findings. Only report things you are confident about1819## Instructions2021### Step 1: Map the project2223Read the project structure. Identify:24- Language/framework (package.json, requirements.txt, go.mod, Cargo.toml, etc.)25- Entry points (main files, route definitions, CLI entry)26- Configuration files (.env.example, config/, settings files)27- Test directories2829### Step 2: Security scan3031Search for these patterns across the codebase:3233**CRITICAL / HIGH:**34- Auth bypass flags or backdoors (`bypass`, `skip_auth`, `admin.*true`, `debug.*mode.*prod`)35- Hardcoded secrets, API keys, passwords (`password\s*=`, `secret\s*=`, `api_key\s*=`, `token\s*=` with actual values)36- SQL injection vectors (string concatenation in queries, f-strings in SQL)37- Command injection (`exec(`, `eval(`, `child_process.exec` with user input)38- Unauthenticated endpoints that should require auth39- Deprecated crypto (MD5, SHA1 for authentication/signing, DES)40- Permissive CORS (`Access-Control-Allow-Origin: *` on authenticated endpoints)41- Missing rate limiting on auth endpoints4243**MEDIUM:**44- Secrets in example/template files (`.env.example` with real values)45- Hidden feature flags (`DARK_LAUNCH`, `FEATURE_FLAG`, `BETA`)46- Overly permissive file permissions in scripts47- Missing input validation on user-facing endpoints48- Unencrypted sensitive data in logs4950**LOW / INFO:**51- Dead routes (defined but no callers)52- Unused exports/functions (exported but never imported elsewhere)53- TODO/HACK/FIXME comments that indicate known issues54- Commented-out code blocks (>10 lines)55- Stale dependencies (check for known-vulnerable versions if lockfile exists)5657**FUN:**58- Easter eggs, hidden messages, joke comments59- Unusual file names or directories6061### Step 3: Dead code detection6263Search for:64- Exported functions/classes never imported by other files65- Route handlers with no corresponding client calls (if both client and server are in repo)66- Config values defined but never read67- Test files for deleted source files6869### Step 4: Compile report7071Output findings in this format:7273```74TREASURES — [project-name] — [N] findings7576CRITICAL ([count])77 * [file:line] [description]78 Evidence: [the matching code or pattern]79 Risk: [what could go wrong]8081HIGH ([count])82 * [file:line] [description]83 ...8485MEDIUM ([count])86 ...8788LOW ([count])89 ...9091INFO ([count])92 ...9394FUN ([count])95 ...9697SUMMARY: [1-2 sentence overall assessment]98```99100### Step 5: Offer next steps101102After the report, offer:103- "Fix critical/high issues now" — walk through fixes one at a time104- "Create GitHub issues for HIGH+" — generate issue descriptions (if gh CLI available)105- "Re-scan [specific area]" — deeper dive into a flagged area106107## Error Handling1081091. **No source code found**: Report "No scannable source files found in [path]. Is this the right directory?"1102. **Scope argument doesn't exist**: Report "Directory `$ARGUMENTS` not found. Available top-level directories: [list]"1113. **Very large project (>1000 files)**: Scan top-level structure first, then focus on the most likely areas (auth, API, config, database)112113## Examples114115### Example 1: Full project scan116**Input**: `/code-security`117**Process**: Scans entire project, finds 3 HIGH issues in auth module, 2 MEDIUM in config, 1 FUN easter egg118**Output**: Severity-ranked report with file:line references119120### Example 2: Scoped scan121**Input**: `/code-security src/auth/`122**Process**: Deep scan of auth directory only123**Output**: Focused report on auth-related findings124125### Example 3: Clean project126**Input**: `/code-security`127**Output**: "TREASURES — acme-api — 0 critical/high findings. 2 LOW items (stale TODOs). Looking solid."