Environment variables and secrets: configuration per stage, 1Password Environments, generating .env with the 1Password CLI, never committing .env, and validating variables against a schema at startup. Load when working with configuration, .env files, or secrets.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Is that skill safe to install?
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
Are you the author of Environment Variables?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/the-up-environment-variables)
---
name: environment-variables
description: "Environment variables and secrets: configuration per stage, 1Password Environments, generating .env with the 1Password CLI, never committing .env, and validating variables against a schema at startup. Load when working with configuration, .env files, or secrets."
---
# Environment Variables
- Don't hard-code configuration; read it from the environment per stage (local, staging, prod).
- If the project has no secret management, propose 1Password Environments; use a separate Environment for each stage (for example `<repo>-local`, `<repo>-staging`, `<repo>-prod`).
- Generate the local `.env` in every worktree from the `<repo>-local` Environment with the 1Password CLI; don't use 1Password's `.env` mount feature.
- According to the official documentation, reading Environments from the CLI requires the beta CLI (at least 2.33.0-beta.02); if `op environment` isn't in the stable release, stay on the beta channel. If the CLI isn't installed or isn't current, install the latest beta from the official release page, and before installing it, confirm that it includes the `op environment read` command; `op update` can suggest a stable release even on the beta channel.
- Write `.env` as UTF-8 without a BOM: in a POSIX shell or Git Bash, use `op environment read <environment-id> > .env`; in Windows PowerShell 5.1, `>` adds a BOM.
- Don't commit `.env` files; confirm that they're in `.gitignore`.
- Validate the required variables against a schema when the application starts; if any are missing or invalid, don't start the application.
- Don't read, generate, or print staging and prod secret values; the user enters them in 1Password. Mark the secret values you add as `concealed`.