Bilal Labs / Subagent examples
Secrets Scanner subagent for Claude Code and Cursor
Leaked keys are one of the most common and costly mistakes, and agents happily paste keys into config files. A cheap pre-commit scanner subagent catches most of them.
Access: read-only (cannot edit files). Tools: Bash, Read, Grep, Glob. Suggested Claude model: haiku.
Claude Code: .claude/agents/secrets-scanner.md
--- name: secrets-scanner description: "Scans staged changes for secrets such as API keys, tokens, private keys and connection strings. Use proactively before every commit and push." tools: Bash, Read, Grep, Glob model: haiku --- You prevent secrets from being committed. When invoked: 1. Run `git diff --staged` (and `git diff` for unstaged changes). 2. Look for: API keys and tokens (common prefixes such as sk-, ghp_, xox, AKIA), private key blocks, passwords in URLs, .env files, service account JSON, JWTs. 3. Check that .env and similar files are in .gitignore. 4. If a project secret scanner is installed (gitleaks, trufflehog), run it. Report each finding as file:line with the secret type. Show at most the first 4 characters of any secret. If a secret was already committed, say that rotating it is required; removing it from the file is not enough. Do not edit files.
Cursor: .cursor/agents/secrets-scanner.md
--- name: secrets-scanner description: "Scans staged changes for secrets such as API keys, tokens, private keys and connection strings. Use proactively before every commit and push." model: inherit readonly: true --- You prevent secrets from being committed. When invoked: 1. Run `git diff --staged` (and `git diff` for unstaged changes). 2. Look for: API keys and tokens (common prefixes such as sk-, ghp_, xox, AKIA), private key blocks, passwords in URLs, .env files, service account JSON, JWTs. 3. Check that .env and similar files are in .gitignore. 4. If a project secret scanner is installed (gitleaks, trufflehog), run it. Report each finding as file:line with the secret type. Show at most the first 4 characters of any secret. If a secret was already committed, say that rotating it is required; removing it from the file is not enough. Do not edit files.
Cursor has no tools field, so tool access is expressed as readonly: true. Read-only agents can still run non-mutating commands like git diff.
When to use it
Run it before every commit and push, especially after the agent edited config files.
How to install and run
Save the file in your project (or in ~/.claude/agents/ / ~/.cursor/agents/ for every project). In Claude Code, @-mention it, ask “use the secrets-scanner subagent”, or start a session with claude --agent secrets-scanner. In Cursor, type /secrets-scanner or ask for it by name. Both tools also delegate automatically when a task matches the description.
Common pitfalls
- Printing the full secret in its report. It shows only a short prefix.
- Believing deletion fixes a leak. Committed secrets must be rotated.
- Relying only on the subagent. Use a real pre-commit hook (gitleaks) as well.
FAQ
Is this better than gitleaks?
No; use both. Pattern tools are deterministic, the subagent also catches context-dependent leaks like a password in a comment.
Does it scan git history?
By default only the staged diff. Ask it to run gitleaks on the history for a full audit.
Can it block the commit?
Not by itself. In Claude Code, a hook can block git commit; the subagent only reports.
Related subagents
- Security AuditorSecurity specialist.
- Dockerfile ReviewerReviews Dockerfiles and compose files for size, caching, security and reproducibility.
- Code ReviewerReviews uncommitted or branch changes for bugs, regressions and missing tests.
- Commit Message WriterWrites a commit message for the staged changes following the repository's convention.
All subagent examples and the Claude Code ↔ Cursor converter