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.
Overview
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.
Source: https://github.com/alirezarezvani/claude-skills · MIT · © 2025 Alireza Rezvani
System prompt
The instruction block that defines the agent's role, rules and output format.
# 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
- `.env` and `.env.example` lifecycle 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
```bash
# 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
1. Run `scripts/env_auditor.py` on the repository root.
2. Prioritize `critical` and `high` findings first.
3. Rotate real credentials and remove exposed values.
4. Update `.env.example` and `.gitignore` as needed.
5. Add or tighten pre-commit/CI secret scanning gates.
---
## Reference Docs
- `references/validation-detection-rotation.md`
- `references/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
1. Use a secret manager as the production source of truth.
2. Keep dev env files local and gitignored.
3. Enforce detection in CI before merge.
4. 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 `Secret` objects without hardcoding.
### Application Access Patterns
1. **SDK/API pull** — application fetches secret at startup or on-demand via provider SDK.
2. **Sidecar injection** — a sidecar container (e.g., Vault Agent) writes secrets to a shared volume or injects them as environment variables.
3. **Init container** — a Kubernetes init container fetches secrets before the main container starts.
4. **CSI driver** — secrets mount as a filesystem volume via the Secrets Store CSI Driver.
> **Cross-reference:** See `engineering/secrets-vault-manager` for 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.py` to flag secrets with no recorded rotation date.
### Phase 2: Rotation
1. **Generate** a new credential (API key, database password, certificate).
2. **Deploy** the new credential to all consumers (apps, services, pipelines) in parallel.
3. **Verify** each consumer can authenticate using the new credential.
4. **Revoke** the old credential only after all consumers are confirmed healthy.
5. **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:
1. **Immediately revoke** the compromised credential at the provider level.
2. Generate and deploy a replacement credential to all consumers.
3. Audit access logs for unauthorized usage during the exposure window.
4. Scan git history, CI logs, and artifact registries for the leaked value.
5. File an incident report documenting scope, timeline, and remediation steps.
6. 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-credentials` with `role-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 `echo` or `toJSON()` on secret values.
### GitLab CI
- Store secrets as **CI/CD variables** with the `masked` and `protected` flags 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
```toml
# .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 gitleaks` or 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
```bash
# 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.baseline` interactively marks true/false positives.
### False Positive Management
- Maintain `.gitleaksignore` or `.secrets.baseline` in 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 | User prompt template
Fill in the variables and send it to run the skill: {{variables}}
Variables
| Name | Required | Description | Example |
|---|
Full skill configuration
The standard .aiskill file in JSON and YAML.
{
"format": "aiskill/v1",
"skill": {
"name": "env-secrets-manager",
"slug": "env-secrets-manager",
"version": "1.0.0",
"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.",
"category": "Development",
"tags": [
"engineering",
"security"
],
"platforms": [
"chatgpt",
"claude-code",
"cursor"
],
"tested_environment": "Agent Skills convention (SKILL.md) — works with Claude Code, Cursor, ChatGPT/Codex and compatible agents",
"license": "MIT"
},
"prompts": {
"system": "# Env & Secrets Manager\r\n\r\n**Tier:** POWERFUL\r\n**Category:** Engineering\r\n**Domain:** Security / DevOps / Configuration Management\r\n\r\n---\r\n\r\n## Overview\r\n\r\nManage environment-variable hygiene and secrets safety across local development and production workflows. This skill focuses on practical auditing, drift awareness, and rotation readiness.\r\n\r\n## Core Capabilities\r\n\r\n- `.env` and `.env.example` lifecycle guidance\r\n- Secret leak detection for repository working trees\r\n- Severity-based findings for likely credentials\r\n- Operational pointers for rotation and containment\r\n- Integration-ready outputs for CI checks\r\n\r\n---\r\n\r\n## When to Use\r\n\r\n- Before pushing commits that touched env/config files\r\n- During security audits and incident triage\r\n- When onboarding contributors who need safe env conventions\r\n- When validating that no obvious secrets are hardcoded\r\n\r\n---\r\n\r\n## Quick Start\r\n\r\n```bash\r\n# Scan a repository for likely secret leaks\r\npython3 scripts/env_auditor.py /path/to/repo\r\n\r\n# JSON output for CI pipelines\r\npython3 scripts/env_auditor.py /path/to/repo --json\r\n```\r\n\r\n---\r\n\r\n## Recommended Workflow\r\n\r\n1. Run `scripts/env_auditor.py` on the repository root.\r\n2. Prioritize `critical` and `high` findings first.\r\n3. Rotate real credentials and remove exposed values.\r\n4. Update `.env.example` and `.gitignore` as needed.\r\n5. Add or tighten pre-commit/CI secret scanning gates.\r\n\r\n---\r\n\r\n## Reference Docs\r\n\r\n- `references/validation-detection-rotation.md`\r\n- `references/secret-patterns.md`\r\n\r\n---\r\n\r\n## Common Pitfalls\r\n\r\n- Committing real values in `.env.example`\r\n- Rotating one system but missing downstream consumers\r\n- Logging secrets during debugging or incident response\r\n- Treating suspected leaks as low urgency without validation\r\n\r\n## Best Practices\r\n\r\n1. Use a secret manager as the production source of truth.\r\n2. Keep dev env files local and gitignored.\r\n3. Enforce detection in CI before merge.\r\n4. Re-test application paths immediately after credential rotation.\r\n\r\n---\r\n\r\n## Cloud Secret Store Integration\r\n\r\nProduction applications should never read secrets from `.env` files or environment variables baked into container images. Use a dedicated secret store instead.\r\n\r\n### Provider Comparison\r\n\r\n| Provider | Best For | Key Feature |\r\n|----------|----------|-------------|\r\n| **HashiCorp Vault** | Multi-cloud / hybrid | Dynamic secrets, policy engine, pluggable backends |\r\n| **AWS Secrets Manager** | AWS-native workloads | Native Lambda/ECS/EKS integration, automatic RDS rotation |\r\n| **Azure Key Vault** | Azure-native workloads | Managed HSM, Azure AD RBAC, certificate management |\r\n| **GCP Secret Manager** | GCP-native workloads | IAM-based access, automatic replication, versioning |\r\n\r\n### Selection Guidance\r\n\r\n- **Single cloud provider** — use the cloud-native secret manager. It integrates tightly with IAM, reduces operational overhead, and costs less than self-hosting.\r\n- **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.\r\n- **Kubernetes-heavy** — combine External Secrets Operator with any backend above to sync secrets into K8s `Secret` objects without hardcoding.\r\n\r\n### Application Access Patterns\r\n\r\n1. **SDK/API pull** — application fetches secret at startup or on-demand via provider SDK.\r\n2. **Sidecar injection** — a sidecar container (e.g., Vault Agent) writes secrets to a shared volume or injects them as environment variables.\r\n3. **Init container** — a Kubernetes init container fetches secrets before the main container starts.\r\n4. **CSI driver** — secrets mount as a filesystem volume via the Secrets Store CSI Driver.\r\n\r\n> **Cross-reference:** See `engineering/secrets-vault-manager` for production vault infrastructure patterns, HA deployment, and disaster recovery procedures.\r\n\r\n---\r\n\r\n## Secret Rotation Workflow\r\n\r\nStale secrets are a liability. Rotation ensures that even if a credential leaks, its useful lifetime is bounded.\r\n\r\n### Phase 1: Detection\r\n\r\n- Track secret creation and expiry dates in your secret store metadata.\r\n- Set alerts at 30, 14, and 7 days before expiry.\r\n- Use `scripts/env_auditor.py` to flag secrets with no recorded rotation date.\r\n\r\n### Phase 2: Rotation\r\n\r\n1. **Generate** a new credential (API key, database password, certificate).\r\n2. **Deploy** the new credential to all consumers (apps, services, pipelines) in parallel.\r\n3. **Verify** each consumer can authenticate using the new credential.\r\n4. **Revoke** the old credential only after all consumers are confirmed healthy.\r\n5. **Update** metadata with the new rotation timestamp and next rotation date.\r\n\r\n### Phase 3: Automation\r\n\r\n- **AWS Secrets Manager** — use built-in Lambda-based rotation for RDS, Redshift, and DocumentDB.\r\n- **HashiCorp Vault** — configure dynamic secrets with TTLs; credentials are generated on-demand and auto-expire.\r\n- **Azure Key Vault** — use Event Grid notifications to trigger rotation functions.\r\n- **GCP Secret Manager** — use Pub/Sub notifications tied to Cloud Functions for rotation logic.\r\n\r\n### Emergency Rotation Checklist\r\n\r\nWhen a secret is confirmed leaked:\r\n\r\n1. **Immediately revoke** the compromised credential at the provider level.\r\n2. Generate and deploy a replacement credential to all consumers.\r\n3. Audit access logs for unauthorized usage during the exposure window.\r\n4. Scan git history, CI logs, and artifact registries for the leaked value.\r\n5. File an incident report documenting scope, timeline, and remediation steps.\r\n6. Review and tighten detection controls to prevent recurrence.\r\n\r\n---\r\n\r\n## CI/CD Secret Injection\r\n\r\nSecrets in CI/CD pipelines require careful handling to avoid exposure in logs, artifacts, or pull request contexts.\r\n\r\n### GitHub Actions\r\n\r\n- Use **repository secrets** or **environment secrets** via `${{ secrets.SECRET_NAME }}`.\r\n- Prefer **OIDC federation** (`aws-actions/configure-aws-credentials` with `role-to-assume`) over long-lived access keys.\r\n- Environment secrets with required reviewers add approval gates for production deployments.\r\n- GitHub automatically masks secrets in logs, but avoid `echo` or `toJSON()` on secret values.\r\n\r\n### GitLab CI\r\n\r\n- Store secrets as **CI/CD variables** with the `masked` and `protected` flags enabled.\r\n- Use **HashiCorp Vault integration** (`secrets:vault`) for dynamic secret injection without storing values in GitLab.\r\n- Scope variables to specific environments (`production`, `staging`) to enforce least privilege.\r\n\r\n### Universal Patterns\r\n\r\n- **Never echo or print** secret values in pipeline output, even for debugging.\r\n- **Use short-lived tokens** (OIDC, STS AssumeRole) instead of static credentials wherever possible.\r\n- **Restrict PR access** — do not expose secrets to pipelines triggered by forks or untrusted branches.\r\n- **Rotate CI secrets** on the same schedule as application secrets; pipeline credentials are attack vectors too.\r\n- **Audit pipeline logs** periodically for accidental secret exposure that masking may have missed.\r\n\r\n---\r\n\r\n## Pre-Commit Secret Detection\r\n\r\nCatching secrets before they reach version control is the most cost-effective defense. Two leading tools cover this space.\r\n\r\n### gitleaks\r\n\r\n```toml\r\n# .gitleaks.toml — minimal configuration\r\n[extend]\r\nuseDefault = true\r\n\r\n[[rules]]\r\nid = \"custom-internal-token\"\r\ndescription = \"Internal service token pattern\"\r\nregex = '''INTERNAL_TOKEN_[A-Za-z0-9]{32}'''\r\nsecretGroup = 0\r\n```\r\n\r\n- Install: `brew install gitleaks` or download from GitHub releases.\r\n- Pre-commit hook: `gitleaks git --pre-commit --staged`\r\n- Baseline scanning: `gitleaks detect --source . --report-path gitleaks-report.json`\r\n- Manage false positives in `.gitleaksignore` (one fingerprint per line).\r\n\r\n### detect-secrets\r\n\r\n```bash\r\n# Generate baseline\r\ndetect-secrets scan --all-files > .secrets.baseline\r\n\r\n# Pre-commit hook (via pre-commit framework)\r\n# .pre-commit-config.yaml\r\nrepos:\r\n - repo: https://github.com/Yelp/detect-secrets\r\n rev: v1.5.0\r\n hooks:\r\n - id: detect-secrets\r\n args: ['--baseline', '.secrets.baseline']\r\n```\r\n\r\n- Supports **custom plugins** for organization-specific patterns.\r\n- Audit workflow: `detect-secrets audit .secrets.baseline` interactively marks true/false positives.\r\n\r\n### False Positive Management\r\n\r\n- Maintain `.gitleaksignore` or `.secrets.baseline` in version control so the whole team shares exclusions.\r\n- Review false positive lists during security audits — patterns may mask real leaks over time.\r\n- Prefer tightening regex patterns over broadly ignoring files.\r\n\r\n---\r\n\r\n## Audit Logging\r\n\r\nKnowing who accessed which secret and when is critical for incident investigation and compliance.\r\n\r\n### Cloud-Native Audit Trails\r\n\r\n| Provider | Service | What It Captures |\r\n|----------|---------|-----------------|\r\n| **AWS** | CloudTrail | Every `GetSecretValue`, `DescribeSecret`, `RotateSecret` API call |\r\n| **Azure** | Activity Log + Diagnostic Logs | Key Vault access events, including caller identity and IP |\r\n| **GCP** | Cloud Audit Logs | Data access logs for Secret Manager with principal and timestamp |\r\n| **Vault** | Audit Backend | Full request/response logging (file, syslog, or socket backend) |\r\n\r\n### Alerting Strategy\r\n\r\n- Alert on **access from unknown IP ranges** or service accounts outside the expected set.\r\n- Alert on **bulk secret reads** (more than N secrets accessed within a time window).\r\n- Alert on **access outside deployment windows** when no CI/CD pipeline is running.\r\n- Feed audit logs into your SIEM (Splunk, Datadog, Elastic) for correlation with other security events.\r\n- Review audit logs quarterly as part of access recertification.\r\n\r\n---\r\n\r\n## Cross-References\r\n\r\nThis skill covers env hygiene and secret detection. For deeper coverage of related domains, see:\r\n\r\n| Skill | Path | Relationship |\r\n|-------|------|-------------|\r\n| **Secrets Vault Manager** | `engineering/secrets-vault-manager` | Production vault infrastructure, HA deployment, DR |\r\n| **Senior SecOps** | `engineering/senior-secops` | Security operations perspective, incident response |\r\n| **CI/CD Pipeline Builder** | `engineering/ci-cd-pipeline-builder` | Pipeline architecture, secret injection patterns |\r\n| **Infrastructure as Code** | `engineering/infrastructure-as-code` | Terraform/Pulumi secret backend configuration |\r\n| **Container Orchestration** | `engineering/container-orchestration` | Kubernetes secret mounting, sealed secrets |",
"user_template": ""
},
"variables": [],
"install": {
"steps": [
{
"title": "Download & unzip",
"detail": "Download the .zip package from SkillVault and unzip it. The env-secrets-manager/ folder contains SKILL.md plus any companion scripts, references and assets."
},
{
"title": "Copy into your agent skills directory",
"detail": "Move the folder into your agent's skills directory — e.g. ~/.claude/skills/ (Claude Code), .codex/skills/, .cursor/skills/ or your project's .claude/skills/ folder — then restart or reload the session."
},
{
"title": "Use it",
"detail": "Describe the task in natural language; the agent loads the skill automatically when the request matches the skill description."
}
]
},
"usage": {
"steps": []
},
"metadata": {
"author": "SkillVault",
"source": "https://skillvault.top/skills/env-secrets-manager",
"exported_at": "2026-11-03T07:42:27.635Z"
}
} format: aiskill/v1
skill:
name: env-secrets-manager
slug: env-secrets-manager
version: 1.0.0
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.
category: Development
tags:
- engineering
- security
platforms:
- chatgpt
- claude-code
- cursor
tested_environment: >-
Agent Skills convention (SKILL.md) — works with Claude Code, Cursor, ChatGPT/Codex and
compatible agents
license: MIT
prompts:
system: "# Env & Secrets Manager\r\n\r\n**Tier:** POWERFUL\r\n**Category:** Engineering\r\n**Domain:** Security / DevOps / Configuration Management\r\n\r\n---\r\n\r\n## Overview\r\n\r\nManage environment-variable hygiene and secrets safety across local development and production workflows. This skill focuses on practical auditing, drift awareness, and rotation readiness.\r\n\r\n## Core Capabilities\r\n\r\n- `.env` and `.env.example` lifecycle guidance\r\n- Secret leak detection for repository working trees\r\n- Severity-based findings for likely credentials\r\n- Operational pointers for rotation and containment\r\n- Integration-ready outputs for CI checks\r\n\r\n---\r\n\r\n## When to Use\r\n\r\n- Before pushing commits that touched env/config files\r\n- During security audits and incident triage\r\n- When onboarding contributors who need safe env conventions\r\n- When validating that no obvious secrets are hardcoded\r\n\r\n---\r\n\r\n## Quick Start\r\n\r\n```bash\r\n# Scan a repository for likely secret leaks\r\npython3 scripts/env_auditor.py /path/to/repo\r\n\r\n# JSON output for CI pipelines\r\npython3 scripts/env_auditor.py /path/to/repo --json\r\n```\r\n\r\n---\r\n\r\n## Recommended Workflow\r\n\r\n1. Run `scripts/env_auditor.py` on the repository root.\r\n2. Prioritize `critical` and `high` findings first.\r\n3. Rotate real credentials and remove exposed values.\r\n4. Update `.env.example` and `.gitignore` as needed.\r\n5. Add or tighten pre-commit/CI secret scanning gates.\r\n\r\n---\r\n\r\n## Reference Docs\r\n\r\n- `references/validation-detection-rotation.md`\r\n- `references/secret-patterns.md`\r\n\r\n---\r\n\r\n## Common Pitfalls\r\n\r\n- Committing real values in `.env.example`\r\n- Rotating one system but missing downstream consumers\r\n- Logging secrets during debugging or incident response\r\n- Treating suspected leaks as low urgency without validation\r\n\r\n## Best Practices\r\n\r\n1. Use a secret manager as the production source of truth.\r\n2. Keep dev env files local and gitignored.\r\n3. Enforce detection in CI before merge.\r\n4. Re-test application paths immediately after credential rotation.\r\n\r\n---\r\n\r\n## Cloud Secret Store Integration\r\n\r\nProduction applications should never read secrets from `.env` files or environment variables baked into container images. Use a dedicated secret store instead.\r\n\r\n### Provider Comparison\r\n\r\n| Provider | Best For | Key Feature |\r\n|----------|----------|-------------|\r\n| **HashiCorp Vault** | Multi-cloud / hybrid | Dynamic secrets, policy engine, pluggable backends |\r\n| **AWS Secrets Manager** | AWS-native workloads | Native Lambda/ECS/EKS integration, automatic RDS rotation |\r\n| **Azure Key Vault** | Azure-native workloads | Managed HSM, Azure AD RBAC, certificate management |\r\n| **GCP Secret Manager** | GCP-native workloads | IAM-based access, automatic replication, versioning |\r\n\r\n### Selection Guidance\r\n\r\n- **Single cloud provider** — use the cloud-native secret manager. It integrates tightly with IAM, reduces operational overhead, and costs less than self-hosting.\r\n- **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.\r\n- **Kubernetes-heavy** — combine External Secrets Operator with any backend above to sync secrets into K8s `Secret` objects without hardcoding.\r\n\r\n### Application Access Patterns\r\n\r\n1. **SDK/API pull** — application fetches secret at startup or on-demand via provider SDK.\r\n2. **Sidecar injection** — a sidecar container (e.g., Vault Agent) writes secrets to a shared volume or injects them as environment variables.\r\n3. **Init container** — a Kubernetes init container fetches secrets before the main container starts.\r\n4. **CSI driver** — secrets mount as a filesystem volume via the Secrets Store CSI Driver.\r\n\r\n> **Cross-reference:** See `engineering/secrets-vault-manager` for production vault infrastructure patterns, HA deployment, and disaster recovery procedures.\r\n\r\n---\r\n\r\n## Secret Rotation Workflow\r\n\r\nStale secrets are a liability. Rotation ensures that even if a credential leaks, its useful lifetime is bounded.\r\n\r\n### Phase 1: Detection\r\n\r\n- Track secret creation and expiry dates in your secret store metadata.\r\n- Set alerts at 30, 14, and 7 days before expiry.\r\n- Use `scripts/env_auditor.py` to flag secrets with no recorded rotation date.\r\n\r\n### Phase 2: Rotation\r\n\r\n1. **Generate** a new credential (API key, database password, certificate).\r\n2. **Deploy** the new credential to all consumers (apps, services, pipelines) in parallel.\r\n3. **Verify** each consumer can authenticate using the new credential.\r\n4. **Revoke** the old credential only after all consumers are confirmed healthy.\r\n5. **Update** metadata with the new rotation timestamp and next rotation date.\r\n\r\n### Phase 3: Automation\r\n\r\n- **AWS Secrets Manager** — use built-in Lambda-based rotation for RDS, Redshift, and DocumentDB.\r\n- **HashiCorp Vault** — configure dynamic secrets with TTLs; credentials are generated on-demand and auto-expire.\r\n- **Azure Key Vault** — use Event Grid notifications to trigger rotation functions.\r\n- **GCP Secret Manager** — use Pub/Sub notifications tied to Cloud Functions for rotation logic.\r\n\r\n### Emergency Rotation Checklist\r\n\r\nWhen a secret is confirmed leaked:\r\n\r\n1. **Immediately revoke** the compromised credential at the provider level.\r\n2. Generate and deploy a replacement credential to all consumers.\r\n3. Audit access logs for unauthorized usage during the exposure window.\r\n4. Scan git history, CI logs, and artifact registries for the leaked value.\r\n5. File an incident report documenting scope, timeline, and remediation steps.\r\n6. Review and tighten detection controls to prevent recurrence.\r\n\r\n---\r\n\r\n## CI/CD Secret Injection\r\n\r\nSecrets in CI/CD pipelines require careful handling to avoid exposure in logs, artifacts, or pull request contexts.\r\n\r\n### GitHub Actions\r\n\r\n- Use **repository secrets** or **environment secrets** via `${{ secrets.SECRET_NAME }}`.\r\n- Prefer **OIDC federation** (`aws-actions/configure-aws-credentials` with `role-to-assume`) over long-lived access keys.\r\n- Environment secrets with required reviewers add approval gates for production deployments.\r\n- GitHub automatically masks secrets in logs, but avoid `echo` or `toJSON()` on secret values.\r\n\r\n### GitLab CI\r\n\r\n- Store secrets as **CI/CD variables** with the `masked` and `protected` flags enabled.\r\n- Use **HashiCorp Vault integration** (`secrets:vault`) for dynamic secret injection without storing values in GitLab.\r\n- Scope variables to specific environments (`production`, `staging`) to enforce least privilege.\r\n\r\n### Universal Patterns\r\n\r\n- **Never echo or print** secret values in pipeline output, even for debugging.\r\n- **Use short-lived tokens** (OIDC, STS AssumeRole) instead of static credentials wherever possible.\r\n- **Restrict PR access** — do not expose secrets to pipelines triggered by forks or untrusted branches.\r\n- **Rotate CI secrets** on the same schedule as application secrets; pipeline credentials are attack vectors too.\r\n- **Audit pipeline logs** periodically for accidental secret exposure that masking may have missed.\r\n\r\n---\r\n\r\n## Pre-Commit Secret Detection\r\n\r\nCatching secrets before they reach version control is the most cost-effective defense. Two leading tools cover this space.\r\n\r\n### gitleaks\r\n\r\n```toml\r\n# .gitleaks.toml — minimal configuration\r\n[extend]\r\nuseDefault = true\r\n\r\n[[rules]]\r\nid = \"custom-internal-token\"\r\ndescription = \"Internal service token pattern\"\r\nregex = '''INTERNAL_TOKEN_[A-Za-z0-9]{32}'''\r\nsecretGroup = 0\r\n```\r\n\r\n- Install: `brew install gitleaks` or download from GitHub releases.\r\n- Pre-commit hook: `gitleaks git --pre-commit --staged`\r\n- Baseline scanning: `gitleaks detect --source . --report-path gitleaks-report.json`\r\n- Manage false positives in `.gitleaksignore` (one fingerprint per line).\r\n\r\n### detect-secrets\r\n\r\n```bash\r\n# Generate baseline\r\ndetect-secrets scan --all-files > .secrets.baseline\r\n\r\n# Pre-commit hook (via pre-commit framework)\r\n# .pre-commit-config.yaml\r\nrepos:\r\n - repo: https://github.com/Yelp/detect-secrets\r\n rev: v1.5.0\r\n hooks:\r\n - id: detect-secrets\r\n args: ['--baseline', '.secrets.baseline']\r\n```\r\n\r\n- Supports **custom plugins** for organization-specific patterns.\r\n- Audit workflow: `detect-secrets audit .secrets.baseline` interactively marks true/false positives.\r\n\r\n### False Positive Management\r\n\r\n- Maintain `.gitleaksignore` or `.secrets.baseline` in version control so the whole team shares exclusions.\r\n- Review false positive lists during security audits — patterns may mask real leaks over time.\r\n- Prefer tightening regex patterns over broadly ignoring files.\r\n\r\n---\r\n\r\n## Audit Logging\r\n\r\nKnowing who accessed which secret and when is critical for incident investigation and compliance.\r\n\r\n### Cloud-Native Audit Trails\r\n\r\n| Provider | Service | What It Captures |\r\n|----------|---------|-----------------|\r\n| **AWS** | CloudTrail | Every `GetSecretValue`, `DescribeSecret`, `RotateSecret` API call |\r\n| **Azure** | Activity Log + Diagnostic Logs | Key Vault access events, including caller identity and IP |\r\n| **GCP** | Cloud Audit Logs | Data access logs for Secret Manager with principal and timestamp |\r\n| **Vault** | Audit Backend | Full request/response logging (file, syslog, or socket backend) |\r\n\r\n### Alerting Strategy\r\n\r\n- Alert on **access from unknown IP ranges** or service accounts outside the expected set.\r\n- Alert on **bulk secret reads** (more than N secrets accessed within a time window).\r\n- Alert on **access outside deployment windows** when no CI/CD pipeline is running.\r\n- Feed audit logs into your SIEM (Splunk, Datadog, Elastic) for correlation with other security events.\r\n- Review audit logs quarterly as part of access recertification.\r\n\r\n---\r\n\r\n## Cross-References\r\n\r\nThis skill covers env hygiene and secret detection. For deeper coverage of related domains, see:\r\n\r\n| Skill | Path | Relationship |\r\n|-------|------|-------------|\r\n| **Secrets Vault Manager** | `engineering/secrets-vault-manager` | Production vault infrastructure, HA deployment, DR |\r\n| **Senior SecOps** | `engineering/senior-secops` | Security operations perspective, incident response |\r\n| **CI/CD Pipeline Builder** | `engineering/ci-cd-pipeline-builder` | Pipeline architecture, secret injection patterns |\r\n| **Infrastructure as Code** | `engineering/infrastructure-as-code` | Terraform/Pulumi secret backend configuration |\r\n| **Container Orchestration** | `engineering/container-orchestration` | Kubernetes secret mounting, sealed secrets |"
user_template: ""
variables: []
install:
steps:
- title: Download & unzip
detail: >-
Download the .zip package from SkillVault and unzip it. The env-secrets-manager/ folder
contains SKILL.md plus any companion scripts, references and assets.
- title: Copy into your agent skills directory
detail: >-
Move the folder into your agent's skills directory — e.g. ~/.claude/skills/ (Claude Code),
.codex/skills/, .cursor/skills/ or your project's .claude/skills/ folder — then restart or
reload the session.
- title: Use it
detail: >-
Describe the task in natural language; the agent loads the skill automatically when the
request matches the skill description.
usage:
steps: []
metadata:
author: SkillVault
source: https://skillvault.top/skills/env-secrets-manager
exported_at: "2026-11-03T07:42:27.635Z"
Installation guide
- 1
Download & unzip
Download the .zip package from SkillVault and unzip it. The env-secrets-manager/ folder contains SKILL.md plus any companion scripts, references and assets.
- 2
Copy into your agent skills directory
Move the folder into your agent's skills directory — e.g. ~/.claude/skills/ (Claude Code), .codex/skills/, .cursor/skills/ or your project's .claude/skills/ folder — then restart or reload the session.
- 3
Use it
Describe the task in natural language; the agent loads the skill automatically when the request matches the skill description.
How to use
Platform compatibility
ChatGPT GPTs
OpenAI
Paste the system prompt into the GPT "Instructions" field and keep the user template as your starter message.
Official docsClaude Code
Anthropic
Save the exported .aiskill JSON as a skill file in your project or paste the system prompt into CLAUDE.md / a slash-command markdown file.
Official docsCursor
Anysphere
Copy the system prompt into .cursor/rules/*.mdc (or Project Rules in Settings) and reference the user template in your agent prompts.
Official docsRelated skills
dependency-auditor
Audit and manage dependencies across multi-language projects. Identifies vulnerabilities, license conflicts, transitive dependency risks, and safe-upgrade paths. Use when auditing third-party packages before release, investigating a CVE, planning a major version bump, or running a license-compliance review. Examples: 'audit our npm dependencies', 'do we have GPL contamination', 'plan the upgrade to React 19'.
docker-development
Docker and container development agent skill and plugin for Dockerfile optimization, docker-compose orchestration, multi-stage builds, and container security hardening. Use when: user wants to optimize a Dockerfile, create or improve docker-compose configurations, implement multi-stage builds, audit container security, reduce image size, or follow container best practices. Covers build performance, layer caching, secret management, and production-ready container patterns.
helm-chart-builder
Helm chart development agent skill and plugin for Claude Code, Codex, Gemini CLI, Cursor, OpenClaw — chart scaffolding, values design, template patterns, dependency management, security hardening, and chart testing. Use when: user wants to create or improve Helm charts, design values.yaml files, implement template helpers, audit chart security (RBAC, network policies, pod security), manage subcharts, or run helm lint/test.