migrate-env-to-1password
Move the secrets in your .env file into 1Password using the official op CLI, then rewrite .env to reference those entries via op:// URIs. Commands still run via op run --env-file=.env -- <cmd>.
Install with your preferred package manager.
gh skill install oharu121/skills migrate-env-to-1passwordnpx skills add oharu121/skills/migrate-env-to-1passwordpnpm dlx skills add oharu121/skills/migrate-env-to-1passwordWhat it does
Section titled “What it does”A .env with plaintext API keys is the default on most projects, and a known risk. The remediation — op:// references resolved at runtime by the op CLI — is correct but fiddly: you create the 1Password item, hand-build the op://Vault/Item/Field URI for every key, and hope you didn’t typo. This skill does that migration end-to-end.
It reads your .env, confirms which variables to migrate, creates a single 1Password login item holding all of them in the vault you pick, then rewrites .env so each line points to the right field. A final verification runs op run --env-file=.env -- env and confirms every variable resolves.
The skill runs fully interactively — every destructive step (creating the 1Password item, overwriting .env) waits on AskUserQuestion confirmation. If op isn’t installed, it offers to install via brew install --cask 1password-cli.
When to use it
Section titled “When to use it”- Your project still has plaintext
.envvalues and you want them in a vault before the next team member joins - You’ve set up 1Password but never did the migration for an existing project — this finishes the job
- You want a tested round-trip:
.env→ 1Password items →op://refs → verified resolution
How it works
Section titled “How it works”-
Read
.env. Variables and values are listed. You confirm which to migrate. -
Install
opif missing.which opis checked; if absent, the skill asks to runbrew install --cask 1password-cli. -
Verify auth.
op whoamichecks you’re signed in. If not, the skill walks you through enabling Settings → Developer → Connect with 1Password CLI in the desktop app, or runningeval $(op signin). -
Pick a vault.
op vault listsurfaces your vaults; you pick one viaAskUserQuestion. -
Create the 1Password item. A single login item with all migrated variables as fields. Title defaults to the project directory name but is confirmable.
-
Rewrite
.env. EachKEY=valuebecomesKEY=op://Vault/Item/Field. The skill shows you the diff before overwriting. -
Verify.
op run --env-file=.env -- env | grep <KEY>confirms each variable resolves. Success message includes theop runusage pattern for running your actual commands.
Example
Section titled “Example”Before:
OPENAI_API_KEY=sk-proj-abc123...DATABASE_URL=postgres://user:pass@host/dbSTRIPE_SECRET_KEY=sk_test_xyz...After the migration, the same file reads:
OPENAI_API_KEY=op://Personal/my-app/openai_api_keyDATABASE_URL=op://Personal/my-app/database_urlSTRIPE_SECRET_KEY=op://Personal/my-app/stripe_secret_keyAnd every command you’d normally run gets a wrapper:
op run --env-file=.env -- node script.jsop run --env-file=.env -- python main.py- Scripts that read
.envdirectly will get the literalop://string, not the value. Pipe them throughop runor use a library that callsop read. - Git history: if plaintext values were ever committed, rotating them after migration is part of the remediation, not an optional step.
- Rate limits: on large projects,
ophits a rate limit; wait and retry is safe.
Related skills
Section titled “Related skills”Source
Section titled “Source”View SKILL.md on GitHub — full interactive workflow, error handling, rate-limit guidance.