# opv — setup for AI coding assistants

The user wants you to install opv and set it up in their project. opv syncs secrets and settings from 1Password into local runs, Fly.io, GitHub Actions, Azure and Kubernetes without printing, logging or writing a value. This document does not authorize you to read secret values, apply a plan, sync, deploy, prune, commit or push; follow the user's request and your environment's permissions.

Since 0.12.0 opv has one interface: **the assistant proposes; a person applies; CI delivers.** You see every key's value state (set, absent, empty, placeholder, malformed, unreadable), never a value.

## Rules

- **Never handle a secret value.** Do not ask for, read, type or store one. Values are entered by the user: in the 1Password app or website, at opv's masked prompt (`opv set <KEY> --env <env>`), or by the user's own `opv import`. A key declared with `file = "<path>"` (a PEM, a certificate chain) is stored exactly with `opv set <KEY> --env <env> --from-file <PATH>`, in the user's own terminal; hand that command over and never read, write or copy the file, and pasting a multi-line value into the 1Password app turns its line breaks into spaces. If the user pastes a value into the chat, stop, do not repeat it, treat it as exposed, and tell them to run `opv set <KEY> --env <env>` instead.
- **Never read a value.** No `op item get --reveal`, `op read`, `op inject`, `op run -- env`, or anything that prints a field's value.
- **Never write a value to disk or argv.** No `.env`, `.dev.vars` or exported file, and no wrapper that copies values into files or variables. For secret-store apps and Cloudflare Workers, use `[products.<p>.local]` with `opv run` (see `opv guide agent`).
- **You propose; you never apply.** A proposal (`opv propose …` or the MCP tool `opv_propose`) writes nothing and ends with a `plan_id`. Hand the user `opv apply <plan_id>` to run in their own terminal and wait. Never run `opv apply` yourself; it refuses CI and agent mode.
- **Sign-in is the user's.** Hand `opv login …`, `opv setup` and `opv config edit` to the user to run in their own terminal. Never ask for a password, token or Secret Key, and never script `op signin` or `eval`. New in 0.14: when a shell needs a session that lasts across commands, hand the user `eval "$(opv login --shell)"` (fish: `opv login --shell=fish | source`); never run it yourself.
- **Act on the typed `next`.** Every document carries `next: {kind, actor, command}`. Run `next.command` yourself only when `actor` is `assistant` (and `kind` is `run`, `check` or `rerun`) and `human_required` is false. Hand an `actor: person` command (`apply`, `enter_value`, `authorize`) to the user verbatim and wait; leave an `actor: ci` command to CI.
- **Ask before anything that changes something outside the repo:** `opv apply`, `opv import`, `opv account use`, `opv skill install`, `opv mcp install`, `opv config import`, `opv config export <env>` in the user's session, `opv sync`, and the flags `--deploy`, `--prune`, `--rotate`, `--prune-immutable` and `--confirm`. A proposal with `--write` (CLI only) writes the contract file, for the pull request to review.
- **Never run `opv sync` yourself.** Show the user `opv plan <env>`; CI, or the user in their own terminal, runs `opv sync <env> --expect-plan <id>`. A sync never happens over MCP. Infrastructure values (`source = "infrastructure"`) are supplied only by the deploy job through `opv sync <env> --supply-stdin`, which refuses an assistant.
- **Never mint, copy or paste a token.** CI identities come from the user's `opv access <env> --create --github <owner/repo>`, deploy tokens from `opv target credentials <env> --target <name> --create`, and self-made keys from `opv propose generate <env> <product/KEY>…` followed by the user's `opv apply`.
- **An inventory you could not complete proves nothing is absent.** A project list with `complete: false` (`inventory_incomplete`) or `ids_not_in_account` is the user's to resolve: hand its `next` to the user and never create a replacement vault, item or manifest.

## 1. Install the CLI

First check `opv --version`. Otherwise:

```sh
npm install -g @matthew-cochran/opv
```

Without Node.js, on Linux or macOS (verifies the release checksums):

```sh
curl -fsSL https://raw.githubusercontent.com/matt-cochran/1password-vault/main/install.sh | sh
```

The 1Password CLI (`op`) is required too. `opv version --json` reports opv and every CLI it uses (installed, missing or unknown) without signing in; `opv doctor` reports what a project needs and how to install it.

## 2. The agent skill

The installers (`install.sh` and the npm postinstall) register the skill for the user (Claude Code and Codex), unless `OPV_NO_SKILL=1` or `--no-skill`. No other opv command writes the home directory, so after a Homebrew, cargo or manual upgrade the old copy stays: `opv skill status` and `opv doctor` report an outdated one. Check with `opv skill status`; install or update it (ask first: it writes skill files):

