$npx -y skills add AlexAI-MCP/hermes-CCC --skill one-password1Password CLI integration — retrieve secrets, manage vaults, inject credentials into scripts without hardcoding.
| 1 | # 1Password CLI |
| 2 | |
| 3 | Retrieve secrets and manage credentials from 1Password without hardcoding them in scripts or environment files. |
| 4 | |
| 5 | ## Setup |
| 6 | |
| 7 | ```bash |
| 8 | # Install 1Password CLI (op) |
| 9 | # macOS |
| 10 | brew install 1password-cli |
| 11 | |
| 12 | # Linux |
| 13 | curl -sS https://downloads.1password.com/linux/keys/1password.asc | gpg --import |
| 14 | # See: developer.1password.com/docs/cli/get-started |
| 15 | |
| 16 | # Windows |
| 17 | winget install AgileBits.1Password.CLI |
| 18 | |
| 19 | # Verify |
| 20 | op --version |
| 21 | ``` |
| 22 | |
| 23 | ## Authentication |
| 24 | |
| 25 | ```bash |
| 26 | # Sign in (opens browser or prompts) |
| 27 | op signin |
| 28 | |
| 29 | # Or with service account (CI/CD) |
| 30 | export OP_SERVICE_ACCOUNT_TOKEN="eyJhbGci..." |
| 31 | |
| 32 | # Check auth |
| 33 | op whoami |
| 34 | ``` |
| 35 | |
| 36 | --- |
| 37 | |
| 38 | ## Read Secrets |
| 39 | |
| 40 | ```bash |
| 41 | # Read a field from an item |
| 42 | op item get "AWS Credentials" --field "access key id" |
| 43 | op item get "GitHub Token" --field password |
| 44 | |
| 45 | # Read by item ID |
| 46 | op item get "abc123xyz" --field password |
| 47 | |
| 48 | # Read as env var format |
| 49 | op item get "AWS Credentials" --format json |
| 50 | ``` |
| 51 | |
| 52 | --- |
| 53 | |
| 54 | ## Inject into Environment |
| 55 | |
| 56 | ```bash |
| 57 | # op run: inject secrets into any command |
| 58 | op run --env-file=".env.1password" -- python my_script.py |
| 59 | |
| 60 | # .env.1password format: |
| 61 | # AWS_ACCESS_KEY_ID=op://Private/AWS Credentials/access key id |
| 62 | # AWS_SECRET_ACCESS_KEY=op://Private/AWS Credentials/secret access key |
| 63 | # DATABASE_URL=op://Work/Production DB/connection string |
| 64 | ``` |
| 65 | |
| 66 | --- |
| 67 | |
| 68 | ## Secret Reference Syntax |
| 69 | |
| 70 | ``` |
| 71 | op://VAULT/ITEM/FIELD |
| 72 | op://Private/GitHub/token |
| 73 | op://Work/AWS Production/access key id |
| 74 | ``` |
| 75 | |
| 76 | Use in .env.1password or in shell scripts: |
| 77 | |
| 78 | ```bash |
| 79 | export GITHUB_TOKEN=$(op item get "GitHub" --field token) |
| 80 | export DB_PASS=$(op item get "PostgreSQL Prod" --field password) |
| 81 | ``` |
| 82 | |
| 83 | --- |
| 84 | |
| 85 | ## In Python Scripts |
| 86 | |
| 87 | ```python |
| 88 | import subprocess |
| 89 | |
| 90 | def get_secret(vault, item, field): |
| 91 | result = subprocess.run( |
| 92 | ["op", "item", "get", item, "--vault", vault, "--field", field], |
| 93 | capture_output=True, text=True, check=True |
| 94 | ) |
| 95 | return result.stdout.strip() |
| 96 | |
| 97 | db_password = get_secret("Work", "PostgreSQL Prod", "password") |
| 98 | api_key = get_secret("Private", "OpenAI", "api key") |
| 99 | ``` |
| 100 | |
| 101 | --- |
| 102 | |
| 103 | ## List and Search |
| 104 | |
| 105 | ```bash |
| 106 | # List all vaults |
| 107 | op vault list |
| 108 | |
| 109 | # List items in vault |
| 110 | op item list --vault Private |
| 111 | |
| 112 | # Search |
| 113 | op item list --categories Login --tags production |
| 114 | ``` |
| 115 | |
| 116 | --- |
| 117 | |
| 118 | ## Create Items |
| 119 | |
| 120 | ```bash |
| 121 | # Create a login |
| 122 | op item create \ |
| 123 | --category Login \ |
| 124 | --title "My Service" \ |
| 125 | --vault Work \ |
| 126 | username="admin" \ |
| 127 | password="$(openssl rand -base64 32)" |
| 128 | |
| 129 | # Create an API credential |
| 130 | op item create \ |
| 131 | --category "API Credential" \ |
| 132 | --title "OpenAI" \ |
| 133 | credential="sk-..." |
| 134 | ``` |
| 135 | |
| 136 | --- |
| 137 | |
| 138 | ## CI/CD Integration |
| 139 | |
| 140 | ```yaml |
| 141 | # GitHub Actions |
| 142 | - name: Configure 1Password |
| 143 | uses: 1password/load-secrets-action@v2 |
| 144 | with: |
| 145 | export-env: true |
| 146 | env: |
| 147 | OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} |
| 148 | AWS_ACCESS_KEY_ID: op://CI/AWS/access-key-id |
| 149 | AWS_SECRET_ACCESS_KEY: op://CI/AWS/secret-access-key |
| 150 | ``` |
| 151 | |
| 152 | --- |
| 153 | |
| 154 | ## SSH Key Management |
| 155 | |
| 156 | ```bash |
| 157 | # 1Password SSH Agent (stores SSH keys in 1Password) |
| 158 | # Enable in 1Password Settings → Developer → SSH Agent |
| 159 | |
| 160 | # Use in ~/.ssh/config: |
| 161 | Host github.com |
| 162 | IdentityAgent "~/Library/Group Containers/.../agent.sock" |
| 163 | |
| 164 | # List SSH keys |
| 165 | op item list --categories "SSH Key" |
| 166 | ``` |
| 167 | |
| 168 | --- |
| 169 | |
| 170 | ## Why Use 1Password CLI |
| 171 | |
| 172 | - No secrets in `.env` files committed to git |
| 173 | - Rotate credentials without touching code |
| 174 | - Audit log of who accessed what |
| 175 | - Works offline (cached vault) |
| 176 | - Team sharing without exposing plaintext |