agentleFS
mgiovanimgiovani/cc-arsenal/skills/env-setup/SKILL.md

env-setup

Skill8 starsChanged 2 months agoMITView on GitHub

Scans a codebase for environment variable usage to generate or sync .env.example, validate .env completeness against what the code actually reads, and detect leaked secrets in .env or git history. Use for "/env-setup", "update .env.example", "sync .env.example with the codebase", "check if .env has everything it needs", "is .env in .gitignore", or "scan for leaked secrets in .env". Not a full security audit (use review-security for OWASP-level scanning) and not a generic secret-rotation or CI-secrets-injection tool.

  • Reads credentials
  • Installs packages

4 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

9 rules. About 0 are common, 3 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Only report variables that are actually found in the code:

    line 25
  2. Very specific:

    Read .env.example before writing: preserve existing entries, only add/update what changed.

    line 27
  3. Very specific:

    No actual secrets: .env.example must only contain placeholder values (e.g., your_api_key_here).

    line 28
  4. Very specific:

    Verify .gitignore: actually read the file before claiming .env is ignored.

    line 29
  5. Very specific:

    Read existing .env.example (if it exists):

    line 56
  6. Very specific:

    Read .env and check:

    line 93
  7. Distinctive:

    Check git history for leaked secrets:

    line 119
  8. Very specific:

    Check NEXT_PUBLIC_*, VITE_*, REACT_APP_* variables

    line 128
  9. Distinctive:

    If any contain "secret", "key", "password", "token" in the name, warn loudly, by variable name only

    line 129

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Env Setup

Scan the codebase for environment variable usage, generate or update .env.example, validate .env completeness, and detect leaked secrets.

Anti-hallucination guidelines

Only report variables that are actually found in the code:

  1. Grep before reporting: never invent variable names, only list what grep actually returns.
  2. Read .env.example before writing: preserve existing entries, only add/update what changed.
  3. No actual secrets: .env.example must only contain placeholder values (e.g., your_api_key_here).
  4. Verify .gitignore: actually read the file before claiming .env is ignored.
  5. Never echo a found secret value: when Phase 6 flags a leaked secret, report the variable name and file:line only. Never print, quote, or write the actual value into chat output, a report file, or anywhere else: the scan's job is to locate leaks, not to create a second one.

Workflow

Phase 1: Scan Codebase

Grep for environment variable usage matching the project's actual language/framework: see references/scan-patterns.md for the ready-to-run pattern per language (Node/TS, Python, Ruby, Rust, Java/Kotlin, Docker Compose, client-exposed prefixes). Only run the pattern(s) for stacks present in the repo.

Also scan:

  • .env.example (existing entries to preserve)
  • config/ directory for config files referencing env vars
  • Framework config files (next.config.js, vite.config.ts, etc.)

Phase 2: Categorize Variables

Group discovered variables by prefix/service: see the service prefix table in references/scan-patterns.md for the standard groupings (Database, Cache, Auth, OAuth, Stripe, AWS, Email, App config, Client vars).

Classify each variable:

  • Required vs optional: required if no default/fallback in code.
  • Secret vs config: secret if it contains key/secret/password/token in the name.
  • Client-exposed: NEXT_PUBLIC_*, VITE_*; flag if it contains secrets.

Phase 3: Compare with .env.example

Read existing .env.example (if it exists):

# Variables in code but NOT in .env.example (missing)
# Variables in .env.example but NOT in code (undocumented/stale)
# Variables in both (up to date)

Report:

  • Missing vars (need to be added to .env.example)
  • Stale vars (in .env.example but no longer used)
  • Up-to-date vars

Phase 4: Generate / Update .env.example

For scan or sync operations:

Generate .env.example with:

  • SCREAMING_SNAKE_CASE variable names
  • Grouped by service (with section comments)
  • Placeholder values for secrets, real defaults for config
  • Type and description comments
# =============================================================================
# Database
# =============================================================================
DATABASE_URL=postgresql://user:password@localhost:5432/app_development
JWT_SECRET=your_jwt_secret_here  # openssl rand -hex 32

Full section-header style and rules (preserve existing entries, only add what's missing, never a real value), see references/env-example-template.md, load it when writing the actual file.

Phase 5: Validate .env (if validate subcommand or .env exists)

Read .env and check:

  1. Missing required variables: every variable in code without a default/fallback must be set.
  2. Empty values: VAR= with no value is suspicious for required vars.
  3. Stale variables: present in .env but not found in codebase scan.
  4. .gitignore check: verify .env (and .env.local) are in .gitignore.
grep -E "^\.env" .gitignore 2>/dev/null

Warn clearly if .env is NOT in .gitignore.

Phase 6: Secret Detection (if --check-secrets)

Scan .env for high-entropy strings and known secret patterns:

# Check for common secret patterns
grep -iE "(password|secret|api_key|private_key|token|auth_key)\s*=\s*['\"]?[A-Za-z0-9+/_.=-]{16,}" .env 2>/dev/null

The character class includes _, -, . alongside base64's +/=: most real key formats (sk_live_..., xoxb-..., AKIA...) contain underscores or hyphens, and a base64-only class silently misses them.

Check git history for leaked secrets:

git log --all --full-history --diff-filter=A -p -- .env 2>/dev/null | grep -iE "(password|secret|key)\s*=" | head -20

Report each hit as a commit + file:line reference (e.g. git log output line, or .env:12), never paste the matched value itself into the report.

Flag client-exposed secrets:

  • Check NEXT_PUBLIC_*, VITE_*, REACT_APP_* variables
  • If any contain "secret", "key", "password", "token" in the name, warn loudly, by variable name only

Recommend pre-commit tools:

  • detect-secrets (Python): pip install detect-secrets && detect-secrets scan > .secrets.baseline
  • gitleaks: gitleaks detect --source=.

Argument Parsing

  • scan (default): Scan codebase, generate/update .env.example
  • validate: Validate .env against discovered variables
  • sync: Sync .env.example to match current codebase (add missing, mark stale)
  • --check-secrets: Enable secret detection in .env and git history

Important Notes

NoteDetail
Never include real secrets.env.example holds only placeholder values
Never echo a found secret's valuereport variable name + file:line only, whether the finding goes to chat or a report file
Client-exposed varsNEXT_PUBLIC_*, VITE_* are bundled into the frontend; flag if their name suggests a secret
.env must be gitignoredverify and warn if not
Historical leaks mattereven if .env is gitignored now, it may have been committed in the past
Stale variablesunused entries in .env can be security risks; document and remove them

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.