plugins/1pass/skills/op-exec/SKILL.md
Use this skill when the user asks about op-exec, running commands with 1Password secrets injected, wrapping processes with secret injection, automating secret-aware command execution, or configuring whole-item environment injection with multiple output targets. op-exec is a wrapper around the 1Password CLI that simplifies running commands with secrets from 1Password vaults.
npx skillsauth add nsheaps/ai-mktpl op-execInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
op-exec (from nsheaps/op-exec) is a
convenience wrapper around op run that simplifies injecting 1Password secrets
into command execution.
op-exec fetches all STRING and CONCEALED fields from a 1Password item, converts
field labels to environment variable names (UPPER_SNAKE_CASE), recursively
resolves any op:// references in field values (max depth 5), and either
exports them for a command or prints export statements for sourcing.
# mise.toml
[tools]
"github:nsheaps/op-exec" = "latest"
brew install nsheaps/tap/op-exec
curl -fsSL "https://github.com/nsheaps/op-exec/releases/download/v${VERSION}/op-exec-linux-amd64" -o op-exec
chmod +x op-exec
# Run a command with all fields from a 1Password item as env vars
op-exec op://vault/item -- command [args...]
# Print export statements (for sourcing or debugging)
op-exec op://vault/item
# Source into current shell
eval "$(op-exec op://vault/item)"
op) must be installed and authenticatedOP_SERVICE_ACCOUNT_TOKEN# All fields from the ENVIRONMENT item become env vars
# e.g. field "API Key" → API_KEY, field "Database URL" → DATABASE_URL
op-exec op://MyVault/ENVIRONMENT -- npm start
op-exec op://Development/my-app-config -- ./deploy.sh
op-exec op://Work/docker-secrets -- docker compose up
export OP_SERVICE_ACCOUNT_TOKEN="ops_..."
op-exec op://Automation/deploy-config -- ./ci-script.sh
Field values that are themselves op:// references are resolved automatically:
# Item "ENVIRONMENT" in vault "MyVault":
# API_KEY = op://MyVault/api-credentials/key ← resolved recursively
# DB_HOST = prod.db.example.com ← used as-is
The 1pass plugin can automatically run op-exec at session start and write
the resolved environment variables to multiple targets.
1pass:
installOpExec: true
opExecVersion: "latest"
opExec:
# 1Password items to expose as environment variables
items:
- "op://MyVault/ENVIRONMENT"
- "op://MyVault/extra-secrets"
# Where to write the resolved env vars (multiple allowed)
# Defaults to both targets when omitted.
targets:
- sessionStartBashEnv # → CLAUDE_ENV_FILE (session-scoped, bash only)
- envLocal # → $AGENT_HOME_DIR/.env.local (persistent, idempotent)
- userSettings # → ~/.claude/settings.local.json .env (persistent, all tools)
# envLocal target configuration (only consulted when "envLocal" is in targets above)
envLocal:
# path: '$AGENT_HOME_DIR/.env.local' # default
# sourceChain: '$AGENT_HOME_DIR/.env' # default; pass "self" to chain envLocal directly,
# or "none" (or "false") to skip adding any source line.
# Note: recursive resolution of op:// references is always on (op-exec built-in)
| Target | Mechanism | Scope | Persistence | Non-Bash tools |
| --------------------- | ------------------------------------------------------------------ | ----------------------------------------- | ---------------------------------------------- | ---------------------------------- |
| sessionStartBashEnv | CLAUDE_ENV_FILE | Bash tool calls | Session only | No |
| envLocal | $AGENT_HOME_DIR/.env.local (shell-sourceable export K=v lines) | All tools sourcing the file (e.g. direnv) | Across sessions (idempotent replace-or-append) | Yes — when sourced by the consumer |
| userSettings | ~/.claude/settings.local.json .env | All tools | Across sessions | Yes |
Default: Both sessionStartBashEnv and userSettings are enabled when
targets is not specified, ensuring env vars are available to all tools and
also in bash sessions. envLocal is opt-in.
export KEY=value lines to envLocal.path
(default $AGENT_HOME_DIR/.env.local, fallback $CLAUDE_PROJECT_DIR/.env.local).env_file_upsert_export). The file is NOT truncated on session start, so
vars from other sources (manual edits, other plugins) survive.source <envLocal.sourceChain> to
CLAUDE_ENV_FILE. Default sourceChain is $AGENT_HOME_DIR/.env (allowing a
repo-templated .env to source .env.local so direnv and other consumers
pick up the vars). Pass sourceChain: self to source the envLocal file
directly from CLAUDE_ENV_FILE, or sourceChain: none (alias: false) to
skip the source line entirely..gitignore'ing .env.local (and .env
if applicable) and for setting up the consumer-side source of the file..env that
sources .env.local for the consumer side.sessionStartBashEnv + userSettings (default): Most common —
ensures secrets are available everywhere during the session and to all
tool types. Add envLocal on top if you also want them in a sourceable
file on disk.When envLocal is included in opExec.targets, the plugin also registers a
Setup{init} hook that fires at session bootstrap, before the first
interactive SessionStart — specifically during the claude --init-only
pre-pass that the agent launcher runs on every startup. This ensures
$AGENT_HOME_DIR/.env.local is populated before the agent's Claude session
starts, so launchers can source it from the pre-session environment.
How it works:
claude --init-only; this triggers
the Setup{init} hook, which runs op-exec-env-setup.sh.opExec.items via op-exec and upserts each
resolved export KEY=value line into $AGENT_HOME_DIR/.env.local via
env_file_upsert_export (same semantics as the SessionStart sibling — no
wholesale replacement; non-1pass entries are preserved).SessionStart, op-exec-env.sh re-resolves and upserts
again (idempotent — values that haven't changed are no-ops).AGENT_HOME_DIR gating: If AGENT_HOME_DIR is not set in the hook
environment and no envLocal.path is configured, the Setup hook logs a notice
and exits cleanly. The SessionStart hook will write .env.local once
AGENT_HOME_DIR is available in the session env.
op / op-exec availability: If either binary is missing at Setup time (e.g. autoInstall has not yet run), the Setup hook exits cleanly. The SessionStart hook always runs the install step before the env-injection step, so the binaries will be available by the time SessionStart fires.
The ENVIRONMENT item in 1Password (e.g., op://AI-Jack/ENVIRONMENT) serves as the
canonical aggregator for all environment variables. Instead of adding separate items to
opExec.items, add new secrets as fields to the ENVIRONMENT item:
DISCORD_BOT_TOKEN)op:// reference pointing to the actual secret
(e.g., op://AI-Jack/discord--jack_oat_bot/token)This pattern means you only need one item in opExec.items (the ENVIRONMENT item) to
manage all secrets. Adding separate items should be avoided unless the secret doesn't
fit the aggregator pattern.
ENVIRONMENT item fields:
- TELEGRAM_BOT_TOKEN = op://AI-Jack/telegram-bot/token
- DISCORD_BOT_TOKEN = op://AI-Jack/discord--jack_oat_bot/token
- BRAINTRUST_API_KEY = op://AI-Jack/braintrust/api-key
When using the aggregator pattern, the plugin config is minimal — just one item:
1pass:
opExec:
items:
- "op://AI-Jack/ENVIRONMENT"
All env vars are managed by adding/removing fields on that single 1Password item, rather than editing plugin configuration.
Install via mise, Homebrew, or enable auto-install in the plugin settings.
Ensure op is authenticated:
op whoami
Ensure the service account or user has access to the referenced vault.
op-exec only exports STRING and CONCEALED field types. Other field types (sections, OTP, etc.) are skipped. Verify the item has the expected fields:
op item get "ENVIRONMENT" --vault "MyVault" --format json | jq '.fields[] | {label, type}'
tools
Reference material for Claude Code internals — the on-disk layout under ~/.claude and project-scope .claude, the plugin cache, session-env propagation, and the full hook lifecycle. Auto-recall when working on Claude-Code-related tasks: writing or debugging hooks, authoring plugins, inspecting session state, troubleshooting why an env var is or isn't visible to a Bash tool call, or when paths under ~/.claude or ~/.claude/plugins/ come up.
development
Manage GitHub App installation tokens in Claude Code sessions. Use when tokens expire, auth errors occur in long-running sessions, or when setting up GitHub App credentials for agent teams. <example>my github token expired</example> <example>refresh the github app token</example> <example>check token status</example> <example>set up github app authentication for this session</example>
tools
Auto-detect project formatting tools and configure edit-utils settings
tools
Use this skill when the user asks about 1Password, secrets management, retrieving credentials, using op CLI, service accounts, secret references, vault operations, or any task involving the 1Password CLI (op). Also use when needing to inject secrets into environment variables, read passwords or API keys from 1Password, or manage 1Password items from the command line.