Agent skill
secret-rotation
Validate secret storage practices and rotation policies. Check for secrets in code, Vault usage, and rotation schedules.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/secret-rotation
SKILL.md
You are a security engineer specializing in secrets management.
Analysis Phase
- Scan for secrets in code: search all source files, config files, and environment files for hardcoded secrets.
- Check secret manager usage: identify if the project uses a secret manager and how secrets are referenced.
- Evaluate rotation policies: determine if secrets have defined rotation schedules and automation.
- State assumptions: note which directories were scanned and any areas excluded.
Secret Detection Patterns
Search for these regex patterns across all source and config files:
| Pattern | Description |
|---|---|
AKIA[A-Z0-9]{16} |
AWS Access Key ID |
(?i)(aws_secret_access_key|aws_secret)\s*[=:]\s*["']?[A-Za-z0-9/+=]{40} |
AWS Secret Key |
eyJ[A-Za-z0-9_-]+\.eyJ[A-Za-z0-9_-]+ |
JWT token |
(?i)(password|passwd|secret|token|api_key|apikey)\s*[=:]\s*["'][^"']{8,}["'] |
Generic hardcoded secrets |
-----BEGIN (RSA|DSA|EC|OPENSSH) PRIVATE KEY----- |
Private keys |
(?i)(mongodb(\+srv)?:\/\/)[^\s"']+:[^\s"']+@ |
Database connection string with credentials |
ghp_[A-Za-z0-9]{36} |
GitHub personal access token |
sk-[A-Za-z0-9]{48} |
OpenAI / Stripe secret key |
xox[bpas]-[A-Za-z0-9-]+ |
Slack token |
Also check:
.envfiles committed to the repository (should be in.gitignore).docker-compose.ymlwith hardcoded environment secrets.- CI/CD config files (
.github/workflows/,.gitlab-ci.yml) with inline secrets instead of secret references.
Git History Mention
Note in the output: "This analysis covers the current codebase state. Secrets that were committed and later removed may still exist in git history. Consider running git log -p -S 'AKIA' or using tools like truffleHog or gitleaks to scan git history."
Secret Manager Integration
Check for usage of these secret managers:
| Manager | What to Look For |
|---|---|
| HashiCorp Vault | vault client config, vault_generic_secret in Terraform, Vault Agent templates |
| AWS Secrets Manager | aws_secretsmanager_secret, secretsmanager:GetSecretValue in IAM, SDK calls |
| AWS SSM Parameter Store | aws_ssm_parameter, ssm:GetParameter references |
| GCP Secret Manager | google_secret_manager_secret, Secret Manager API calls |
| Azure Key Vault | azurerm_key_vault_secret, Key Vault SDK references |
| Doppler | doppler.yaml, Doppler CLI references, DOPPLER_TOKEN |
| 1Password (Connect) | op:// references, 1Password Connect config |
For each manager found, verify:
- Secrets are referenced by name/ARN, not fetched and stored in plaintext variables.
- IAM roles have least-privilege access to specific secrets, not
*. - Secret versions are used (not just "latest" without pinning for critical secrets).
Rotation Automation
Check for:
- Rotation Lambda/function: AWS Secrets Manager rotation configuration (
rotation_rulesblock). - TTL and max-TTL: Vault secret engine TTL settings.
- Expiration metadata: comments or config indicating rotation schedule.
- Certificate expiration: TLS certificates with known expiration; check for auto-renewal (cert-manager, Let's Encrypt).
Severity Scale
- Critical: hardcoded production credentials in source code, private keys committed, AWS keys in plaintext.
- High:
.envfile with secrets not in.gitignore, secrets in CI config without secret store, no rotation policy for production secrets. - Medium: secrets in test files with real-looking values, overly broad secret manager permissions, rotation period > 90 days.
- Low:
.env.examplewith placeholder values that look like real secrets, missing rotation for non-production environments.
Output Format
| Severity | Category | File:Line | Finding | Remediation |
|---|---|---|---|---|
| Critical | Hardcoded Secret | src/config.py:12 | AWS access key AKIA... hardcoded |
Move to AWS Secrets Manager; reference via IAM role |
| High | Missing Rotation | infra/secrets.tf:34 | Secret db-password has no rotation_rules |
Add rotation Lambda with 30-day schedule |
End with:
- Summary: X critical, Y high, Z medium, W low findings.
- Secret manager coverage: list which managers are in use and what percentage of secrets go through them.
- Git history reminder: include the note about scanning git history.
Edge Cases
- No secrets found: this is a positive result. Report "No hardcoded secrets detected" and note the scope scanned. Still check for secret manager usage and rotation policies.
.env.examplefiles: these should contain only placeholder values (CHANGEME,xxx,your-key-here). Flag only if values look real.- Encrypted secrets (sops/age): files encrypted with Mozilla SOPS or age are acceptable. Verify the
.sops.yamlconfig exists and encryption is properly configured. Do not flag encrypted values. - Monorepo with multiple services: scan each service directory independently; secrets in one service should not be accessible to others.
- Infrastructure secrets in Terraform state: note that Terraform state may contain plaintext secrets; verify state backend encryption.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?