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
In this repository21 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- a11y-page-auditSkill
- branch-comment-cleanupSkill
- branch-test-planSkill
- context7-mcpSkill
- feature-based-architectureSkill
- great-readmeSkill
- harvest-reviewsSkill
- light-dark-modeSkill
- localizationSkill
- minimal-code-changesSkill
- prod-page-auditSkill
- quantum-design-tokensSkill
- reviewable-commitsSkill
- shell-aliases-socialSkill
- skill-best-practices-syncSkill
- skills-auditSkill
- skills-socialSkill
- stacked-pr-splitterSkill
- team-reviewerSkill
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
- Very specific: line 21
Only .env is rewritten.
- Very specific: line 25
Default to .env and .env.example at the repo root.
- Very specific: line 26
If either path is ambiguous or multiple exist (e.g.
- Very specific: line 28
If .env does not exist, ask whether to create it from .env.example verbatim, then stop.
- Very specific: line 33
Read both files fully and build key sets: example-order list, .env-active, .env-commented, .env-only.
- Distinctive: line 53
Ask these as one batched question (skip any already answered):
- Very specific: line 59
Default if the user says "just do it": move everything .env-only to Local extras.
- Very specific: line 64
Write the mirrored body and the Local extras block to .env.
- Very specific: line 68
After writing, re-read .env and confirm: (a) body key order equals .env.example key order.
- Very specific: line 72
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.
≈ “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.
Files
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)
- Never change, comment out, or uncomment an existing active value in
.env. Preserve key, value, and quoting exactly. - Never print full secret values back to the user. Refer to them by key name only.
- Never touch
.env.example. It is the source of truth for order/structure only. - Only
.envis rewritten.
Inputs
- Default to
.envand.env.exampleat the repo root. - If either path is ambiguous or multiple exist (e.g.
apps/*/.env), ask which pair before doing anything. - If
.envdoes not exist, ask whether to create it from.env.exampleverbatim, 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:
- Mirrored body — every section/comment/key from
.env.example, in the same order.- Key active in
.env: keep the.envvalue (uncommented), placed at the example's position. - Key commented (placeholder) in
.env.exampleand absent from.env: copy the commented line verbatim. - Preserve the example's section header comments and blank-line spacing.
- Key active in
- 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.
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.

