direnv-1password
Skill2 starsChanged 3 months agoMITView on GitHub
Designs, reviews, and troubleshoots local developer environments using direnv, .envrc, and 1Password CLI without committing plaintext secrets. Use when adding project environment variables, migrating .env files, creating op:// references, or debugging direnv and 1Password integration.
- Reads credentials
In this repository11 other files it gives its agents.
- AGENTS.mdAGENTS.md
- global/AGENTS.mdAGENTS.md
- adr-documentationSkill
- dreamingSkill
- linear-task-managementSkill
- researchSkill
- code-review-and-qualitySkill
- debugging-and-error-recoverySkill
- security-and-hardeningSkill
- test-driven-developmentSkill
- zikra-memorySkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
19 rules. About 0 are common, 4 are distinctive, and 15 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.
15
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
- Very specific: line 9
Use direnv for directory-scoped non-secret configuration and 1Password for secrets.
- Very specific: line 15
Keep project-specific secrets in the narrowest appropriate vault/item instead of adding everything to LocalEnvironment.
- Distinctive: line 17
Never commit resolved secret values.
- Very specific: line 23
Use this when one command or service needs secrets.
- Very specific: line 30
Keep .envrc limited to non-secrets:
- Distinctive: line 37
Run the application with secrets only in its subprocess:
- Very specific: line 43
Prefer this pattern because secrets do not remain in the interactive shell after the process exits.
- Very specific: line 47
Use one bulk op inject call instead of many op read calls.
- Very specific: line 86
Prefer a reference-only .env.op plus op run.
- Very specific: line 87
Keep non-secret defaults in .envrc.
- Very specific: line 88
Add generated plaintext files to .gitignore.
- Very specific: line 109
Never use set -x while secrets are loaded.
- Distinctive: line 110
Never echo, print, serialize, or snapshot resolved values.
- Very specific: line 111
Never use dotenv .env on a plaintext secret file intended for source control.
- Very specific: line 112
Never put plaintext secrets directly in .envrc.
- Very specific: line 113
Never write resolved op inject output to a tracked file.
- Very specific: line 114
Treat .envrc as code execution.
- Distinctive: line 116
If a secret appears in Git history, logs, or agent output, rotate it.
- Very specific: line 125
Variable expands too early: when testing inside op run, use a subshell: op run -- sh -c 'test -n "$API_TOKEN"'.
≈ “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
direnv + 1Password
Use direnv for directory-scoped non-secret configuration and 1Password for secrets. This machine already has the zsh direnv hook, direnv 2.x, and op 2.x.
Local conventions
- Select the intended 1Password account through
OP_ACCOUNT; never hardcode a personal account identifier in shared files. - Shared integration fields commonly live under
op://Shared/LocalEnvironment/<section>/<field>. - Keep project-specific secrets in the narrowest appropriate vault/item instead of adding everything to
LocalEnvironment. - Secret-reference files may be committed only when revealing vault/item/field names is acceptable to the repository audience.
- Never commit resolved secret values.
Choose the least-exposed pattern
Preferred: command-scoped secrets with op run
Use this when one command or service needs secrets. Commit a reference-only file such as .env.op:
DATABASE_URL="op://Shared/My Project/dev/DATABASE_URL"
API_TOKEN="op://Shared/My Project/dev/API_TOKEN"Keep .envrc limited to non-secrets:
export APP_ENV=development
PATH_add binRun the application with secrets only in its subprocess:
op run --account "$OP_ACCOUNT" --env-file=.env.op -- ./bin/devPrefer this pattern because secrets do not remain in the interactive shell after the process exits. Keep 1Password masking enabled; do not use --no-masking in routine commands.
When interactive tooling truly requires exported secrets
Use one bulk op inject call instead of many op read calls. Create a reference-only .env.tpl:
DATABASE_URL="op://Shared/My Project/dev/DATABASE_URL"
API_TOKEN="op://Shared/My Project/dev/API_TOKEN"Then use a reviewed .envrc:
strict_env
if ! has op; then
log_error "1Password CLI (op) is required"
return 1
fi
: "${OP_ACCOUNT:?set OP_ACCOUNT to your 1Password account identifier}"
export OP_ACCOUNT
watch_file .env.tpl
_resolved="$(op inject --account "$OP_ACCOUNT" --in-file .env.tpl 2>/dev/null)" || {
log_error "Unable to resolve .env.tpl from 1Password; unlock 1Password and run: direnv reload"
return 1
}
eval "$(printf '%s\n' "$_resolved" | direnv dotenv bash /dev/stdin)"
unset _resolved
env_vars_required DATABASE_URL API_TOKENdirenv dotenv bash performs shell-safe quoting. The resolved values still enter the interactive shell and are available to child processes, so use this only when command-scoped op run is impractical.
Setup and review workflow
- Inspect existing
.envrc,.env*,.gitignore, scripts, Compose files, and CI configuration. - Inventory variable names only. Never print or paste values into chat, logs, diffs, tests, or Zikra.
- Identify the correct 1Password account, vault, item, section, and field. Reuse established fields where appropriate.
- Prefer a reference-only
.env.opplusop run; use.env.tpl+ bulkop injectonly for persistent shell variables. - Keep non-secret defaults in
.envrc; keep secrets in 1Password. - Add generated plaintext files to
.gitignore. Avoid generating them at all when the consumer accepts environment variables. - Review every
.envrcas executable code before runningdirenv allow. - Validate without exposing values:
direnv status
op account list
op read --account "$OP_ACCOUNT" 'op://Vault/Item/field' >/dev/null
direnv reload
# Check presence, never value:
direnv exec . sh -c 'test -n "$API_TOKEN"'- For command-scoped mode, verify with a presence check inside
op run:
op run --account "$OP_ACCOUNT" --env-file=.env.op -- sh -c 'test -n "$API_TOKEN"'Hard rules
- Never use
set -xwhile secrets are loaded. - Never echo, print, serialize, or snapshot resolved values.
- Never use
dotenv .envon a plaintext secret file intended for source control. - Never put plaintext secrets directly in
.envrc. - Never write resolved
op injectoutput to a tracked file. - Treat
.envrcas code execution; rundirenv allowonly after reviewing changes. - Remember that same-user processes may be able to inspect environment variables. Use command-scoped secrets and least-privilege 1Password access where practical.
- If a secret appears in Git history, logs, or agent output, rotate it; deletion alone is insufficient.
Troubleshooting
opaccount not found: open 1Password, enable Settings → Developer → Integrate with 1Password CLI, and ensure the intended account is signed in.- Biometric prompt or locked app: unlock 1Password, test one
op read ... >/dev/null, then rundirenv reload. - Changed
.envrcblocked: review the diff, then rundirenv allow. - Slow reloads: replace repeated
op readcalls with oneop inject, or switch to command-scopedop run. - Literal
op://...reaches the app: the command was not wrapped inop run, or the template was loaded withdotenvwithout resolution. - Variable expands too early: when testing inside
op run, use a subshell:op run -- sh -c 'test -n "$API_TOKEN"'.
References
- 1Password: https://developer.1password.com/docs/cli/secrets-environment-variables
- 1Password secret references: https://developer.1password.com/docs/cli/secret-references
- direnv stdlib: https://direnv.net/man/direnv-stdlib.1.html
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
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.

