{"data":{"slug":"discovered-2cf0a943ec09bdc01fa4f569917a7a76d831fc30af3db760","title":"Op Secrets","summary":"Securely store and use secrets with 1Password in Claude Code without exposing them in the chat, transcript, or shell history. The tool provides `op-store` for saving secrets, `op-env` for injecting them into commands, and ensures secrets are never visible to Claude.","url":"https:\/\/skillshunter.net\/skills\/discovered-2cf0a943ec09bdc01fa4f569917a7a76d831fc30af3db760","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/discovered-2cf0a943ec09bdc01fa4f569917a7a76d831fc30af3db760","markdown_url":"https:\/\/skillshunter.net\/skills\/discovered-2cf0a943ec09bdc01fa4f569917a7a76d831fc30af3db760.md","download_url":"https:\/\/skillshunter.net\/skills\/discovered-2cf0a943ec09bdc01fa4f569917a7a76d831fc30af3db760\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Before using `op-store` or `op-env`, ensure the 1Password CLI (`op`) is installed and configured with the 1Password app or a service-account token. Run `op-env --check` first to verify setup and resolve any connection issues.","instructions":"---\nname: op-secrets\ndescription: >\n  Use 1Password with Claude Code without secrets ever entering the chat, the transcript, the\n  command line or shell history. Use when the user wants to store an API key, token, password\n  or credential; when a tool, MCP server, hook or script needs a secret; when the user mentions\n  1Password, `op`, `op:\/\/`, secret references, .env files with secrets, \"where does the key go\",\n  or asks how to launch Claude Code with secrets loaded. Provides `op-store` (native hidden\n  dialog with an eye\/reveal toggle, straight into 1Password), `op-env` (launch any command with\n  secrets injected, TTY preserved, one biometric prompt) and `secret-dialog`. Not for other\n  password managers.\nversion: \"0.7.3\"\nmetadata:\n  author: Lucas Saldanha Werneck <lucas@2olhares.com>\n  tags: [1password, secrets, security, op, credentials]\n---\n\n# 1Password for Claude Code\n\n## Purpose\n\nKeep secrets out of the chat, the transcript, the command line and shell history: store them in\n1Password through a dialog Claude cannot see (`op-store`), and load them as environment variables\nfor a session or command (`op-env`). Only `op:\/\/` references and variable names pass through Claude.\n\n## Instructions\n\n1. Never ask for a secret in the chat. To store one, run `op-store <title>`; a native dialog opens and only the `op:\/\/` reference comes back.\n2. If a tool needs the secret as an environment variable, append `VAR_NAME=op:\/\/...` to `~\/.claude\/.env.tpl`.\n3. Tell the user to start Claude Code with `op-env claude`, so the variables are loaded with one biometric prompt.\n4. Use `$VAR_NAME` in commands; never print values, never `op read` inside every Bash call.\n5. When anything fails, run `op-env --check` first, then see Troubleshooting below.\n\n## The one rule\n\n**Never ask the user to paste a secret into the chat.** Anything typed in the chat or shown in a\ntool result is in the transcript forever. Instead run `op-store <title>`: a native dialog opens\noutside Claude's view, the user pastes there, the value goes straight into 1Password, and only the\n`op:\/\/` reference comes back.\n\nAlso never: print a secret value, `op read` inside every Bash call (biometric prompt fatigue),\n`source <(op run ... env)` or `eval` (values with shell metacharacters execute as code),\n`bash -x` any script that handles a value (the trace prints it).\n\n## The guard hooks back this up\n\nWhen installed as a plugin, `hooks\/guard.py` catches the common mistakes: secrets pasted by the\nuser (erased before you see them), `op read` \/ `op item get` \/ `op run` \/ `printenv` \/ `echo $TOKEN`\n\/ reading `.env*` or credential files (Bash, Read, Grep) \/ `op item create ...=value`, literal\nsecrets in Write\/Edit, and any final message of yours that asks the user to paste a secret.\nIf a hook blocks you, do what its message says: run `op-store <title>` and use the `op:\/\/`\nreference or `$VAR`. Do not look for a way around it, and do not call `secret-dialog` yourself:\nits output is the secret.\n\n## Commands (installed by `install.sh` into `~\/.local\/bin`)\n\n| Command | What it does |\n|---|---|\n| `op-store <title>` | Opens the native dialog (hidden field + eye). Saves an *API Credential* item, field `credential`, in vault `Claude`. Prints `OK op:\/\/Claude\/<title>\/credential`. Single-line values only. |\n| `op-store --login <title> [--url URL]` | Asks username (visible) then password (hidden). Saves a *Login* item. |\n| `op-store --update <title>` | Replaces the value of an existing item. |\n| `op-store --vault V --field F <title>` | Other vault \/ field name. |\n| `op-env <command>` | Resolves every `op:\/\/` line of `~\/.claude\/.env.tpl` in ONE `op` call, exports them, then `exec`s the command. TTY preserved. Use `op-env claude` to start Claude Code. |\n| `op-env --check` | Shows op version, template, account, and how many keys resolve. Run this first when anything fails. |\n| `op-env --list` | Key names only, never values. |\n| `op-env --meta \"<item>\" [vault]` | Title, vault, version, created\/updated dates and field NAMES of one item (never values). Use it to see whether an edit in the app reached 1Password. |\n\n## Workflows\n\n**User wants to store a secret** (key, token, password):\n1. Choose a short item title (e.g. `Apify`, `GitHub PAT`, `UniFi`).\n2. Run `op-store <title>` (or `--login` for user+password). Tell the user a dialog opened and to paste there.\n3. On `OK op:\/\/...`, append `VAR_NAME=op:\/\/...` to `~\/.claude\/.env.tpl` if a tool needs it as an env var.\n4. Tell the user to restart Claude Code with `op-env claude` so the new variable is loaded.\n   Never verify by printing the value; `op-store` already confirmed the field exists.\n\n**A tool \/ script \/ hook needs a secret** and Claude was started with `op-env`:\nthe variable is already in the environment. Use `$VAR_NAME` in the command. Do not `op read` again.\nIf the variable is missing, check `op-env --list`, then ask the user to add it with `op-store`\nand restart with `op-env claude`.\n\n**MCP server needs a token** (`.mcp.json`): use `${VAR_NAME}` expansion, inherited from `op-env`:\n```json\n{ \"mcpServers\": { \"x\": { \"command\": \"npx\", \"args\": [\"-y\", \"x-mcp\"], \"env\": { \"X_TOKEN\": \"${X_TOKEN}\" } } } }\n```\nHTTP servers with a bearer header: `claude mcp add-json` with a `headersHelper` that runs\n`op read` once at connect time (see README).\n\n**One-off value outside a session**: `op read \"op:\/\/Claude\/Item\/credential\"` \u2014 fine in the\nuser's own terminal, avoid inside Claude's Bash tool (each call is a new shell \u2192 new prompt).\n\n## Prerequisites\n\n- The 1Password CLI (`op`) and either the 1Password app with \"Integrate with 1Password CLI\" on, or a service-account token (`OP_SERVICE_ACCOUNT_TOKEN`).\n- `op-store`, `op-env` and `secret-dialog` installed by `install.sh` into `~\/.local\/bin`; the guard hooks need `python3` and the plugin install.\n\n## Setup check (run before the first use)\n\n```bash\nop-env --check\n```\n- `op not found` \u2192 macOS `brew install --cask 1password-cli`; other OS: https:\/\/developer.1password.com\/docs\/cli\/get-started\/\n- `NOT connected` \u2192 1Password app > Settings > Developer > \"Integrate with 1Password CLI\"\n  (Touch ID \/ Windows Hello \/ PolKit). Or export `OP_SERVICE_ACCOUNT_TOKEN` (no app needed, scoped to chosen vaults).\n- `resolved: N of M` with N < M \u2192 a reference in the template is wrong (vault\/item\/field name).\n\n## Security model (tell the user when relevant)\n\n- With the desktop-app integration, `op` can read **every vault** of the account while the app is\n  unlocked, not only `Claude`. The vault is organisation, not isolation. For real isolation use a\n  **service account** scoped to one vault (`op service-account create name --vault Claude:read_items,write_items`;\n  `write_items` is needed for `op-store`) and turn the app integration off. `op-env` removes\n  `OP_SERVICE_ACCOUNT_TOKEN` from the launched session on purpose (`OP_ENV_KEEP_SA=1` keeps it).\n- Injected env vars protect the disk and the transcript. Every subprocess, hook and stdio MCP server\n  started by Claude Code inherits **all** of them, and a process can still `printenv`. Do not print\n  environments; do not run `env`\/`printenv`\/`set` without filtering.\n- `op:\/\/` references reveal vault, item and field *names*. Keep them non-sensitive.\n- Claude Code's own login token lives in the OS keychain and is readable by same-user processes\n  (reported by Silverfort, 2026-07). Unrelated to 1Password; nothing here changes it.\n\n## Limitations\n\n- `op-store` saves single-line values only.\n- With the desktop-app integration, `op` can read every vault of the account; only a service account scoped to one vault isolates it.\n- Every subprocess started by Claude Code inherits the injected variables. The guard hooks are a text filter, not a sandbox.\n- Windows and Linux dialog backends are not yet verified by the author.\n\n## Troubleshooting\n\n- Claude starts in `--print` mode \/ \"No terminal detected\": you used `op run -- claude`. Use `op-env claude`.\n- `op whoami` says \"account is not signed in\" but everything works: known with app integration; ignore.\n- Repeated biometric prompts: something calls `op` per command. Move the secret to the template and use `op-env`.\n- macOS 26: \"\u00abiTerm\/Terminal\u00bb would like to access data from other apps\" pops up again and again, even after Allow:\n  `op` talks to the desktop app through a socket inside 1Password's group container, and macOS keeps that\n  answer only for the current terminal session and program. Fix: System Settings \u2192 Privacy & Security \u2192\n  Full Disk Access \u2192 add the terminal app, restart it. `op-env --check` prints a `macOS:` line while this is missing.\n- `op-env` loads 0 keys and `op-env --check` says \"More than one item matches\": two items share a title.\n  Delete the duplicate in 1Password, or reference the item by ID in the template: `VAR=op:\/\/Vault\/<item id>\/field`\n  (the IDs are in that same error message).\n- MCP server fails after `\/mcp` reconnect: reconnect spawns non-interactively, `op` cannot prompt. Prefer `${VAR}` from `op-env`.\n- Dialog never appears (macOS): the binary `secret-dialog-macos` is missing \u2192 run `install.sh` (needs `swiftc`); falls back to AppleScript (no eye).\n- Linux: KDE uses `kdialog --password` (eye built in, KDE Frameworks \u2265 5.84); GNOME uses GTK4 `Gtk.PasswordEntry` via `python3-gi`; else `zenity` (no eye); else `read -s` in a TTY.\n- Windows: PowerShell + WinForms dialog. Claude Code runs in Git Bash; the scripts run there.\n  Windows and Linux backends are not yet verified by the author.\n\n## Examples\n\n- \"Store my Apify key\": run `op-store Apify`, tell the user a dialog opened and to paste there; it prints\n  `OK op:\/\/Claude\/Apify\/credential`. Then append `APIFY_TOKEN=op:\/\/Claude\/Apify\/credential` to `~\/.claude\/.env.tpl`\n  and tell the user to restart with `op-env claude`.\n- \"How do I start Claude Code with my secrets loaded?\": `op-env claude` (any command works: `op-env .\/deploy.sh`).\n- \"Where do I put my key?\": not in the chat; use `op-store <title>`, then the `op:\/\/` reference in `.env.tpl`.\n- \"Secrets are not loading\": run `op-env --check`; `resolved: N of M` with N < M means a reference in the template is wrong.\n","use_cases":["Storing API keys, tokens, or passwords securely in 1Password for use with Claude Code","Injecting secrets into environment variables for tools or scripts that require them","Launching Claude Code with preloaded secrets using `op-env`","Verifying 1Password CLI setup and connection status with `op-env --check`"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/lucas-saldanha-werneck\/op-secrets\/blob\/ff42dd004f0177f4d10e551e7399d073b8e650b4\/skills\/op-secrets\/SKILL.md","source_commit":"ff42dd004f0177f4d10e551e7399d073b8e650b4","license":null,"version":null,"listing_approved_at":"2026-12-01","created_at":"2026-11-30T08:07:08.000000Z","updated_at":"2026-12-01T12:48:20.000000Z","seo_title":"Securely Manage Secrets with 1Password in Claude Code","seo_description":"Use Op Secrets to store and access sensitive information like API keys and passwords securely with 1Password in Claude Code, ensuring they never appear in chat, logs, or\u58f3","seo_keywords":["1Password","secrets management","Claude Code","secure API keys","op-store","op-env","secret injection","secure credential handling"]}}