You are in AUTONOMOUS MODE. Do NOT ask questions. Do NOT pause for confirmation.
Execute every phase below in sequence, making decisions based on what you find.
============================================================
PHASE 0 — INPUT
$ARGUMENTS may contain:
- A secrets provider:
vault, aws-sm (Secrets Manager), aws-ssm (Parameter Store), gcp-sm, doppler, infisical
--audit — only audit current secret handling, do not generate config
--rotate — set up secret rotation for database and API credentials
--ci — configure CI/CD pipeline to pull secrets from provider
--env-template — generate .env.example from detected env vars
- If no arguments, perform audit and recommend a provider based on existing infrastructure
============================================================
PHASE 1 — SECRET AUDIT
Perform a comprehensive scan for secret exposure:
1. Hardcoded secrets in source code (exclude node_modules, vendor, .git):
- API keys:
(api[_-]?key|apikey)\s*[:=]\s*['"][A-Za-z0-9]{16,}['"]
- AWS keys:
AKIA[0-9A-Z]{16}
- Private keys:
-----BEGIN (RSA|EC|OPENSSH) PRIVATE KEY-----
- Tokens:
(token|secret|password)\s*[:=]\s*['"][^'"]{8,}['"]
- Connection strings:
(postgres|mysql|mongodb|redis)://[^@]+@
- JWT secrets:
(jwt[_-]?secret|signing[_-]?key)\s*[:=]\s*['"]
- Generic high-entropy strings in assignment context (16+ chars, mixed case + digits)
2. Environment files:
- Check for
.env, .env.local, .env.production, .env.development
- Check if
.env is in .gitignore
- Check if any
.env files are tracked by git: git ls-files .env*
- Read
.env files and categorize values as: secret vs configuration
3. Git history (last 50 commits):
- Scan diffs for accidentally committed secrets
- Check if any
.env files were ever committed then removed
- Flag any file in history matching secret patterns
4. Configuration files:
docker-compose.yml — passwords in environment blocks
application.yml / application.properties — embedded credentials
- Terraform files — hardcoded provider credentials or database passwords
- Kubernetes secrets — base64-encoded values in committed YAML
5. CI/CD configuration:
.github/workflows/*.yml — check for inline secrets (should use ${{ secrets.NAME }})
.gitlab-ci.yml — check for variables with exposed values
Severity classification:
- CRITICAL: Secrets in source code or git history
- HIGH: .env files tracked by git, secrets in docker-compose
- MEDIUM: .env not in .gitignore, missing .env.example
- LOW: No secrets manager configured, no rotation policy
============================================================
PHASE 2 — ENVIRONMENT TEMPLATE
Generate .env.example from all detected environment variable references.
Scan for env var patterns:
- Node.js:
process.env.VARNAME
- Python:
os.environ["VARNAME"], os.getenv("VARNAME")
- Go:
os.Getenv("VARNAME")
- Generic:
${VARNAME} in config files
Create .env.example with:
- Grouped sections (Application, Database, Cache, Authentication, External APIs, Cloud)
# SECRET: prefix for values that must come from secrets manager
# CONFIG: prefix for non-sensitive configuration
- Placeholder values that clearly indicate they need replacement (e.g.,
REPLACE_ME_WITH_SECURE_RANDOM_VALUE)
============================================================
PHASE 3 — SECRETS PROVIDER SETUP
Based on detected infrastructure or $ARGUMENTS, set up the appropriate provider:
AWS Secrets Manager:
- Generate Terraform for
aws_secretsmanager_secret resources
- Generate application helper to read secrets at startup (using
@aws-sdk/client-secrets-manager or equivalent)
- Configure IAM policy for ECS task role / Lambda execution role
- Set up secret versioning and stage labels
AWS Systems Manager Parameter Store:
- Generate Terraform for
aws_ssm_parameter resources (SecureString type)
- Hierarchical naming:
/{project}/{env}/{secret_name}
- Cheaper alternative for smaller number of secrets
GCP Secret Manager:
- Generate Terraform for
google_secret_manager_secret resources
- Configure IAM bindings for service account access
HashiCorp Vault:
- Generate Vault policy file and AppRole auth method config
- Docker Compose service for local Vault dev server
- Application helper for Vault API integration
Doppler:
- Generate
doppler.yaml project config
- Set up environment configs (dev, staging, prod)
For all providers, generate a unified secrets loading wrapper:
- In production: load from secrets manager
- In development: load from
.env file via dotenv
============================================================
PHASE 4 — SECRET ROTATION (if --rotate)
Database credentials:
- AWS: Lambda rotation function with
aws_secretsmanager_secret_rotation
- Dual-user rotation strategy (alternating credentials for zero-downtime)
- Rotation schedule: every 30 days
API keys:
- Script that: creates new key, updates secrets manager, waits for propagation, revokes old key
- Document manual rotation steps for third-party APIs
TLS certificates:
- Reference cert-manager or ACM for auto-renewal
- Alert 30 days before expiration
============================================================
PHASE 5 — CI/CD INTEGRATION (if --ci)
GitHub Actions:
- OIDC federation for GitHub -> AWS (no long-lived credentials needed)
aws-actions/configure-aws-credentials@v4 with role-to-assume
aws-actions/aws-secretsmanager-get-secrets@v2 for loading secrets
- Environment protection rules for production secrets
Doppler:
dopplerhq/secrets-fetch-action@v1 with DOPPLER_TOKEN secret
General:
- Enable GitHub secret scanning and push protection
- Document all required repository secrets and where to obtain them
============================================================
PHASE 6 — REMEDIATION
For each CRITICAL and HIGH finding from the audit:
- Hardcoded secrets: Replace with environment variable references
- Committed .env files: Add to
.gitignore, remove from git tracking (warn about history)
- Docker compose passwords: Replace with variable references
${DB_PASSWORD}
- Missing .gitignore entries: Add
.env*, *.pem, *.key, *.jks patterns
If secrets were found in git history:
- Recommend
git-filter-repo to remove from history (document command but do NOT execute)
- Recommend rotating ALL exposed credentials immediately
============================================================
SELF-HEALING VALIDATION (max 2 iterations)
After completing deployment/infrastructure changes, validate:
- Verify all generated files are syntactically valid (YAML, JSON, HCL, Dockerfile).
- Run validation commands if available (terraform validate, docker build --check, kubectl dry-run).
- Verify no secrets, credentials, or sensitive values are hardcoded.
- If validation fails, diagnose and fix the specific syntax or config error.
- Repeat up to 2 iterations.
IF STILL FAILING after 2 iterations:
- Document what failed and the exact error
- Include partial output if available
============================================================
OUTPUT
## Secrets Audit & Configuration
### Audit Results
| Severity | Finding | Location | Status |
|----------|---------|----------|--------|
| CRITICAL | {finding} | {file:line} | {fixed/needs-action} |
| HIGH | {finding} | {file} | {fixed/needs-action} |
| MEDIUM | {finding} | {file} | {fixed/needs-action} |
### Files Created/Modified
- .env.example — Environment variable template ({N} variables)
- .gitignore — Added secret file patterns
- {provider config files}
- {application secret loader}
### Secrets Inventory
| Secret | Provider | Rotation | CI/CD |
|--------|----------|----------|-------|
| DATABASE_URL | {provider} | 30 days | configured |
| JWT_SECRET | {provider} | 90 days | configured |
### Immediate Actions Required
{ordered list of manual actions needed, starting with credential rotation}
============================================================
NEXT STEPS
- Rotate any credentials that were exposed in source or git history
- Set up the secrets provider account/project if not already done
- Migrate existing .env values to the secrets provider
- Update deployment scripts to pull secrets from provider at runtime
- Enable GitHub secret scanning and push protection on the repository
- Schedule quarterly secret rotation reviews
============================================================
SELF-EVOLUTION TELEMETRY
After producing output, record execution metadata for the /evolve pipeline.
Check if a project memory directory exists:
- Look for the project path in
~/.claude/projects/
- If found, append to
skill-telemetry.md in that memory directory
Entry format:
### /secrets — {{YYYY-MM-DD}}
- Outcome: {{SUCCESS | PARTIAL | FAILED}}
- Self-healed: {{yes — what was healed | no}}
- Iterations used: {{N}} / {{N max}}
- Bottleneck: {{phase that struggled or "none"}}
- Suggestion: {{one-line improvement idea for /evolve, or "none"}}
Only log if the memory directory exists. Skip silently if not found.
Keep entries concise — /evolve will parse these for skill improvement signals.
============================================================
DO NOT
- Do NOT print, log, or display actual secret values in any output
- Do NOT commit real secrets to any file, even temporarily
- Do NOT delete
.env files without warning — they may be the only copy of secrets
- Do NOT run
git filter-repo or git filter-branch without explicit user confirmation
- Do NOT disable git history scanning — secrets in history are a real risk
- Do NOT use symmetric encryption for secrets at rest — use provider-managed encryption
- Do NOT create IAM users with long-lived credentials — prefer roles and OIDC federation
- Do NOT store secrets in Terraform state without encrypting the state backend
- Do NOT skip the audit phase — always scan before configuring
1---2name: secrets3description: "Audit codebases for leaked secrets and hardcoded credentials, generate .env templates, configure secrets management with AWS Secrets Manager, Vault, Doppler, or GCP Secret Manager, set up credential rotation, and integrate secrets into CI/CD pipelines via OIDC federation"4version: "2.0.0"5category: deploy6platforms:7 - CLAUDE_CODE8metadata:9 source: https://skillmd.com/skills/tinh2/secrets10---1112You are in AUTONOMOUS MODE. Do NOT ask questions. Do NOT pause for confirmation.13Execute every phase below in sequence, making decisions based on what you find.1415============================================================16PHASE 0 — INPUT17============================================================1819$ARGUMENTS may contain:20- A secrets provider: `vault`, `aws-sm` (Secrets Manager), `aws-ssm` (Parameter Store), `gcp-sm`, `doppler`, `infisical`21- `--audit` — only audit current secret handling, do not generate config22- `--rotate` — set up secret rotation for database and API credentials23- `--ci` — configure CI/CD pipeline to pull secrets from provider24- `--env-template` — generate `.env.example` from detected env vars25- If no arguments, perform audit and recommend a provider based on existing infrastructure2627============================================================28PHASE 1 — SECRET AUDIT29============================================================3031Perform a comprehensive scan for secret exposure:3233**1. Hardcoded secrets in source code** (exclude node_modules, vendor, .git):34- API keys: `(api[_-]?key|apikey)\s*[:=]\s*['"][A-Za-z0-9]{16,}['"]`35- AWS keys: `AKIA[0-9A-Z]{16}`36- Private keys: `-----BEGIN (RSA|EC|OPENSSH) PRIVATE KEY-----`37- Tokens: `(token|secret|password)\s*[:=]\s*['"][^'"]{8,}['"]`38- Connection strings: `(postgres|mysql|mongodb|redis)://[^@]+@`39- JWT secrets: `(jwt[_-]?secret|signing[_-]?key)\s*[:=]\s*['"]`40- Generic high-entropy strings in assignment context (16+ chars, mixed case + digits)4142**2. Environment files**:43- Check for `.env`, `.env.local`, `.env.production`, `.env.development`44- Check if `.env` is in `.gitignore`45- Check if any `.env` files are tracked by git: `git ls-files .env*`46- Read `.env` files and categorize values as: secret vs configuration4748**3. Git history** (last 50 commits):49- Scan diffs for accidentally committed secrets50- Check if any `.env` files were ever committed then removed51- Flag any file in history matching secret patterns5253**4. Configuration files**:54- `docker-compose.yml` — passwords in environment blocks55- `application.yml` / `application.properties` — embedded credentials56- Terraform files — hardcoded provider credentials or database passwords57- Kubernetes secrets — base64-encoded values in committed YAML5859**5. CI/CD configuration**:60- `.github/workflows/*.yml` — check for inline secrets (should use `${{ secrets.NAME }}`)61- `.gitlab-ci.yml` — check for variables with exposed values6263**Severity classification**:64- **CRITICAL**: Secrets in source code or git history65- **HIGH**: .env files tracked by git, secrets in docker-compose66- **MEDIUM**: .env not in .gitignore, missing .env.example67- **LOW**: No secrets manager configured, no rotation policy6869============================================================70PHASE 2 — ENVIRONMENT TEMPLATE71============================================================7273Generate `.env.example` from all detected environment variable references.7475Scan for env var patterns:76- Node.js: `process.env.VARNAME`77- Python: `os.environ["VARNAME"]`, `os.getenv("VARNAME")`78- Go: `os.Getenv("VARNAME")`79- Generic: `${VARNAME}` in config files8081Create `.env.example` with:82- Grouped sections (Application, Database, Cache, Authentication, External APIs, Cloud)83- `# SECRET:` prefix for values that must come from secrets manager84- `# CONFIG:` prefix for non-sensitive configuration85- Placeholder values that clearly indicate they need replacement (e.g., `REPLACE_ME_WITH_SECURE_RANDOM_VALUE`)8687============================================================88PHASE 3 — SECRETS PROVIDER SETUP89============================================================9091Based on detected infrastructure or $ARGUMENTS, set up the appropriate provider:9293**AWS Secrets Manager**:94- Generate Terraform for `aws_secretsmanager_secret` resources95- Generate application helper to read secrets at startup (using `@aws-sdk/client-secrets-manager` or equivalent)96- Configure IAM policy for ECS task role / Lambda execution role97- Set up secret versioning and stage labels9899**AWS Systems Manager Parameter Store**:100- Generate Terraform for `aws_ssm_parameter` resources (SecureString type)101- Hierarchical naming: `/{project}/{env}/{secret_name}`102- Cheaper alternative for smaller number of secrets103104**GCP Secret Manager**:105- Generate Terraform for `google_secret_manager_secret` resources106- Configure IAM bindings for service account access107108**HashiCorp Vault**:109- Generate Vault policy file and AppRole auth method config110- Docker Compose service for local Vault dev server111- Application helper for Vault API integration112113**Doppler**:114- Generate `doppler.yaml` project config115- Set up environment configs (dev, staging, prod)116117**For all providers**, generate a unified secrets loading wrapper:118- In production: load from secrets manager119- In development: load from `.env` file via dotenv120121============================================================122PHASE 4 — SECRET ROTATION (if --rotate)123============================================================124125**Database credentials**:126- AWS: Lambda rotation function with `aws_secretsmanager_secret_rotation`127- Dual-user rotation strategy (alternating credentials for zero-downtime)128- Rotation schedule: every 30 days129130**API keys**:131- Script that: creates new key, updates secrets manager, waits for propagation, revokes old key132- Document manual rotation steps for third-party APIs133134**TLS certificates**:135- Reference cert-manager or ACM for auto-renewal136- Alert 30 days before expiration137138============================================================139PHASE 5 — CI/CD INTEGRATION (if --ci)140============================================================141142**GitHub Actions**:143- OIDC federation for GitHub -> AWS (no long-lived credentials needed)144- `aws-actions/configure-aws-credentials@v4` with `role-to-assume`145- `aws-actions/aws-secretsmanager-get-secrets@v2` for loading secrets146- Environment protection rules for production secrets147148**Doppler**:149- `dopplerhq/secrets-fetch-action@v1` with `DOPPLER_TOKEN` secret150151**General**:152- Enable GitHub secret scanning and push protection153- Document all required repository secrets and where to obtain them154155============================================================156PHASE 6 — REMEDIATION157============================================================158159For each CRITICAL and HIGH finding from the audit:1601611. **Hardcoded secrets**: Replace with environment variable references1622. **Committed .env files**: Add to `.gitignore`, remove from git tracking (warn about history)1633. **Docker compose passwords**: Replace with variable references `${DB_PASSWORD}`1644. **Missing .gitignore entries**: Add `.env*`, `*.pem`, `*.key`, `*.jks` patterns165166If secrets were found in git history:167- Recommend `git-filter-repo` to remove from history (document command but do NOT execute)168- Recommend rotating ALL exposed credentials immediately169170171============================================================172SELF-HEALING VALIDATION (max 2 iterations)173============================================================174175After completing deployment/infrastructure changes, validate:1761771. Verify all generated files are syntactically valid (YAML, JSON, HCL, Dockerfile).1782. Run validation commands if available (terraform validate, docker build --check, kubectl dry-run).1793. Verify no secrets, credentials, or sensitive values are hardcoded.1804. If validation fails, diagnose and fix the specific syntax or config error.1815. Repeat up to 2 iterations.182183IF STILL FAILING after 2 iterations:184- Document what failed and the exact error185- Include partial output if available186187============================================================188OUTPUT189============================================================190191```192## Secrets Audit & Configuration193194### Audit Results195| Severity | Finding | Location | Status |196|----------|---------|----------|--------|197| CRITICAL | {finding} | {file:line} | {fixed/needs-action} |198| HIGH | {finding} | {file} | {fixed/needs-action} |199| MEDIUM | {finding} | {file} | {fixed/needs-action} |200201### Files Created/Modified202- .env.example — Environment variable template ({N} variables)203- .gitignore — Added secret file patterns204- {provider config files}205- {application secret loader}206207### Secrets Inventory208| Secret | Provider | Rotation | CI/CD |209|--------|----------|----------|-------|210| DATABASE_URL | {provider} | 30 days | configured |211| JWT_SECRET | {provider} | 90 days | configured |212213### Immediate Actions Required214{ordered list of manual actions needed, starting with credential rotation}215```216217============================================================218NEXT STEPS219============================================================2202211. Rotate any credentials that were exposed in source or git history2222. Set up the secrets provider account/project if not already done2233. Migrate existing .env values to the secrets provider2244. Update deployment scripts to pull secrets from provider at runtime2255. Enable GitHub secret scanning and push protection on the repository2266. Schedule quarterly secret rotation reviews227228229============================================================230SELF-EVOLUTION TELEMETRY231============================================================232233After producing output, record execution metadata for the /evolve pipeline.234235Check if a project memory directory exists:236- Look for the project path in `~/.claude/projects/`237- If found, append to `skill-telemetry.md` in that memory directory238239Entry format:240```241### /secrets — {{YYYY-MM-DD}}242- Outcome: {{SUCCESS | PARTIAL | FAILED}}243- Self-healed: {{yes — what was healed | no}}244- Iterations used: {{N}} / {{N max}}245- Bottleneck: {{phase that struggled or "none"}}246- Suggestion: {{one-line improvement idea for /evolve, or "none"}}247```248249Only log if the memory directory exists. Skip silently if not found.250Keep entries concise — /evolve will parse these for skill improvement signals.251252============================================================253DO NOT254============================================================255256- Do NOT print, log, or display actual secret values in any output257- Do NOT commit real secrets to any file, even temporarily258- Do NOT delete `.env` files without warning — they may be the only copy of secrets259- Do NOT run `git filter-repo` or `git filter-branch` without explicit user confirmation260- Do NOT disable git history scanning — secrets in history are a real risk261- Do NOT use symmetric encryption for secrets at rest — use provider-managed encryption262- Do NOT create IAM users with long-lived credentials — prefer roles and OIDC federation263- Do NOT store secrets in Terraform state without encrypting the state backend264- Do NOT skip the audit phase — always scan before configuring