env-setup
Skill8 starsChanged 48 days 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
7 other projects use a version of this.
Adopted by
Most recently taken up by
- jars-demo/jars-skillstheir own version, first seen Oct 25, 2026
- njt2810/claude-code-frameworktheir own version, first seen Sep 10, 2026
- Jinbae10/skillstheir own version, first seen Jul 7, 2026
- GlamgarOnDiscord/claude-saas-blueprinttheir own version, first seen May 17, 2026
- viknesh20-20/claude-code-tool-kittheir own version, first seen May 2, 2026
- khanashes/claude-skillstheir own version, first seen Apr 30, 2026
Used with
Projects with it also use api-design.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
MicrosoftSkillapi-design
Guide for designing and documenting RESTful APIs. Use when asked to design an API, create endpoints, or document an API.
Also in 3 projects that use this
Other versions7 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 7
- viknesh20-20/claude-code-tool-kit★ 7same name
- GlamgarOnDiscord/claude-saas-blueprint★ 2same name
- njt2810/claude-code-framework★ 1same name
- 354685856-sn/claude-code-skills★ 0same name
- jars-demo/jars-skills★ 0same name
- Jinbae10/skills★ 0same name
- khanashes/claude-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository53 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- agent-browserSkill
- anything-to-skillSkill
- ci-generateSkill
- ci-localSkill
- clotho-researchSkill
- codex-imagegenSkill
- create-ruleSkill
- create-skillSkill
- db-migrateSkill
- docker-initSkill
- docs-adrSkill
- docs-checkSkill
- docs-diagramSkill
- docs-initSkill
- docs-rfcSkill
- docs-updateSkill
- find-skillsSkill
- fix-bugSkill
- git-commitSkill
- git-create-prSkill
- gitflowSkill
- git-releaseSkill
- git-syncSkill
- i18n-checkSkill
- implement-featureSkill
- improve-skillSkill
- inject-docsSkill
- jira-cliSkill
- motion-studioSkill
- optimize-ai-setupSkill
- orchestrateSkill
- oss-launchSkill
- prd-to-issuesSkill
- product-design-specSkill
- product-design-tokensSkill
- product-prdSkill
- project-illustratorSkill
- project-plannerSkill
- refactorSkill
- renderSkill
- review-codeSkill
- review-depsSkill
- review-designSkill
- review-perfSkill
- review-planSkill
- review-securitySkill
- shipSkill
- stopslopSkill
- test-suiteSkill
- vrt-checkSkill
- wtfSkill
The file
We split this skill into the rules it gives an agent
8 rules. 0 are common, 2 are distinctive, and 6 are very specific to this project.
0
Common
Most of the 5 edited versions we read keep these.
2
Distinctive
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
- Distinctive: line 18
Only report variables that are actually found in the code:
- Very specific: line 20
Read .env.example before writing: preserve existing entries, only add/update what changed.
- Very specific: line 21
No actual secrets: .env.example must only contain placeholder values (e.g., your_api_key_here).
- Very specific: line 22
Verify .gitignore: actually read the file before claiming .env is ignored.
- Very specific: line 49
Read existing .env.example (if it exists):
- Very specific: line 86
Read .env by key name only, never with Read or cat (they print values): grep -nE '^(export )?[A-Za-z_][A-Za-z0-9_]*=' .env | cut -d= -f1, …
- Very specific: line 133
Check NEXT_PUBLIC_*, VITE_*, REACT_APP_* variables
- Distinctive: line 134
If any contain "secret", "key", "password", "token" in the name, warn loudly, by variable name only
“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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:
- Grep before reporting: never invent variable names, only list what grep actually returns.
- Read
.env.examplebefore writing: preserve existing entries, only add/update what changed. - No actual secrets:
.env.examplemust only contain placeholder values (e.g.,your_api_key_here). - Verify
.gitignore: actually read the file before claiming.envis ignored. - Never echo a found secret value: when Phase 6 flags a leaked secret, report the variable name and
file:lineonly. 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.examplebut 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 32Full 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 by key name only, never with Read or cat (they print values): grep -nE '^(export )?[A-Za-z_][A-Za-z0-9_]*=' .env | cut -d= -f1, and grep -nE '=\s*$' .env | cut -d= -f1 for empty values. Check:
- Missing required variables: every variable in code without a default/fallback must be set.
- Empty values:
VAR=with no value is suspicious for required vars. - Stale variables: present in
.envbut not found in codebase scan. .gitignorecheck: verify.env(and.env.local) are in.gitignore.
grep -E "^\.env" .gitignore 2>/dev/nullWarn clearly if .env is NOT in .gitignore.
Phase 6: Secret Detection (if --check-secrets)
Scan .env, git history and source for secrets. Every command below emits only variable names and file:line, never a value. Do not swap in a plain grep (or Read) that prints matching lines.
Requires gitleaks (brew install gitleaks); if command -v gitleaks finds nothing, skip to the grep checks.
gitleaks detect --source=. --redact --no-banner -vGrep checks, which also work without gitleaks:
# Secret-looking assignments in .env: line:NAME
grep -inE "(password|secret|api_key|private_key|token|auth_key)[A-Za-z0-9_]*\s*=\s*['\"]?[A-Za-z0-9+/_.=-]{16,}" .env 2>/dev/null | cut -d= -f1
# Known key formats hardcoded in files: file:line
grep -rnIE "(AKIA[0-9A-Z]{16}|sk_live_[A-Za-z0-9]+|xox[abp]-[A-Za-z0-9-]+|gh[pousr]_[A-Za-z0-9]{36})" . --exclude-dir=.git --exclude-dir=node_modules 2>/dev/null | cut -d: -f1,2
# Commits that added .env to history
git log --all --full-history --diff-filter=A --format=%h -- .env 2>/dev/null
# Secret-looking names that appeared in .env history
git log --all --full-history -p --format= -- .env 2>/dev/null | grep -iE "^\+.*(password|secret|key)\s*=" | cut -d= -f1 | sort -uThe 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.
Report each hit as a commit + file:line reference plus the variable name (e.g. .env:12 STRIPE_SECRET_KEY),
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.baselinegitleaks:gitleaks detect --source=. --redact --no-banner -v
Argument Parsing
scan(default): Scan codebase, generate/update.env.examplevalidate: Validate.envagainst discovered variablessync: Sync.env.exampleto match current codebase (add missing, mark stale)--check-secrets: Enable secret detection in.envand git history
Important Notes
| Note | Detail |
| Never include real secrets | .env.example holds only placeholder values |
| Never echo a found secret's value | report variable name + file:line only, whether the finding goes to chat or a report file |
| Client-exposed vars | NEXT_PUBLIC_*, VITE_* are bundled into the frontend; flag if their name suggests a secret |
.env must be gitignored | verify and warn if not |
| Historical leaks matter | even if .env is gitignored now, it may have been committed in the past |
| Stale variables | unused entries in .env can be security risks; document and remove them |
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
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.

