Skip to content
Agentmart
Submit a tool

env-setup

Scans a codebase for environment variable usage to generate or sync .env.example, validate .env completeness against what the code actually reads, and detect…

Skill by mgiovani

IndexedMIT★ 8
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/mgiovani-env-setup

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

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.

Use cases: devops, security

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md and code. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/env-setup

What's inside

Skill name
env-setup
Description
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.
License
MIT
Metadata
author: mgiovani · summary: Scan a codebase for env var usage, sync .env.example, and detect leaked secrets · version: 1.1.0
Instructions
147 lines in SKILL.md · view on GitHub

Files (5)

  • SKILL.md
  • evals.json · evals/
  • trigger-eval.json · evals/
  • env-example-template.md · references/
  • scan-patterns.md · references/

SKILL.md (first lines)

# 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):

```bash
# 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

```bash
# =============================================================================
# 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` 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:

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`.

```bash
grep -E "^\.env" .gitignore 2>/dev/null
```

Warn 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.

```bash
gitleaks detect --source=. --redact --no-banner -v
```

Grep checks, which also work without gitleaks:

```bash
# 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 -u
```

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.

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.

From mgiovani/cc-arsenal, MIT.

More from mgiovani/cc-arsenal

Signals

Stars
8
Forks
1
Open issues
6
Last commit (this folder)
Oct 5, 2026 (23 days ago)
Last release
Oct 7, 2026 (22 days ago)

From GitHub (fetched Oct 24, 2026).

Details

Version
1.1.0
License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from mgiovani

Cite this page

env-setup skill. Agent Mart. https://agentmart.dev/skills/mgiovani-env-setup (last updated 2026-10-24)