agentleFS
glrodaszglrodasz/dotfiles/skills/env-example-sync/SKILL.md

env-example-sync

Skill20 starsChanged 14 days agoMITView on GitHub

Reorder a .env to mirror its .env.example, add missing keys as commented defaults, and move .env-only lines to a Local extras block. Use when the user wants to sync, mirror, align, or diff a .env against a .env.example (any project).

  • Reads credentials

The file

We split this skill into the rules it gives an agent

10 rules. About 0 are common, 1 is distinctive, and 9 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 9

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Only .env is rewritten.

    line 21
  2. Very specific:

    Default to .env and .env.example at the repo root.

    line 25
  3. Very specific:

    If either path is ambiguous or multiple exist (e.g.

    line 26
  4. Very specific:

    If .env does not exist, ask whether to create it from .env.example verbatim, then stop.

    line 28
  5. Very specific:

    Read both files fully and build key sets: example-order list, .env-active, .env-commented, .env-only.

    line 33
  6. Distinctive:

    Ask these as one batched question (skip any already answered):

    line 53
  7. Very specific:

    Default if the user says "just do it": move everything .env-only to Local extras.

    line 59
  8. Very specific:

    Write the mirrored body and the Local extras block to .env.

    line 64
  9. Very specific:

    After writing, re-read .env and confirm: (a) body key order equals .env.example key order.

    line 68
  10. Very specific:

    If any check fails, write the original .env content (from the Phase 1 read) back unchanged, report which check failed by key name, and stop.

    line 72

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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 Example Sync

Make a .env mirror its .env.example so the two are trivially diffable, without ever changing the user's real values.

Hard rules (never violate)

  1. Never change, comment out, or uncomment an existing active value in .env. Preserve key, value, and quoting exactly.
  2. Never print full secret values back to the user. Refer to them by key name only.
  3. Never touch .env.example. It is the source of truth for order/structure only.
  4. Only .env is rewritten.

Inputs

  • Default to .env and .env.example at the repo root.
  • If either path is ambiguous or multiple exist (e.g. apps/*/.env), ask which pair before doing anything.
  • If .env does not exist, ask whether to create it from .env.example verbatim, then stop.

Phase 1 — Build the target layout

Read both files fully and build key sets: example-order list, .env-active, .env-commented, .env-only. Detect value differences (same key active in both, different value) — collect, never change.

Plan the new .env as two parts, in this order:

  1. Mirrored body — every section/comment/key from .env.example, in the same order.
    • Key active in .env: keep the .env value (uncommented), placed at the example's position.
    • Key commented (placeholder) in .env.example and absent from .env: copy the commented line verbatim.
    • Preserve the example's section header comments and blank-line spacing.
  2. Trailing block # ===== Local extras (not in .env.example) ===== — every line that exists only in .env (orphan keys, inline alternates, commented variants), kept in their original commented/active state.

Nothing else. No invented keys.

Phase 2 — Confirm decisions

Ask these as one batched question (skip any already answered):

  • Dead/deprecated .env-only blocks: move to Local extras, or delete?
  • Inline commented alternates (staging secrets, alt project ids): keep inline next to their key, or move all to Local extras?

Default if the user says "just do it": move everything .env-only to Local extras; delete nothing.

Phase 3 — Write

Write the mirrored body and the Local extras block to .env.

Phase 4 — Verify

After writing, re-read .env and confirm: (a) body key order equals .env.example key order; (b) the set of active values is unchanged from the original; (c) no key disappeared except ones the user approved for deletion.

If any check fails, write the original .env content (from the Phase 1 read) back unchanged, report which check failed by key name, and stop. Do not attempt a second rewrite.

Report

Always, after writing:

## .env sync — <path>

- Reordering: done / sections moved
- Keys added from example (commented placeholders): <names>
- Keys moved to Local extras: <names>
- Keys deleted (only if the user opted in): <names>
- Value differences left untouched: `KEY` (.env=<value or [secret]>, example=<value>)
- Unsure: <.env lines with no example counterpart that were not clearly classifiable>

Flag value differences explicitly — when the value is not a secret they are real behavioral mismatches, not just secrets.

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.

Reviews can't be read right now.

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.