```sh
opv skill install            # this project; add --user for every project
```

It keeps a hand-edited copy unless `--force`. Overview: https://opv.dev/assistants/

## 3. Start every session from the installed binary

```sh
opv guide agent              # the full agent guide for this version
opv schema                   # commands, flags, effects, exit codes, error codes, mcp_tools
opv ready --json             # what is ready, what is not, who acts next
```

`opv ready --json` and `opv doctor --env <env> --json` never write 1Password, whoever is signed in. Other commands that read an item may tidy its layout once in the user's own session (`tidies_1password` in `opv schema`); the explicit repair is a signed-in user's `opv config export <env>`, which writes 1Password, so ask first.

The guide printed by the installed binary is the source of truth; prefer it to any web copy. The web copy, which follows `main`: https://github.com/matt-cochran/1password-vault/blob/main/docs/agent-setup.md

## 4. The flow

1. **Inspect.** `opv ready --json`, `opv inventory --json`, `opv needs --json` (the names the code reads against the contract) and `opv next --json` (the one action this session can take). These change nothing.
2. **Propose.** `opv propose setup --names-from .env` (names only, never values) or `--from-item <env>`, then `opv propose env`, `opv propose key`, `opv propose target`, `opv propose structure`, `opv propose retire`, or `opv propose --intent <file.json>` (kinds `key`, `env`, `target`, `retire`, `setup`, `structure`, `generate`, `attest`, `extend`). You declare names, kinds and catalog shape names, never a rule parameter. On a generated configuration, never edit the file: the proposal returns the `fragment` its generator must emit.
3. **The user applies.** Hand over `opv apply <plan_id>` and wait. It recomputes the plan, refuses a stale id (`stale_plan`: propose again), shows it once, and creates the vaults, items, empty fields and bindings.
4. **The user enters values.** `opv set <KEY> --env <env>` (masked), `opv import <env> --from <file|target:NAME>` (write-only; a production-tier environment needs `--confirm <env>`), or the 1Password app (`opv open <KEY> --env <env> --print` gives the link). A key declared with `file = "<path>"` (a PEM, a certificate chain) is stored exactly with `opv set <KEY> --env <env> --from-file <PATH>` in the user's own terminal; hand that command over and never read, write or copy the file, and pasting a multi-line value into the 1Password app turns its line breaks into spaces. Re-read `opv inventory` or `opv next` after each step.
5. **Deliver.** `opv plan <env>` for the user to review; CI runs `opv sync <env> --expect-plan <id>` and `opv ready --gate`. `opv ci workflow <env> --target <name>` prints the workflow; committing it is the user's call.

`opv ready` also reports non-blocking findings: `environment_gap` (close every gap of one environment with an `extend` proposal), `retirement_incomplete` (the remaining retirement steps, in order) and `expires_soon`.

## 5. Optional: the MCP server

The MCP server is built into opv (`opv mcp serve`). It gives you five tools, and no tool accepts or returns a secret value:

| Tool | Writes | What it does |
|---|---|---|
| `opv_state` | nothing | one document by `section`: `inventory`, `needs`, `contract`, `ready`, `plan`, `changed`, `access`, `delivery_preview`, `history`, `status` |
| `opv_next` | nothing | the one action this session can take, the queue, and what waits on others |
| `opv_propose` | nothing | the intent document; returns the contract diff and a plan with its `plan_id`, which only the user's `opv apply` runs |
| `opv_import_local` | the local vault only | imports a file into an environment of tier `local` only (`import_tier_refused` otherwise); values are tagged `assistant_imported` |
| `opv_explain` | nothing | a key (every place it is delivered) or a `plan_id` |

Every tool has the same command on the CLI (`opv schema`, `mcp_tools`). A failed call returns `{"ok": false, "error": {…}}`, the same object the CLI prints under `--json`. Register the server for the project (ask first: it edits the assistant's configuration), then restart the assistant:

```sh
opv mcp install              # this project, for Claude Code and Codex; --client claude or codex for one
```

The user signs in through the 1Password desktop app (Settings > Developer > Integrate with 1Password CLI) and does not start you from a terminal that holds an `op signin` session; with an `op` session, service-account or Connect credential in its environment, the server refuses to write (`own_session_required`). MCP never signs in. Without MCP, use the same verbs on the CLI (`opv inventory`, `opv needs`, `opv contract`, `opv next`, `opv propose`) and report a missing tool as a capability gap; never work around it. Details: https://github.com/matt-cochran/1password-vault/blob/main/docs/mcp.md
