agentleFS
neeraj181-dotneeraj181-dot/ClaudeSkills/.claude/skills/env-guard/SKILL.md

env-guard

Skill0 starsChanged 3 months agoApache-2.0View on GitHub

Safely configure a project's API credentials via environment variables and local .env files while making accidental Git exposure extremely difficult. Detects the stack, sets the right env var name, protects .env via .gitignore, maintains a secret-free .env.example, scans for hardcoded secrets, and checks Git tracking/history — never printing, committing, or hardcoding a secret, and never rewriting Git history automatically. Only touches the specified project. Works across JS/Node, Python/Django, and similar stacks. Use when the user wants to set up an API key/token/secret, add .env handling, stop secrets leaking into Git, or check for exposed credentials.

  • Reads credentials

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

14 rules. About 0 are common, 4 are distinctive, and 10 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 10

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Very specific:

    When the user provides a key and asks to configure it, determine the correct variable name — e.g.

    line 21
  2. Very specific:

    If the required name is ambiguous, ask.

    line 23
  3. Very specific:

    If the project uses .env, ensure it's git-ignored:

    line 27
  4. Very specific:

    Create or update .env.example with variable names only, never real secrets:

    line 44
  5. Very specific:

    When the user explicitly provides a secret and asks to configure it, store it in the appropriate local config — prefer .env for …

    line 57
  6. Very specific:

    Search the project for likely hardcoded secrets — API keys, tokens, bearer tokens, secret keys, passwords, private credentials (common …

    line 63
  7. Distinctive:

    Never display the actual value.

    line 71
  8. Very specific:

    Run git status and determine whether .env is already tracked.

    line 75
  9. Distinctive:

    If a secret appears to have already been committed, do NOT attempt automatic history rewriting.

    line 82
  10. Distinctive:

    Remove the secret from current files.

    line 85
  11. Distinctive:

    Never expose the secret in the report.

    line 88
  12. Very specific:

    Verify: .env exists where appropriate · .env is ignored · .env.example has placeholders only · app config references the env var · the …

    line 104
  13. Very specific:

    Never print the secret while verifying: Prefer a plain status — API key: CONFIGURED — or masked form at most — sk-….

    line 106
  14. Very specific:

    Only modify the exact project folder the user specified.

    line 114

≈ “Common” is an estimate: at least 1 in 5 of the 372,429 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 Guard

Safely configure project API credentials using environment variables and local .env files, while preventing secrets from ever reaching Git. The goal: "Configure credentials automatically while making accidental Git exposure extremely difficult."

Core principle: API keys, tokens, passwords, and secrets must NEVER be hardcoded into source or committed to Git. The actual secret value must never be written into source code · README/docs · Git commits · GitHub repos · committed config files · logs · or terminal output. Use env vars and local .env files instead.

This skill only touches the specified project (see Phase 12) and never rewrites Git history on its own (Phase 8).

Phase 1 — Inspect the project

Detect (don't modify yet): framework · language · package manager · existing .env files · .env.example · .gitignore · whether it's a Git repo · existing env-var conventions · existing API configuration.

Phase 2 — Determine the env variable name

When the user provides a key and asks to configure it, determine the correct variable name — e.g. ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN, OPENAI_API_KEY, GOOGLE_API_KEY, GITHUB_TOKEN, STRIPE_SECRET_KEY.

If the required name is ambiguous, ask. Never guess a provider's auth variable when a wrong guess could make the app fail (e.g. _API_KEY vs _AUTH_TOKEN + _BASE_URL).

Phase 3 — Protect .env

If the project uses .env, ensure it's git-ignored:

  • No .gitignore? Create one in the current project.
  • Existing .gitignore? Preserve its contents; add only the missing entries.

Common entries:

.env
.env.local
.env.*.local

Do not blindly ignore .env.example — that file is meant to be committed.

Phase 4 — Create/update .env.example

Create or update .env.example with variable names only, never real secrets:

ANTHROPIC_API_KEY=your_api_key_here
# or:
ANTHROPIC_BASE_URL=https://example.com
ANTHROPIC_AUTH_TOKEN=your_token_here

Never copy a real token into .env.example.

Phase 5 — Configure the local environment

When the user explicitly provides a secret and asks to configure it, store it in the appropriate local config — prefer .env for project-local application credentials. For Claude Code-specific env vars, use the appropriate Claude Code config or shell environment per the user's request.

Never reach for system-wide environment variables when project-local config is sufficient. Write the value only to the local .env (which Phase 3 has ignored) — and never echo it back.

Phase 6 — Hardcoded-secret detection

Search the project for likely hardcoded secrets — API keys, tokens, bearer tokens, secret keys, passwords, private credentials (common prefixes like sk-, ghp_, AKIA, Bearer , long base64/hex blobs).

Do not print any discovered secret. Report only the location:

⚠ Potential secret found in <file>:<line>

Never display the actual value.

Phase 7 — Git tracking safety

Run git status and determine whether .env is already tracked.

  • Untracked and ignored → good.
  • Already tracked → STOP. Explain: "The .env file is already tracked by Git." Ask permission before running git rm --cached .env. Never delete the user's local .env (only untrack it, and only with consent).

Phase 8 — Git history safety

If a secret appears to have already been committed, do NOT attempt automatic history rewriting. Explain that removing a secret from the working tree does not remove it from history. Recommend, in order:

  1. Rotate/revoke the exposed credential (most important).
  2. Remove the secret from current files.
  3. Clean Git history separately if necessary (e.g. git filter-repo / BFG) — as a deliberate, user-driven step.

Never expose the secret in the report.

Phase 9 — Framework integration

Where appropriate, wire the app to read the env var — without inventing application logic:

JavaScript   process.env.API_KEY
Python       os.getenv("API_KEY")
Django       os.environ.get("API_KEY")

Only modify application logic if the user asked for API integration/configuration. Otherwise, stop at env/ignore/example setup.

Phase 10 — Verification (masked)

Verify: .env exists where appropriate · .env is ignored · .env.example has placeholders only · app config references the env var · the secret is not in tracked source · git status doesn't show .env as untracked.

Never print the secret while verifying. Prefer a plain status — API key: CONFIGURED — or masked form at most — sk-****…****.

Phase 11 — Multiple environments

Support: Development → .env; Production → the platform/host secret manager; Testing → .env.test or test env vars. Never recommend committing production secrets.

Phase 12 — Scope safety

Only modify the exact project folder the user specified. Never modify another project, another repository, global Git configuration, or system environment variables — unless explicitly requested. (Pairs with safe-scope.)

Phase 13 — Final report

╭─ Environment Security ───────────────────────╮
│ API variable   │ CONFIGURED                  │
│ .env           │ PROTECTED                   │
│ .gitignore     │ UPDATED                     │
│ .env.example   │ SAFE                        │
│ Git status     │ CLEAN                       │
╰───────────────────────────────────────────────╯

Then:

## Files Changed
(files changed — never revealing secrets)

## Security Status
(is the credential protected?)

## Git Status
(could the secret be committed? is .env tracked?)

## Remaining Issues
(anything needing user action — e.g. rotate an exposed key)

Report real states only — if .env is still tracked or a secret was already committed, say so plainly rather than showing a green dashboard.


Critical security rules — always: NEVER print API keys or tokens; NEVER put secrets in .env.example; NEVER commit .env; NEVER hardcode secrets into source; NEVER push secrets to GitHub; NEVER expose secrets in error messages, logs, or terminal output; NEVER put secrets in README files; NEVER rewrite Git history automatically; NEVER delete a user's .env; NEVER modify another project; if a secret was exposed publicly, recommend rotating it; and if .env is already tracked, ask before removing it from tracking.

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.