1Password CLI
Manage secrets through the 1Password CLI (op).
Setup
- Install:
brew install 1password-cli - Enable desktop app integration in 1Password preferences
- Sign in:
op signin - Verify:
op whoami
Common Commands
# List vaults
op vault list
# Get an item
op item get "Item Name" --vault "Vault"
# Read a secret field
op read "op://Vault/Item/field"
# Run a command with secrets injected
op run --env-file=.env -- your-command
# Inject secrets into a template
op inject -i template.env -o .env
Best Practices
- Use
op runorop injectinstead of writing secrets to disk - Never paste secrets into logs, chat, or code
- Use
--accountflag for multi-account setups
