Configure for Code
In short: install the 1Password app and the op CLI, turn on Settings → Developer, then either
call op for a vault item or ask Cursor to manage an Environment. Cursor can see variable names.
Secret values stay in 1Password.
Overview
What: this guide gets 1Password ready for code. You install the desktop app and the CLI, turn on the developer switches, then read and write secrets in two places:
| Store | What it is | Read | Write |
|---|---|---|---|
| Vault item | One login, password, or API credential in a vault | op read and op item get |
op item create and op item edit |
| Environment | A named set of variables for one project or stage, such as dev |
op environment secret list, op run --environment, or a mounted .env file |
The 1Password app, or Cursor. The CLI has no write command for Environments. |
The switches live on Settings → Developer in the desktop app: Integrate with 1Password CLI and Integrate with MCP clients.
Why: a .env file full of real keys gets copied, committed, and pasted into chat. 1Password keeps
the values, and your app or a single command receives them only when you approve.
Who it’s for: developers who have a 1Password account and want secrets in the terminal or in Cursor. You don’t need to have used the CLI or an MCP server before. An MCP server is a small local program Cursor talks to. This one is built into the 1Password app.
You can stop after the CLI steps if you don’t use Cursor. Cursor’s Environment tools and local .env
mounts work on Mac and Linux. On Windows, use the CLI.
Prerequisites
| What | Details |
|---|---|
| 1Password account | A subscription. On a team account, an owner or admin may need to allow developer tools first. See Security. |
| Desktop app | 1Password for Linux, Mac, or Windows. Snap and Flatpak builds can’t unlock the CLI. |
| Linux extras | PolKit, and a PolKit authentication agent already running. Ubuntu desktop has both. |
| A vault you can edit | Your Private vault is enough for a first item. Use a project vault when a team shares the secret. |
| Cursor | Only for the Cursor steps. Install the 1Password Developer Tools plugin from the marketplace. |
sqlite3 |
Only for the Cursor plugin’s mount check. Pre-installed on Mac. On Ubuntu: sudo apt install sqlite3. |
The install steps below are for Debian and Ubuntu, which matches this team’s machines. Mac and Windows install commands are at the end of Step 1. After that, the sign-in and secret steps are the same.
Architecture
The app holds the secrets. The CLI and Cursor both ask the app, on your machine, before anything is
released. A mounted .env file is a pipe (a FIFO), not a file on disk. Your app reads it, you approve
once, and the value is handed to that read.
flowchart LR
classDef user fill:#CBD5E1,stroke:#475569,color:#060913
classDef app fill:#38BDF8,stroke:#0284C7,color:#000810
classDef cloud fill:#0B1121,stroke:#38BDF8,color:#E2E8F0
classDef data fill:#075985,stroke:#38BDF8,color:#F8FAFC
classDef secret fill:#F59E0B,stroke:#B45309,color:#1C1917
U([You]):::user -->|ask or run a command| C[Cursor or the terminal]:::app
C -->|name or secret reference| OP[1Password app]:::cloud
OP -->|stores| V{{Vault item or Environment}}:::secret
A[Your app]:::app -->|reads| M[(.env pipe)]:::data
V -.->|value after you approve| M
Figure 1: Cursor and the CLI talk to the 1Password app. The app fills a local pipe when your app reads it.
A secret reference is a pointer, safe to commit: op://<your-vault>/<your-item>/<field>. op run
swaps it for the real value inside one child process.
%%{init: {"theme": "base", "themeVariables": {"actorBkg": "#0B1121", "actorBorder": "#38BDF8", "actorTextColor": "#E2E8F0", "actorLineColor": "#718096", "signalColor": "#718096", "signalTextColor": "#718096", "textColor": "#718096", "loopTextColor": "#718096", "labelBoxBkgColor": "#38BDF8", "labelBoxBorderColor": "#0284C7", "labelTextColor": "#000810", "sequenceNumberColor": "#FFFFFF", "noteBkgColor": "#F59E0B", "noteBorderColor": "#B45309", "noteTextColor": "#1C1917"}}}%%
sequenceDiagram
autonumber
box rgba(148,163,184,0.15) Person
participant U as You
end
box rgba(56,189,248,0.15) Your app
participant T as Terminal
participant A as Your command
end
box rgba(148,163,184,0.06) Services you use
participant OP as 1Password app
end
U->>T: op run --env-file=.env.tpl -- node ...
T->>OP: Resolve op:// references
OP-->>U: Approve this request
U->>OP: Approves in the app
OP-->>T: Values for this process only
T->>A: Starts the command with those variables
A-->>U: API_KEY is set
Figure 2: op run resolves secret references for one command. The parent shell never receives the values.
Where you turn each part on:
flowchart TB
classDef user fill:#CBD5E1,stroke:#475569,color:#060913
classDef app fill:#38BDF8,stroke:#0284C7,color:#000810
classDef cloud fill:#0B1121,stroke:#38BDF8,color:#E2E8F0
classDef data fill:#075985,stroke:#38BDF8,color:#F8FAFC
classDef secret fill:#F59E0B,stroke:#B45309,color:#1C1917
classDef zone fill:transparent,stroke:#94A3B8,stroke-dasharray:4 3
subgraph App["1Password app"]
direction LR
Dev[Settings, Developer]:::cloud
Env{{Environment}}:::secret
Item{{Vault item}}:::secret
end
subgraph Editor["Cursor"]
direction LR
Plugin[1Password plugin]:::app
end
subgraph Machine["Your machine"]
direction LR
You([You]):::user
CLI[op CLI]:::app
Pipe[(.env pipe)]:::data
end
You -->|turns the toggles on| Dev
Dev -->|Integrate with CLI| CLI
Dev -->|Integrate with MCP clients| Plugin
Plugin -->|create, list, update| Env
CLI -->|create or edit| Item
CLI -->|op run| Env
Env -.->|mount| Pipe
class App,Editor,Machine zone
Figure 3: The two Developer toggles. The CLI writes vault items. Cursor writes Environments and mounts the pipe.
Step 1: Install the app and the CLI
On Debian or Ubuntu, the same repository ships the desktop app and the CLI.
-
Add 1Password’s package signing key:
Terminal window curl -sS https://downloads.1password.com/linux/keys/1password.asc \| sudo gpg --dearmor --output /usr/share/keyrings/1password-archive-keyring.gpg -
Add the repository.
dpkg --print-architecturepicks amd64 or arm64 for you:Terminal window echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/1password-archive-keyring.gpg] https://downloads.1password.com/linux/debian/$(dpkg --print-architecture) stable main" \| sudo tee /etc/apt/sources.list.d/1password.list -
Add the signature policy so apt can verify the packages:
Terminal window sudo mkdir -p /etc/debsig/policies/AC2D62742012EA22/curl -sS https://downloads.1password.com/linux/debian/debsig/1password.pol \| sudo tee /etc/debsig/policies/AC2D62742012EA22/1password.polsudo mkdir -p /usr/share/debsig/keyrings/AC2D62742012EA22curl -sS https://downloads.1password.com/linux/keys/1password.asc \| sudo gpg --dearmor --output /usr/share/debsig/keyrings/AC2D62742012EA22/debsig.gpg -
Install the app and the CLI:
Terminal window sudo apt update && sudo apt install 1password 1password-cli -
Open a new terminal and check the CLI:
Terminal window op --version
You should see a version number, and 1Password in your app menu.
On a Mac: install the app from 1password.com/downloads, then
brew install 1password-cli.
On Windows: install the app from the same downloads page, then winget install 1password-cli.
Continue at Step 2. Skip the Cursor mount steps. Use op run --environment instead.
Snap and Flatpak builds of the app can’t use system authentication, so they can’t unlock the CLI. Install the deb, rpm, or official Mac or Windows app.
Step 2: Turn on developer access and sign in
-
Open 1Password and sign in.
-
Select your account at the top of the sidebar.
-
On Linux, go to Settings → Security and turn on Unlock using system authentication. On a Mac, turn on Touch ID if you want to approve with your fingerprint. On Windows, turn on Windows Hello.
-
Go to Settings → Developer.
-
Select Integrate with 1Password CLI.
You should see the CLI row switched on. Leave Integrate with MCP clients off until Step 5.
-
In a terminal, list your vaults:
Terminal window op vault list -
Approve the system authentication prompt.
You should see your vault names, including Private. The app stays the thing that unlocks the CLI. You are not typing your Secret Key into the terminal.
If you have more than one account in the app, pick one:
op signinUse the arrow keys, then Enter. Later commands use that account until you run op signin again.
To pin one account, set OP_ACCOUNT to its sign-in address, such as my.1password.com.
If the command asks for your email, Secret Key, and account password, the CLI is signing in on its
own. Go back to Settings → Developer and turn Integrate with 1Password CLI on, unlock the
app, and run op vault list again.
Step 3: Read and write a vault item from the CLI
A vault item is the right place for a single credential: a login, an API token, a database password. You point at a field with a secret reference:
op://<your-vault>/<your-item>/<field>Names are case-insensitive. If a name contains a space, wrap the whole reference in quotes. Build the reference from the vault, item, and field names. You can also copy it from the item in the app.
Create an item
Preview first. --dry-run prints the item and writes nothing. --generate-password makes the password
inside 1Password, so the secret never appears in your shell history.
op item create --dry-run \ --category=login \ --title='<your-service>' \ --vault='<your-vault>' \ --generate-password=32,letters,digits \ 'username=someone@example.com'When the preview looks right, run the same command without --dry-run.
You should see the new item printed, with the password concealed. In the app, the item is in
<your-vault>.
To see every category name before you create something that isn’t a login:
op item template listRead it back
Print a field only when you mean to see it:
op read 'op://<your-vault>/<your-service>/username'You should see someone@example.com.
Prefer op run when a command needs the secret. Put references in a template file. This file is safe
to commit, because the values are pointers:
API_KEY=op://<your-vault>/<your-service>/passwordSave that as .env.tpl in your project, then:
op run --env-file=.env.tpl -- node -e "console.log(process.env.API_KEY ? 'API_KEY is set' : 'API_KEY is missing')"Approve the prompt. You should see API_KEY is set. The value is in that Node process only.
Your shell does not gain API_KEY.
About the code: the one-liner is plain Node.js. It doesn’t assume React, Next.js, or Vite.
In a real app, start it the same way: op run --env-file=.env.tpl -- npm run dev.
op inject is the other tool, and the syntax is different. It writes a file that contains the real
secret. Use it for a config file a program will only read from disk, then delete the result.
| Command | What you put in the file | What you get |
|---|---|---|
op run --env-file=.env.tpl -- <command> |
API_KEY=op://<your-vault>/<your-service>/password |
Variables in one child process. Nothing new on disk. |
op inject -i config.tpl -o config.yml |
password: {{ op://<your-vault>/<your-service>/password }} |
A file with the real value. Delete it when you finish. Don’t commit it. |
Change an item
Generate a new password without typing one:
op item edit '<your-service>' --vault '<your-vault>' \ --generate-password=32,letters,digits,symbolsTo store a value you already have, keep it out of the command line. Command arguments land in shell history and can be seen by other processes.
-
Export the item:
Terminal window op item get '<your-service>' --vault '<your-vault>' --format json > /tmp/item.json -
Edit the field in
/tmp/item.json. -
Apply it, then delete the file:
Terminal window op item edit '<your-service>' --vault '<your-vault>' --template=/tmp/item.jsonrm /tmp/item.json
Security: /tmp/item.json holds the secret in plaintext. Delete it in the same sitting.
Don’t commit it, and don’t put the secret in the chat.
Step 4: Create an Environment and load it from the CLI
An Environment is a set of variables for one app and one stage (dev, staging). Share that set
with your team instead of copying a .env file around.
- In the app, go to Developer → View Environments.
- Select New environment.
- Type a name, such as
<your-environment>, and select Save. - Open that Environment.
- Select New secret. Type the name (for example
API_KEY) and the value, then save. Or select Import .env file if you already have a plaintext.env.
You should see the variable name in the Environment. The value is hidden.
The CLI can list those names. Concealed values stay hidden unless you pass --reveal:
op environment secret list '<your-environment>'You should see API_KEY and a concealed value.
Load them into one command. The flag takes the Environment’s ID, not its name.
-
In the app, open the Environment.
-
Select Manage environment → Copy environment ID.
-
Run your command under
op run:Terminal window op run --environment <environment-id> -- node -e "console.log(process.env.API_KEY ? 'API_KEY is set' : 'API_KEY is missing')"
You should see API_KEY is set.
Add and edit Environment variables in the app (this step) or from Cursor (Step 5).
op environment can list secrets. It has no create or edit command.
Step 5: Read and write Environments from Cursor
Cursor’s 1Password Developer Tools plugin connects the agent to the app. The agent can create an
Environment, list variable names, add or update variables, and mount a .env file. The server does
not return secret values to the agent, even if you ask it to print them.
-
On Linux, install the tool the mount check uses:
Terminal window sudo apt install sqlite3sqlite3 --version -
In Cursor, open the Agents window.
-
In the left sidebar, select Customize.
-
Select Plugins.
-
Search for 1Password Developer Tools and select Add.
-
In the 1Password app, go to Settings → Developer and turn on Integrate with MCP clients.
-
Quit Cursor and open it again.
-
Go to Cursor Settings → Tools & MCPs.
You should see the 1Password server connected.
You can also install the plugin from the command palette: Ctrl+Shift+P (on a Mac, Cmd+Shift+P),
then Plugins: Install Plugin. Or, in the agent chat, run /add-plugin 1password.
Try it. In the agent chat, ask:
List my 1Password Environments.Approve the prompt in the 1Password app. You should get names, including <your-environment>.
Ask for the variables:
What variables are in my <your-environment> Environment?You should get names such as API_KEY, and no values. The first time the agent touches that
Environment, the app asks you to approve. Approval lasts until 1Password locks.
To add a variable, ask:
Add a variable named LOG_LEVEL to my <your-environment> Environment, with the value info.Approve in the app. Then look at the Environment. LOG_LEVEL should be there.
Security: don’t paste a live key into the chat. For a real secret, select New secret in the
app, or ask the agent to import a local .env and then delete that plaintext file. The chat keeps
what you typed. The 1Password prompt does not send the value back to the agent.
To import an existing file:
Import .env into my <your-environment> Environment.If that .env is tracked by git, delete it and commit the deletion before you mount anything over
the same path. Step 6 covers the mount.
On Windows the plugin’s mount check does nothing, and the MCP server is not available. Use Step 4
(op run --environment) there.
Step 6: Mount a local .env file
A mount lets your app keep reading .env while the bytes stay in 1Password. This works on Mac and
Linux only. You can have up to 25 enabled mounts on one device.
- If
.envis already committed, delete it and commit that deletion before you mount. Add.envto.gitignoreif it isn’t there. - Open the Environment in the app.
- Under Connect to, select Connect next to Local .env file.
- Select Choose file path and pick the project’s
.envpath. - Select Mount .env file.
Check that the path is a pipe, not a normal file:
test -p .env && echo 'mounted as a pipe'You should see mounted as a pipe.
When a program reads the file, the app asks you to approve. Approval lasts until 1Password locks.
cat .env works after you approve, and it prints every value onto the screen. Prefer the op run
check in Verify it works.
Vite watches .env and can restart forever, because a pipe fires file events on each read.
In vite.config.js, ignore that file. The same block belongs in vite.config.ts if you use TypeScript.
import { defineConfig } from 'vite'
export default defineConfig({ server: { watch: { ignored: ['**/.env'], }, },})The Cursor plugin checks these mounts before the agent runs a shell command. A normal .env file
still sitting on a mount path makes the agent stop and tell you. Fix the mount, or see
Troubleshooting.
Security
Security: the value belongs in 1Password. A secret reference (op://...) is safe in git.
The resolved file from op inject, a JSON item template, and anything you paste into chat are not.
- Secrets: store them as vault items or Environment variables. Commit
.env.tpl(references only). Gitignore.env,config.ymlafter inject, and/tmp/item.json. Delete those files when you’re done. - Least privilege: a personal trial fits in your Private vault. For a shared app, use a vault or an Environment that only that project can read. For CI and servers, use a service account limited to those vaults or Environments, instead of your own unlock. On a team account, an admin turns Environments on, and can allow or block Policies → Agentic permissions → Local MCP server and the CLI integration.
- Who can see a mount: after you approve a local
.envfile, every process on your machine can read it until 1Password locks. Lock the app when you step away. The same is true of environment variables: other processes running as you can read a process’s environment. - Rotate: after you import a plaintext
.env, rotate those keys. The old file may be in shell history, editor swap files, or an old commit. Generate a replacement withop item edit --generate-passwordor by editing the Environment, update the app that uses it, then revoke the old key at the provider. - Cursor: the agent receives variable names, not values. Don’t ask it to print a secret, and don’t type a live key into the chat. Type it in the app.
- Shell history:
op item createandop item editarguments are visible to other processes. Use--generate-passwordor a template file you delete. Don’t pass the secret as a flag.
Verify it works
- Run
op vault listand approve the prompt. You should see your vaults. - Run
op read 'op://<your-vault>/<your-service>/username'. You should seesomeone@example.com. - Run the
op run --env-file=.env.tplcommand from Step 3. You should seeAPI_KEY is set. - Run
op environment secret list '<your-environment>'. You should see the names, with values concealed. - In Cursor Settings → Tools & MCPs, the 1Password server shows as connected.
- Ask the agent:
What variables are in my <your-environment> Environment?You should get names only. - In the project, run
test -p .env && echo 'mounted as a pipe'. You should seemounted as a pipe.
Troubleshooting
| Problem or error | Likely cause | Fix |
|---|---|---|
command not found: op |
The CLI isn’t on your PATH, or this terminal was opened before install |
Open a new terminal and run op --version |
| Asked for your email, Secret Key, and account password | Integrate with 1Password CLI is off, so the CLI signs in by itself | Turn it on under Settings → Developer, unlock the app, run the command again |
| No approval prompt at all | The app is locked, or the command runs as a different user | Unlock the app. Run the command as the same Linux user. Confirm a PolKit agent is running |
op signin doesn’t list your account |
That account isn’t in the desktop app | Add the account in the app, then run op signin again |
| Integrate with 1Password CLI is missing or won’t stay on | An admin policy is blocking developer tools | Ask your 1Password admin to allow the CLI integration |
| Integrate with MCP clients is missing | The app is old, or an admin turned off the local MCP server | Update the app. Ask an admin to check Policies → Agentic permissions → Local MCP server |
MCP error -32000: Connection closed |
Cursor can’t start 1password-mcp |
Turn on Integrate with MCP clients and restart Cursor. On macOS, allow Cursor under System Settings → Privacy & Security → Files & Folders for the entry that starts with Data shared by 1Password |
Error: unknown flag: --environment |
The CLI is older than 2.41.0 | sudo apt update && sudo apt install 1password-cli, then open a new terminal |
| Cursor blocks a shell command and mentions environment files | A mount is missing, turned off, or a normal .env is still at that path |
Enable the mount, or move the plaintext file. To unblock while you fix it, put mount_paths = [] in .1password/environments.toml |
git status shows .env after a mount |
The old .env was tracked |
Delete it, commit that deletion, then mount again |
| Vite’s dev server restarts in a loop | Vite is watching the pipe | Ignore .env in server.watch.ignored (Step 6) |
test -p .env fails |
The path is a normal file, or the mount is disabled | Turn Enabled on for that destination. Move any real file aside first |
| Snap or Flatpak app never unlocks the CLI | Those builds can’t use system authentication | Install the deb, rpm, or official desktop app instead |
Cleanup or rollback
To undo this guide:
- In the Environment, turn Enabled off next to Local .env file. That removes the pipe.
- Delete the trial vault item in the app: open it, open its menu, and select Delete.
- Delete the trial Environment from Developer → View Environments if you don’t want to keep it.
- Under Settings → Developer, turn off Integrate with MCP clients and Integrate with 1Password CLI.
- In Cursor, open Customize → Plugins and remove 1Password Developer Tools.
- To uninstall on Ubuntu:
sudo apt remove 1password-cli 1password.
Locking or quitting the app stops the CLI and Cursor from reading secrets until you unlock it again. Your items stay in the account.
Dependencies
Other dev-docs guides:
None yet. This is the first 1Password guide.
External services:
- 1Password account, desktop app, and CLI
- Cursor, only for Steps 5 and 6
- Node.js, only for the
node -echecks. Any current Node.js is enough. Those checks don’t use a framework.
Versions
What this guide was checked against on 2026-11-22:
| Tool | Version | Notes |
|---|---|---|
| 1Password CLI | 2.41.0 or newer | op run --environment is in the stable CLI from 2.41.0. The get-started page’s sample op --version output still shows 2.31.1. Confirm with op --version. |
| 1Password desktop app | Current Mac, Windows, or Linux app | Settings → Developer and Environment steps checked against the developer docs. Local .env mounts and the MCP server need Mac or Linux. |
| Cursor | Current | 1Password Developer Tools plugin. Install path checked against the Cursor plugin doc. |
| sqlite3 | Any recent build | Used by the plugin’s mount check. Pre-installed on Mac. On Ubuntu, sudo apt install sqlite3. |
References
Checked on 2026-11-22:
- Get started with 1Password CLI — install, app integration,
op vault list - Sign in with the desktop app — Linux system authentication and failed sign-in
- Secret references —
op read,op run, andop inject - Secret reference syntax —
op://vault/item/field - Create and edit items —
op item create,op item edit,--dry-run,--generate-password - Load secrets into the environment —
op run --environmentand--env-file op environment—op environment secret list- 1Password Environments — create an Environment and add secrets
- Local .env files — mounts, git, and the Vite watcher
- Use Cursor with 1Password Environments — the plugin and Tools & MCPs
- 1Password Environments MCP server — what the agent can and cannot see
- Get the 1Password for Linux app — deb install, and why Snap and Flatpak don’t unlock the CLI
- Service accounts with the CLI — least privilege for CI