| name | tools-1password-cli |
| description | Comprehensive 1Password CLI (op) skill for secrets management, vault operations, environment injection, shell plugins, service accounts, and CI/CD integration. Use when working with credentials, API keys, environment variables, secure document storage, or automating secrets in development workflows. |
1Password CLI (op) Skill
Master reference for the 1Password CLI (op command) covering secrets management, environment injection, shell plugins, service accounts, and CI/CD automation.
Decision Tree
┌─────────────────────────────────────────────────────────────────────────────────┐
│ 1PASSWORD CLI TASK ROUTER │
└─────────────────────────────────────────────────────────────────────────────────┘
│
┌──────────────┬───────────┼───────────┬──────────────┐
│ │ │ │ │
AUTHENTICATE READ/WRITE INJECT AUTOMATE PLUGINS
│ SECRETS SECRETS │ │
│ │ │ │ │
▼ ▼ ▼ ▼ ▼
┌─────────┐ ┌──────────┐ ┌─────────┐ ┌──────────┐ ┌──────────┐
│Desktop │ │op item │ │op run │ │Service │ │Shell │
│App Int. │ │op read │ │op inject│ │Account │ │Plugins │
│or Token │ │op vault │ │.env │ │CI/CD │ │CLI Auth │
└─────────┘ └──────────┘ └─────────┘ └──────────┘ └──────────┘
Prerequisites
op --version
op whoami
op account list
Authentication Methods
Method 1: Desktop App Integration (Recommended for Development)
Best for interactive use with biometric authentication.
op vault list
Method 2: Service Account Token (CI/CD & Automation)
For non-interactive environments.
export OP_SERVICE_ACCOUNT_TOKEN="ops_..."
op vault list
op item get "API Keys" --vault Production
Create Service Account:
op service-account create "ci-pipeline" \
--vault Dev:read_items \
--vault Staging:read_items,write_items \
--expires-in 90d
Permission Options:
read_items - Read secrets (default)
write_items - Create/edit items (requires read_items)
share_items - Share items (requires read_items)
Method 3: Manual Sign-In (Legacy)
eval $(op signin)
eval $(op signin --account my-team.1password.com)
op signin --raw
Secret Reference Syntax
The op:// URI format for referencing secrets:
op://vault/item/[section/]field[?attribute=value]
Examples
op://Private/GitHub/password
op://Production/Database/Credentials/connection-string
"op://Private/Google/one-time password?attribute=otp"
"op://DevOps/SSH Key/private key?ssh-format=openssh"
Get Reference for Existing Item
op item get "GitHub" --vault Private --fields password --format json | jq -r '.reference'
Reading Secrets
Read Single Secret
op read "op://vault/item/field"
op read "op://Private/API Keys/openai-key"
op read "op://Production/Database/password"
op read --out-file ./key.pem "op://DevOps/Server/ssh-key"
op read --out-file ./cert.pem --file-mode 0600 "op://Production/SSL/certificate"
op read -n "op://Private/Token/value"
Get Item Details
op item get "Database" --vault Production --format json
op item get "GitHub" --fields password
op item get "Database" --fields username,password
op item get "Server" --fields type=concealed
op item get "Google" --otp
op item get "API Key" --vault Shared --share-link
op item get "Secrets" --reveal
Environment Injection
Using op run (Recommended)
Secrets exist only during command execution - never in shell history.
export DB_PASSWORD="op://Production/Database/password"
op run -- ./deploy.sh
op run -- npm start
op run -- docker-compose up
op run -- printenv DB_PASSWORD
op run --no-masking -- printenv DB_PASSWORD
Using .env Files
DATABASE_URL="op://Production/Postgres/connection-string"
API_KEY="op://Production/Stripe/secret-key"
JWT_SECRET="op://Production/Auth/jwt-secret"
op run --env-file=.env -- npm start
op run --env-file=.env.production -- ./deploy.sh
op run --env-file=.env --env-file=.env.local -- npm run dev
Environment-Specific Switching
DB_PASSWORD="op://$APP_ENV/database/password"
API_KEY="op://$APP_ENV/api/key"
APP_ENV=dev op run --env-file=.env -- npm start
APP_ENV=staging op run --env-file=.env -- npm test
APP_ENV=production op run --env-file=.env -- ./deploy.sh
Using op inject (Config Files)
For templating configuration files with secrets.
database:
host: {{ op://Production/DB/host }}
user: {{ op://Production/DB/username }}
pass: {{ op://Production/DB/password }}
op inject -i config.yml.tpl -o config.yml
echo "key: {{ op://Private/API/key }}" | op inject
echo "postgres://{{ op://db/user }}:{{ op://db/pass }}@{{ op://db/host }}/mydb" | op inject
echo "secret: {{ op://$ENV/app/secret }}" | ENV=prod op inject
Vault Operations
List & Search
op vault list
op vault list --format json
op vault get "Production"
op vault get "Production" --format json
Create & Manage
op vault create "API Keys" --icon vault-door --description "Third-party API credentials"
op vault edit "API Keys" --name "External APIs" --icon globe
op vault delete "Old Vault"
Vault Access Management
op vault user grant --vault "Production" --user user@example.com --permissions manage_vault
op vault group grant --vault "Production" --group "DevOps" --permissions manage_vault
op vault user revoke --vault "Production" --user user@example.com
Item Operations
List Items
op item list
op item list --vault Production
op item list --categories Login,Password
op item list --tags api-key,production
op item list --include-archive
op item list --long
op item list --vault Dev --categories "API Credential" --tags active --format json
Create Items
op item create --category Login \
--title "Service Account" \
--vault Production \
--url "https://api.example.com" \
--generate-password='letters,digits,symbols,32' \
username=service@example.com
op item create --category "API Credential" \
--title "OpenAI API" \
--vault "API Keys" \
api-key=sk-xxx... \
--tags "ai,production"
op item create --category "Secure Note" \
--title "Database Credentials" \
--vault Production \
"Connection.host=db.example.com" \
"Connection.port=5432" \
"Connection.database=myapp" \
"Credentials.username=admin" \
"Credentials.password[password]=secret123"
op item create --category "SSH Key" \
--title "Deploy Key" \
--vault DevOps \
--ssh-generate-key ed25519
op item template get Login --out-file login.json
op item create --template login.json --vault Private
op item get "Template Item" --format json | op item create --vault Production -
Edit Items
op item edit "GitHub" --vault Private password="new-password"
op item edit "Service" --generate-password='letters,digits,32'
op item edit "Database" \
username="newuser" \
password="newpass" \
"Connection.host=newhost.example.com"
op item edit "Config" "api-key[password]"
op item edit "Item" "old-field[delete]"
op item edit "API Key" --tags "production,active,v2"
op item edit "Item" --dry-run password="test"
Delete & Archive
op item delete "Old API Key" --vault Archive
op item delete "Deprecated Key" --archive
Share Items
op item share "Shared Secret" --vault Shared
op item share "Credentials" --emails "user1@example.com,user2@example.com"
op item share "One-time Password" --view-once
op item share "Temp Access" --expires-in 24h
Move Items
op item move "API Key" --from-vault Dev --to-vault Production
Document Operations
op document create ./config.json --title "Production Config" --vault Secrets
cat sensitive.log | op document create - --title "Debug Log" --file-name "debug.log"
op document get "Production Config" --vault Secrets --out-file ./config.json
op document list --vault Secrets
op document edit "Config" --title "New Title" --tags "config,production"
op document delete "Old Config" --vault Archive
Shell Plugins
Authenticate third-party CLIs securely through 1Password.
Available Plugins
op plugin list
Configure Plugin
op plugin init aws
op plugin init gh
op plugin inspect
op plugin clear aws
Using Plugins
aws s3 ls
gh repo list
kubectl get pods
op plugin run -- aws s3 ls
CI/CD Integration
GitHub Actions
name: Deploy
on: push
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install 1Password CLI
uses: 1password/install-cli-action@v1
- name: Load secrets and deploy
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
run: |
op run --env-file=.env.ci -- ./deploy.sh
GitLab CI
deploy:
image: 1password/op:2
variables:
OP_SERVICE_ACCOUNT_TOKEN: $OP_TOKEN
script:
- op run --env-file=.env.ci -- ./deploy.sh
Docker
# Use op to inject secrets at runtime
FROM 1password/op:2 AS secrets
COPY .env.tpl .
RUN --mount=type=secret,id=OP_SERVICE_ACCOUNT_TOKEN \
export OP_SERVICE_ACCOUNT_TOKEN=$(cat /run/secrets/OP_SERVICE_ACCOUNT_TOKEN) && \
op inject -i .env.tpl -o .env
FROM node:20
COPY --from=secrets .env .
Docker Compose
services:
app:
build: .
environment:
OP_SERVICE_ACCOUNT_TOKEN: ${OP_SERVICE_ACCOUNT_TOKEN}
command: op run --env-file=.env -- npm start
Item Categories
API Credential Bank Account Credit Card
Database Document Driver License
Email Account Identity Login
Membership Outdoor License Passport
Password Reward Program Secure Note
Server Social Security Software License
SSH Key Wireless Router
Get Category Template
op item template list
op item template get "API Credential" --format json
op item template get Login --out-file login-template.json
Account Management
op account add --address my-team.1password.com
op account list
op account get
op vault list --account work
op vault list --account personal
op account forget my-team.1password.com
Output Formats
op vault list
op vault list --format json
op item get "Database" --format json | jq -r '.fields[] | select(.label=="password") | .value'
op item list --iso-timestamps
Common Workflows
Local Development Setup
cat > .env.local << 'EOF'
DATABASE_URL="op://Dev/Postgres/connection-string"
REDIS_URL="op://Dev/Redis/url"
API_KEY="op://Dev/Internal API/key"
JWT_SECRET="op://Dev/Auth/jwt-secret"
EOF
op run --env-file=.env.local -- npm run dev
Rotate Credentials
op item edit "Service Account" --generate-password='letters,digits,symbols,64'
NEW_PASS=$(op read "op://Production/Service Account/password")
Backup/Export Secrets
op item list --vault Production --format json > vault-inventory.json
op item list --vault Production --format json | op item get - --format json > full-export.json
Audit Access
op user list
op group list
op vault user list --vault Production
op vault group list --vault Production
Troubleshooting
"You are not currently signed in"
op whoami
eval $(op signin)
export OP_SERVICE_ACCOUNT_TOKEN="ops_..."
"Item not found"
op vault list
op item list --vault "VaultName" | grep -i "item"
op item list --include-archive | grep -i "item"
"Permission denied"
op vault get "VaultName"
Desktop Integration Not Working
- Ensure 1Password app is running and unlocked
- Check Settings > Developer > "Integrate with 1Password CLI"
- Restart terminal after enabling
- Check app and CLI versions are compatible
Rate Limiting
op service-account ratelimit
op item list --cache
Security Best Practices
- Use
op run over export - Secrets only exist during command execution
- Service accounts for CI/CD - Never use personal credentials in automation
- Minimal vault access - Service accounts should only access required vaults
- Rotate tokens regularly - Set expiration on service account tokens
- Never log secrets - Keep
op run masking enabled
- Use secret references - Store references in config, not actual secrets
- Audit access regularly - Review service account usage and permissions
- Separate environments - Use different vaults for dev/staging/production
Quick Reference
| Task | Command |
|---|
| Check auth status | op whoami |
| List vaults | op vault list |
| List items | op item list --vault X |
| Read secret | op read "op://vault/item/field" |
| Get item | op item get "Name" --vault X |
| Get OTP | op item get "Name" --otp |
| Run with secrets | op run --env-file=.env -- cmd |
| Inject into config | op inject -i template.tpl -o config |
| Create item | op item create --category X --title Y |
| Generate password | op item edit "X" --generate-password |
| Share item | op item share "X" --expires-in 24h |
| Setup plugin | op plugin init aws |
| Create service account | op service-account create "name" --vault X:read_items |
Integration
This skill integrates with:
eng-security-safety - Threat modeling for secrets management
tools-docker - Container secrets injection
tools-github-actions - CI/CD pipeline secrets
tools-aws - AWS credential management via shell plugins