Env & Secrets Manager
Manage environment-variable hygiene and secrets safety across local development and production.
How to use it
Claude Code
- Run the line below. It pulls the whole folder into
~/.claude/skills/env-secrets-manager, including the files SKILL.md points to. - Describe your job in plain words. Claude Code follows the skill from there.
npx degit alirezarezvani/claude-skills/engineering/skills/env-secrets-manager#main ~/.claude/skills/env-secrets-managerFor one project only, change the path to .claude/skills/env-secrets-manager. This skill also uses gitleaks-report.json — copying SKILL.md alone won't be enough. See the folder on GitHub.
Claude (web or desktop app)
- On this page open ⋯ → Download .md.
- Save it as SKILL.md in a folder, zip the folder, then Customize → Skills → + → Create skill → Upload a skill.
- Pick the file and Save. Claude shows the name and description and runs a security scan.
- Check the skill is switched on.
- Start a new chat and describe your job in plain words. The AI follows the skill from there.
ChatGPT or another app
- ChatGPT: make a Project and paste it into Instructions.
- Neither? Paste it at the top of a new chat — it works for that chat.
Not working?
- Check which app you pasted it into — the steps above name the right one.
- Some skills need the paid tier of Claude or ChatGPT.
Paste into Claude, ChatGPT or Cursor.
Source of Env & Secrets Manager
Show the full text261 lines
| name | description |
|---|---|
| env-secrets-manager | Manage environment-variable hygiene and secrets safety across local development and production. Practical auditing, drift awareness, rotation readiness. Use when auditing .env files for committed secrets, planning a credential rotation, debugging missing-env-var production incidents, or hardening a new project against secrets leakage. |
Env & Secrets Manager
Tier: POWERFUL Category: Engineering Domain: Security / DevOps / Configuration Management
Overview
Manage environment-variable hygiene and secrets safety across local development and production workflows. This skill focuses on practical auditing, drift awareness, and rotation readiness.
Core Capabilities
.envand.env.examplelifecycle guidance- Secret leak detection for repository working trees
- Severity-based findings for likely credentials
- Operational pointers for rotation and containment
- Integration-ready outputs for CI checks
When to Use
- Before pushing commits that touched env/config files
- During security audits and incident triage
- When onboarding contributors who need safe env conventions
- When validating that no obvious secrets are hardcoded
Quick Start
# Scan a repository for likely secret leaks
python3 scripts/env_auditor.py /path/to/repo
# JSON output for CI pipelines
python3 scripts/env_auditor.py /path/to/repo --json
Recommended Workflow
- Run
scripts/env_auditor.pyon the repository root. - Prioritize
criticalandhighfindings first. - Rotate real credentials and remove exposed values.
- Update
.env.exampleand.gitignoreas needed. - Add or tighten pre-commit/CI secret scanning gates.
Reference Docs
references/validation-detection-rotation.mdreferences/secret-patterns.md
Common Pitfalls
- Committing real values in
.env.example - Rotating one system but missing downstream consumers
- Logging secrets during debugging or incident response
- Treating suspected leaks as low urgency without validation
Best Practices
- Use a secret manager as the production source of truth.
- Keep dev env files local and gitignored.
- Enforce detection in CI before merge.
- Re-test application paths immediately after credential rotation.
Cloud Secret Store Integration
Production applications should never read secrets from .env files or environment variables baked into container images. Use a dedicated secret store instead.
Provider Comparison
| Provider | Best For | Key Feature |
|---|---|---|
| HashiCorp Vault | Multi-cloud / hybrid | Dynamic secrets, policy engine, pluggable backends |
| AWS Secrets Manager | AWS-native workloads | Native Lambda/ECS/EKS integration, automatic RDS rotation |
| Azure Key Vault | Azure-native workloads | Managed HSM, Azure AD RBAC, certificate management |
| GCP Secret Manager | GCP-native workloads | IAM-based access, automatic replication, versioning |
Selection Guidance
- Single cloud provider — use the cloud-native secret manager. It integrates tightly with IAM, reduces operational overhead, and costs less than self-hosting.
- Multi-cloud or hybrid — use HashiCorp Vault. It provides a uniform API across environments and supports dynamic secret generation (database credentials, cloud IAM keys) that expire automatically.
- Kubernetes-heavy — combine External Secrets Operator with any backend above to sync secrets into K8s
Secretobjects without hardcoding.
Application Access Patterns
- SDK/API pull — application fetches secret at startup or on-demand via provider SDK.
- Sidecar injection — a sidecar container (e.g., Vault Agent) writes secrets to a shared volume or injects them as environment variables.
- Init container — a Kubernetes init container fetches secrets before the main container starts.
- CSI driver — secrets mount as a filesystem volume via the Secrets Store CSI Driver.
Cross-reference: See
engineering/secrets-vault-managerfor production vault infrastructure patterns, HA deployment, and disaster recovery procedures.
Secret Rotation Workflow
Stale secrets are a liability. Rotation ensures that even if a credential leaks, its useful lifetime is bounded.
Phase 1: Detection
- Track secret creation and expiry dates in your secret store metadata.
- Set alerts at 30, 14, and 7 days before expiry.
- Use
scripts/env_auditor.pyto flag secrets with no recorded rotation date.
Phase 2: Rotation
- Generate a new credential (API key, database password, certificate).
- Deploy the new credential to all consumers (apps, services, pipelines) in parallel.
- Verify each consumer can authenticate using the new credential.
- Revoke the old credential only after all consumers are confirmed healthy.
- Update metadata with the new rotation timestamp and next rotation date.
Phase 3: Automation
- AWS Secrets Manager — use built-in Lambda-based rotation for RDS, Redshift, and DocumentDB.
- HashiCorp Vault — configure dynamic secrets with TTLs; credentials are generated on-demand and auto-expire.
- Azure Key Vault — use Event Grid notifications to trigger rotation functions.
- GCP Secret Manager — use Pub/Sub notifications tied to Cloud Functions for rotation logic.
Emergency Rotation Checklist
When a secret is confirmed leaked:
- Immediately revoke the compromised credential at the provider level.
- Generate and deploy a replacement credential to all consumers.
- Audit access logs for unauthorized usage during the exposure window.
- Scan git history, CI logs, and artifact registries for the leaked value.
- File an incident report documenting scope, timeline, and remediation steps.
- Review and tighten detection controls to prevent recurrence.
CI/CD Secret Injection
Secrets in CI/CD pipelines require careful handling to avoid exposure in logs, artifacts, or pull request contexts.
GitHub Actions
- Use repository secrets or environment secrets via
${{ secrets.SECRET_NAME }}. - Prefer OIDC federation (
aws-actions/configure-aws-credentialswithrole-to-assume) over long-lived access keys. - Environment secrets with required reviewers add approval gates for production deployments.
- GitHub automatically masks secrets in logs, but avoid
echoortoJSON()on secret values.
GitLab CI
- Store secrets as CI/CD variables with the
maskedandprotectedflags enabled. - Use HashiCorp Vault integration (
secrets:vault) for dynamic secret injection without storing values in GitLab. - Scope variables to specific environments (
production,staging) to enforce least privilege.
Universal Patterns
- Never echo or print secret values in pipeline output, even for debugging.
- Use short-lived tokens (OIDC, STS AssumeRole) instead of static credentials wherever possible.
- Restrict PR access — do not expose secrets to pipelines triggered by forks or untrusted branches.
- Rotate CI secrets on the same schedule as application secrets; pipeline credentials are attack vectors too.
- Audit pipeline logs periodically for accidental secret exposure that masking may have missed.
Pre-Commit Secret Detection
Catching secrets before they reach version control is the most cost-effective defense. Two leading tools cover this space.
gitleaks
# .gitleaks.toml — minimal configuration
[extend]
useDefault = true
[[rules]]
id = "custom-internal-token"
description = "Internal service token pattern"
regex = '''INTERNAL_TOKEN_[A-Za-z0-9]{32}'''
secretGroup = 0
- Install:
brew install gitleaksor download from GitHub releases. - Pre-commit hook:
gitleaks git --pre-commit --staged - Baseline scanning:
gitleaks detect --source . --report-path gitleaks-report.json - Manage false positives in
.gitleaksignore(one fingerprint per line).
detect-secrets
# Generate baseline
detect-secrets scan --all-files > .secrets.baseline
# Pre-commit hook (via pre-commit framework)
# .pre-commit-config.yaml
repos:
- repo: https://github.com/Yelp/detect-secrets
rev: v1.5.0
hooks:
- id: detect-secrets
args: ['--baseline', '.secrets.baseline']
- Supports custom plugins for organization-specific patterns.
- Audit workflow:
detect-secrets audit .secrets.baselineinteractively marks true/false positives.
False Positive Management
- Maintain
.gitleaksignoreor.secrets.baselinein version control so the whole team shares exclusions. - Review false positive lists during security audits — patterns may mask real leaks over time.
- Prefer tightening regex patterns over broadly ignoring files.
Audit Logging
Knowing who accessed which secret and when is critical for incident investigation and compliance.
Cloud-Native Audit Trails
| Provider | Service | What It Captures |
|---|---|---|
| AWS | CloudTrail | Every GetSecretValue, DescribeSecret, RotateSecret API call |
| Azure | Activity Log + Diagnostic Logs | Key Vault access events, including caller identity and IP |
| GCP | Cloud Audit Logs | Data access logs for Secret Manager with principal and timestamp |
| Vault | Audit Backend | Full request/response logging (file, syslog, or socket backend) |
Alerting Strategy
- Alert on access from unknown IP ranges or service accounts outside the expected set.
- Alert on bulk secret reads (more than N secrets accessed within a time window).
- Alert on access outside deployment windows when no CI/CD pipeline is running.
- Feed audit logs into your SIEM (Splunk, Datadog, Elastic) for correlation with other security events.
- Review audit logs quarterly as part of access recertification.
Cross-References
This skill covers env hygiene and secret detection. For deeper coverage of related domains, see:
| Skill | Path | Relationship |
|---|---|---|
| Secrets Vault Manager | engineering/secrets-vault-manager |
Production vault infrastructure, HA deployment, DR |
| Senior SecOps | engineering/senior-secops |
Security operations perspective, incident response |
| CI/CD Pipeline Builder | engineering/ci-cd-pipeline-builder |
Pipeline architecture, secret injection patterns |
| Infrastructure as Code | engineering/infrastructure-as-code |
Terraform/Pulumi secret backend configuration |
| Container Orchestration | engineering/container-orchestration |
Kubernetes secret mounting, sealed secrets |
| 1 | |
| 2 | name "env-secrets-manager" |
| 3 | description "Manage environment-variable hygiene and secrets safety across local development and production. Practical auditing, drift awareness, rotation readiness. Use when auditing .env files for committed secrets, planning a credential rotation, debugging missing-env-var production incidents, or hardening a new project against secrets leakage." |
| 4 | |
| 5 | |
| 6 | # Env & Secrets Manager |
| 7 | |
| 8 | **Tier:** POWERFUL |
| 9 | **Category:** Engineering |
| 10 | **Domain:** Security / DevOps / Configuration Management |
| 11 | |
| 12 | |
| 13 | |
| 14 | ## Overview |
| 15 | |
| 16 | Manage environment-variable hygiene and secrets safety across local development and production workflows. This skill focuses on practical auditing, drift awareness, and rotation readiness. |
| 17 | |
| 18 | ## Core Capabilities |
| 19 | |
| 20 | `.env` and `.env.example` lifecycle guidance |
| 21 | Secret leak detection for repository working trees |
| 22 | Severity-based findings for likely credentials |
| 23 | Operational pointers for rotation and containment |
| 24 | Integration-ready outputs for CI checks |
| 25 | |
| 26 | |
| 27 | |
| 28 | ## When to Use |
| 29 | |
| 30 | Before pushing commits that touched env/config files |
| 31 | During security audits and incident triage |
| 32 | When onboarding contributors who need safe env conventions |
| 33 | When validating that no obvious secrets are hardcoded |
| 34 | |
| 35 | |
| 36 | |
| 37 | ## Quick Start |
| 38 | |
| 39 | |
| 40 | # Scan a repository for likely secret leaks |
| 41 | python3 scripts/env_auditor.py /path/to/repo |
| 42 | |
| 43 | # JSON output for CI pipelines |
| 44 | python3 scripts/env_auditor.py /path/to/repo --json |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | ## Recommended Workflow |
| 50 | |
| 51 | Run `scripts/env_auditor.py` on the repository root. |
| 52 | Prioritize `critical` and `high` findings first. |
| 53 | Rotate real credentials and remove exposed values. |
| 54 | Update `.env.example` and `.gitignore` as needed. |
| 55 | Add or tighten pre-commit/CI secret scanning gates. |
| 56 | |
| 57 | |
| 58 | |
| 59 | ## Reference Docs |
| 60 | |
| 61 | `references/validation-detection-rotation.md` |
| 62 | `references/secret-patterns.md` |
| 63 | |
| 64 | |
| 65 | |
| 66 | ## Common Pitfalls |
| 67 | |
| 68 | Committing real values in `.env.example` |
| 69 | Rotating one system but missing downstream consumers |
| 70 | Logging secrets during debugging or incident response |
| 71 | Treating suspected leaks as low urgency without validation |
| 72 | |
| 73 | ## Best Practices |
| 74 | |
| 75 | Use a secret manager as the production source of truth. |
| 76 | Keep dev env files local and gitignored. |
| 77 | Enforce detection in CI before merge. |
| 78 | Re-test application paths immediately after credential rotation. |
| 79 | |
| 80 | |
| 81 | |
| 82 | ## Cloud Secret Store Integration |
| 83 | |
| 84 | Production applications should never read secrets from `.env` files or environment variables baked into container images. Use a dedicated secret store instead. |
| 85 | |
| 86 | ### Provider Comparison |
| 87 | |
| 88 | | Provider | Best For | Key Feature | |
| 89 | |----------|----------|-------------| |
| 90 | | **HashiCorp Vault** | Multi-cloud / hybrid | Dynamic secrets, policy engine, pluggable backends | |
| 91 | | **AWS Secrets Manager** | AWS-native workloads | Native Lambda/ECS/EKS integration, automatic RDS rotation | |
| 92 | | **Azure Key Vault** | Azure-native workloads | Managed HSM, Azure AD RBAC, certificate management | |
| 93 | | **GCP Secret Manager** | GCP-native workloads | IAM-based access, automatic replication, versioning | |
| 94 | |
| 95 | ### Selection Guidance |
| 96 | |
| 97 | **Single cloud provider** — use the cloud-native secret manager. It integrates tightly with IAM, reduces operational overhead, and costs less than self-hosting. |
| 98 | **Multi-cloud or hybrid** — use HashiCorp Vault. It provides a uniform API across environments and supports dynamic secret generation (database credentials, cloud IAM keys) that expire automatically. |
| 99 | **Kubernetes-heavy** — combine External Secrets Operator with any backend above to sync secrets into K8s `Secret` objects without hardcoding. |
| 100 | |
| 101 | ### Application Access Patterns |
| 102 | |
| 103 | **SDK/API pull** — application fetches secret at startup or on-demand via provider SDK. |
| 104 | **Sidecar injection** — a sidecar container (e.g., Vault Agent) writes secrets to a shared volume or injects them as environment variables. |
| 105 | **Init container** — a Kubernetes init container fetches secrets before the main container starts. |
| 106 | **CSI driver** — secrets mount as a filesystem volume via the Secrets Store CSI Driver. |
| 107 | |
| 108 | > **Cross-reference:** See `engineering/secrets-vault-manager` for production vault infrastructure patterns, HA deployment, and disaster recovery procedures. |
| 109 | |
| 110 | |
| 111 | |
| 112 | ## Secret Rotation Workflow |
| 113 | |
| 114 | Stale secrets are a liability. Rotation ensures that even if a credential leaks, its useful lifetime is bounded. |
| 115 | |
| 116 | ### Phase 1: Detection |
| 117 | |
| 118 | Track secret creation and expiry dates in your secret store metadata. |
| 119 | Set alerts at 30, 14, and 7 days before expiry. |
| 120 | Use `scripts/env_auditor.py` to flag secrets with no recorded rotation date. |
| 121 | |
| 122 | ### Phase 2: Rotation |
| 123 | |
| 124 | **Generate** a new credential (API key, database password, certificate). |
| 125 | **Deploy** the new credential to all consumers (apps, services, pipelines) in parallel. |
| 126 | **Verify** each consumer can authenticate using the new credential. |
| 127 | **Revoke** the old credential only after all consumers are confirmed healthy. |
| 128 | **Update** metadata with the new rotation timestamp and next rotation date. |
| 129 | |
| 130 | ### Phase 3: Automation |
| 131 | |
| 132 | **AWS Secrets Manager** — use built-in Lambda-based rotation for RDS, Redshift, and DocumentDB. |
| 133 | **HashiCorp Vault** — configure dynamic secrets with TTLs; credentials are generated on-demand and auto-expire. |
| 134 | **Azure Key Vault** — use Event Grid notifications to trigger rotation functions. |
| 135 | **GCP Secret Manager** — use Pub/Sub notifications tied to Cloud Functions for rotation logic. |
| 136 | |
| 137 | ### Emergency Rotation Checklist |
| 138 | |
| 139 | When a secret is confirmed leaked: |
| 140 | |
| 141 | **Immediately revoke** the compromised credential at the provider level. |
| 142 | Generate and deploy a replacement credential to all consumers. |
| 143 | Audit access logs for unauthorized usage during the exposure window. |
| 144 | Scan git history, CI logs, and artifact registries for the leaked value. |
| 145 | File an incident report documenting scope, timeline, and remediation steps. |
| 146 | Review and tighten detection controls to prevent recurrence. |
| 147 | |
| 148 | |
| 149 | |
| 150 | ## CI/CD Secret Injection |
| 151 | |
| 152 | Secrets in CI/CD pipelines require careful handling to avoid exposure in logs, artifacts, or pull request contexts. |
| 153 | |
| 154 | ### GitHub Actions |
| 155 | |
| 156 | Use **repository secrets** or **environment secrets** via `${{ secrets.SECRET_NAME }}`. |
| 157 | Prefer **OIDC federation** (`aws-actions/configure-aws-credentials` with `role-to-assume`) over long-lived access keys. |
| 158 | Environment secrets with required reviewers add approval gates for production deployments. |
| 159 | GitHub automatically masks secrets in logs, but avoid `echo` or `toJSON()` on secret values. |
| 160 | |
| 161 | ### GitLab CI |
| 162 | |
| 163 | Store secrets as **CI/CD variables** with the `masked` and `protected` flags enabled. |
| 164 | Use **HashiCorp Vault integration** (`secrets:vault`) for dynamic secret injection without storing values in GitLab. |
| 165 | Scope variables to specific environments (`production`, `staging`) to enforce least privilege. |
| 166 | |
| 167 | ### Universal Patterns |
| 168 | |
| 169 | **Never echo or print** secret values in pipeline output, even for debugging. |
| 170 | **Use short-lived tokens** (OIDC, STS AssumeRole) instead of static credentials wherever possible. |
| 171 | **Restrict PR access** — do not expose secrets to pipelines triggered by forks or untrusted branches. |
| 172 | **Rotate CI secrets** on the same schedule as application secrets; pipeline credentials are attack vectors too. |
| 173 | **Audit pipeline logs** periodically for accidental secret exposure that masking may have missed. |
| 174 | |
| 175 | |
| 176 | |
| 177 | ## Pre-Commit Secret Detection |
| 178 | |
| 179 | Catching secrets before they reach version control is the most cost-effective defense. Two leading tools cover this space. |
| 180 | |
| 181 | ### gitleaks |
| 182 | |
| 183 | |
| 184 | # .gitleaks.toml — minimal configuration |
| 185 | [extend] |
| 186 | useDefault = true |
| 187 | |
| 188 | [[rules]] |
| 189 | id = "custom-internal-token" |
| 190 | description = "Internal service token pattern" |
| 191 | regex = '''INTERNAL_TOKEN_[A-Za-z0-9]{32}''' |
| 192 | secretGroup = 0 |
| 193 | |
| 194 | |
| 195 | Install: `brew install gitleaks` or download from GitHub releases. |
| 196 | Pre-commit hook: `gitleaks git --pre-commit --staged` |
| 197 | Baseline scanning: `gitleaks detect --source . --report-path gitleaks-report.json` |
| 198 | Manage false positives in `.gitleaksignore` (one fingerprint per line). |
| 199 | |
| 200 | ### detect-secrets |
| 201 | |
| 202 | |
| 203 | # Generate baseline |
| 204 | detect-secrets scan --all-files > .secrets.baseline |
| 205 | |
| 206 | # Pre-commit hook (via pre-commit framework) |
| 207 | # .pre-commit-config.yaml |
| 208 | repos: |
| 209 | - repo: https://github.com/Yelp/detect-secrets |
| 210 | rev: v1.5.0 |
| 211 | hooks: |
| 212 | - id: detect-secrets |
| 213 | args: ['--baseline', '.secrets.baseline'] |
| 214 | |
| 215 | |
| 216 | Supports **custom plugins** for organization-specific patterns. |
| 217 | Audit workflow: `detect-secrets audit .secrets.baseline` interactively marks true/false positives. |
| 218 | |
| 219 | ### False Positive Management |
| 220 | |
| 221 | Maintain `.gitleaksignore` or `.secrets.baseline` in version control so the whole team shares exclusions. |
| 222 | Review false positive lists during security audits — patterns may mask real leaks over time. |
| 223 | Prefer tightening regex patterns over broadly ignoring files. |
| 224 | |
| 225 | |
| 226 | |
| 227 | ## Audit Logging |
| 228 | |
| 229 | Knowing who accessed which secret and when is critical for incident investigation and compliance. |
| 230 | |
| 231 | ### Cloud-Native Audit Trails |
| 232 | |
| 233 | | Provider | Service | What It Captures | |
| 234 | |----------|---------|-----------------| |
| 235 | | **AWS** | CloudTrail | Every `GetSecretValue`, `DescribeSecret`, `RotateSecret` API call | |
| 236 | | **Azure** | Activity Log + Diagnostic Logs | Key Vault access events, including caller identity and IP | |
| 237 | | **GCP** | Cloud Audit Logs | Data access logs for Secret Manager with principal and timestamp | |
| 238 | | **Vault** | Audit Backend | Full request/response logging (file, syslog, or socket backend) | |
| 239 | |
| 240 | ### Alerting Strategy |
| 241 | |
| 242 | Alert on **access from unknown IP ranges** or service accounts outside the expected set. |
| 243 | Alert on **bulk secret reads** (more than N secrets accessed within a time window). |
| 244 | Alert on **access outside deployment windows** when no CI/CD pipeline is running. |
| 245 | Feed audit logs into your SIEM (Splunk, Datadog, Elastic) for correlation with other security events. |
| 246 | Review audit logs quarterly as part of access recertification. |
| 247 | |
| 248 | |
| 249 | |
| 250 | ## Cross-References |
| 251 | |
| 252 | This skill covers env hygiene and secret detection. For deeper coverage of related domains, see: |
| 253 | |
| 254 | | Skill | Path | Relationship | |
| 255 | |-------|------|-------------| |
| 256 | | **Secrets Vault Manager** | `engineering/secrets-vault-manager` | Production vault infrastructure, HA deployment, DR | |
| 257 | | **Senior SecOps** | `engineering/senior-secops` | Security operations perspective, incident response | |
| 258 | | **CI/CD Pipeline Builder** | `engineering/ci-cd-pipeline-builder` | Pipeline architecture, secret injection patterns | |
| 259 | | **Infrastructure as Code** | `engineering/infrastructure-as-code` | Terraform/Pulumi secret backend configuration | |
| 260 | | **Container Orchestration** | `engineering/container-orchestration` | Kubernetes secret mounting, sealed secrets | |
| 261 |
Discussion
Browse more free Claude skills.