In this article
- 1Password CLI at a glance
- What the 1Password CLI is for
- How to install and sign in
- 1Password CLI examples
- op run vs op read vs op inject
- Shell Plugins: sign in to other CLIs with your fingerprint
- Service accounts for servers and CI
- Using the CLI with AI coding agents
- Common errors and fixes
- Walkthrough: move a project off a plain .env file
- How the CLI keeps secrets safe
- Which secret command should you use
- Security checklist before you automate
- Troubleshooting order that saves time
- Cost
- Pros and cons
- Latest information about 1Password
- 1Password CLI FAQs
- Final Verdict
Your API keys sit in a .env file. One wrong commit and they are public.
You already use 1Password for logins. It can guard your code secrets too.
This guide shows setup and real script examples.
Quick answer
The 1Password CLI is a tool named op. Install it, then turn on Integrate with 1Password CLI in the desktop app. Use op run to pass secrets as environment variables. Use op read for single values and op inject for config files. It is included with every 1Password plan.
Not a member yet? Start at our 1Password deals page.
1Password CLI at a glance
| Item | Details | Source |
|---|---|---|
| Command name | op | CLI reference |
| Platforms | Mac, Windows, Linux | Get started |
| Install on Mac | brew install 1password-cli | Get started |
| Sign in | Through the desktop app with Touch ID, Windows Hello or system auth | Get started |
| Headless use | Service account token scoped to vaults | Get started |
| Main secret commands | op run, op read, op inject | Load secrets |
| Command style | Noun then verb, like op item get | CLI reference |
| Cost | Included with 1Password plans | Pricing |

What the 1Password CLI is for
The CLI brings 1Password to your terminal. Its main job is keeping secrets out of code.
Instead of a plain .env file, you store keys in 1Password. Scripts fetch them at runtime.
- Load API keys into scripts without saving them to disk.
- Inject secrets into config files from a template.
- Authenticate other CLIs with your fingerprint through Shell Plugins.
- Manage items, vaults, users and groups from scripts.
- Run automated jobs with service accounts.
1Password lists CLI and SDKs on Individual and Families plans.
How to install and sign in
Step 1: Install the CLI
On Mac, Homebrew is the easiest route.
brew install 1password-cli
op --version
Windows and Linux have their own installers in the docs. The Homebrew cask is maintained by Homebrew and 1Password developers.
Step 2: Turn on the desktop app integration
- Open and unlock the 1Password app.
- Select your account at the top of the sidebar.
- Go to Settings, then Developer.
- Select Integrate with 1Password CLI.
- Turn on Touch ID or Windows Hello if you want biometric sign in.
Step 3: Run any command
You are prompted to authenticate. Try listing your vaults.
op vault list
Step 4: Pick an account
Have more than one account in the app? Use op signin and choose with the arrow keys.
That is it. The app integration is easier than typing a password in the terminal.
1Password CLI examples

Read one secret
Secret references look like op://vault/item/field. Use op read to fetch one.
docker login -u "$(op read op://prod/docker/username)" -p "$(op read op://prod/docker/password)"
The secret passes only to that one command. It never lands in your shell history as plain text.
Run an app with secrets as environment variables
Put secret references in your env file. Then wrap the command with op run.
# .env
DB_PASSWORD="op://dev/postgres/password"
op run --env-file=.env -- npm start
The CLI resolves each reference and runs the app in a subprocess. Secrets exist only while it runs.

Inject secrets into a config file
Write a template with references. Then let op inject fill it.
op inject -i config.yml.tpl -o config.yml
Delete the output file when done, or keep it out of Git.
Get an item field
op item get "GitHub" --fields password
Create a login with a generated password
op item create --category login --title "New Service" --generate-password
List items in a vault
op item list --vault Private
Command names follow a noun then verb pattern. So op vault list, op item get and so on.
op run vs op read vs op inject
| Command | Best for | Secret lifetime |
|---|---|---|
op run | Apps that read environment variables | Only while the process runs |
op read | One value in one command | Only for that command |
op inject | Tools that need a config file | Until you delete the file |
op plugin run | Third party CLIs via Shell Plugins | Handled by the plugin |
op run is the better default for most projects, and it suits AI agents too.
With op read, the value prints to output if you are careless. op run passes it straight to the process.
Shell Plugins: sign in to other CLIs with your fingerprint
Shell Plugins let 1Password handle auth for tools like cloud and Git CLIs.
Your tokens stay in 1Password. You approve each use with biometrics.

The docs list Bash and Zsh among supported shells. Check the Shell Plugins page for the full tool list.
Service accounts for servers and CI
The desktop app integration needs a person at the keyboard. Servers do not have one.
For that, 1Password recommends service accounts. Each token is scoped to specific vaults.
- Follow least privilege. Give each job only the vaults it needs.
- Use them when your own account has SSO or MFA rules.
- Store the token in your CI secret store, not in the repo.
- Rotate the token if it leaks.
The docs also mention a Credential Broker for short lived CI access. It is new, so check the docs before relying on it.
Using the CLI with AI coding agents
Many developers now give agents shell access. That makes plain .env files risky.
Developers increasingly pair coding agents with the CLI. A service account limited to one vault limits what the agent can see.
- Prefer
op runso secrets never print to the transcript. - Use a service account limited to one vault.
- Never let an agent run broad item list commands across all vaults.
- Review what the agent asks to access.
CLI access can reach every vault your account can reach, so scope matters.
Common errors and fixes
| Problem | Likely fix |
|---|---|
| Command asks for a password every time | Turn on the desktop app integration |
| Wrong account used | Run op signin and pick the account |
| Reference not found | Check vault, item and field names match exactly |
| Works locally, fails in CI | Use a service account token |
| Another app keeps requesting CLI access | Review app permissions in 1Password settings |
For anything else, see the troubleshooting links on the get started page.
Walkthrough: move a project off a plain .env file
Here is a full flow for an existing project.
Step 1: Create a vault for the project
Make a vault named after the project, like dev or prod. Keep it separate from personal logins.
Step 2: Save each secret as an item
Add one item per service. Use clear field names like password or api key.
Step 3: Replace values with references
In your env file, swap each value for its op:// reference. The file is now safe to share.
Step 4: Wrap your start command
Prefix your usual command with op run --env-file=.env --. Test that the app starts.
Step 5: Rotate the old secrets
The old values may live in Git history. Rotate them at each provider.
Step 6: Add CI
Create a service account for the vault. Store its token in your CI settings.
After this, nobody on the team needs plain secrets on disk.
New teammates just install the CLI and sign in. Their access follows their vault permissions.
How the CLI keeps secrets safe
The app integration means the CLI never stores your account password. You approve access with biometrics.
Approval lasts for your terminal session. Close it and access ends.
Secrets loaded by op run live only in the child process. They do not stay in your shell.
1Password publishes an app integration security page. Read it if you handle sensitive production keys.
Which secret command should you use
- Your app reads environment variables: use op run with an env file of secret references.
- You need one value inside a single command, such as a docker login: use op read.
- Your tool needs a real config file: use op inject, then delete the output file or keep it out of Git.
- You use a third party CLI that supports Shell Plugins: use op plugin run so the token stays in 1Password.
- A server or CI job needs access with nobody at the keyboard: use a service account token scoped to the vaults it needs.
When two options both work, pick the one where the secret lives for the shortest time. That is op run for long running apps and op read for one off commands. Files created by op inject last until you delete them, so treat them like any other plain text secret.
Security checklist before you automate
- Keep one vault per project so a script cannot reach personal logins.
- Give each service account only the vaults that job needs.
- Store service account tokens in your CI secret store, never in the repository.
- Rotate any secret that has lived in Git history or a plain env file.
- Prefer op run over op read when output might end up in logs or an agent transcript.
- Review which apps have requested CLI access in the 1Password settings.
None of these steps cost anything extra, because the CLI comes with your plan. They take a few minutes to set up and they remove the most common way secrets leak: a plain text file that nobody remembers to clean up.
Troubleshooting order that saves time
When a command fails, work through the same short list each time. First confirm the desktop app is unlocked and that Integrate with 1Password CLI is turned on. Second, run op vault list to prove sign in works. Third, check that the vault, item and field names in your secret reference match exactly, including capitalisation. Fourth, if it works on your laptop but fails in CI, switch to a service account token, because the desktop integration needs a person present. If an unrelated app keeps asking for CLI access, review its permissions and remove anything you do not recognise. Keeping that permission list short is a simple habit that protects every vault.
Cost
The CLI has no separate price. It comes with your 1Password plan.
| Plan | Promo price | Regular price |
|---|---|---|
| Individual | $2.99 a month | $3.99 a month |
| Families | $4.49 a month | $5.99 a month |
Team and business plans also include developer tools. See our 1Password pricing guide.
Open source projects may qualify for a free Teams account.
Pros and cons
| Pros | Cons |
|---|---|
| Secrets never sit in plain text | Needs the desktop app for biometric sign in |
| Biometric approval in the terminal | Service accounts add setup work |
| Works with any language or tool | Agents with broad access are risky |
| Included in every plan | Some apps over request access |
Latest information about 1Password
- 1Password for Agents. The company now pitches tools that let AI agents use access without seeing your passwords.
Watch: 1Password official video
Here is the CLI doing real work. 1Password’s video shows secrets loaded at runtime with the 1Password CLI and Environments, so keys never sit in plain text files.
1Password CLI FAQs
What is the 1Password CLI?
A command line tool named op. It brings 1Password to your terminal and scripts.
How do I install the 1Password CLI on Mac?
Run brew install 1password-cli, then check with op --version.
Is the 1Password CLI free?
It is included with 1Password plans. There is no separate fee.
How do I sign in to the CLI?
Turn on Integrate with 1Password CLI in the app under Settings, then Developer.
What is a secret reference?
A URI like op://vault/item/field that points to a stored secret.
What is the difference between op run and op read?
Op run passes secrets as environment variables to a process. op read fetches one value.
Can I use the CLI in CI pipelines?
Yes. Use a service account token scoped to the vaults you need.
Does the CLI work on Linux and Windows?
Yes. It runs on Mac, Windows and Linux.
Can the CLI create items?
Yes. Use op item create, with an option to generate a password.
Do secrets stay in my shell after op run?
No. They exist only in the child process while it runs.
Do I need the desktop app to use the CLI?
For biometric sign in, yes. Servers use service account tokens instead.
What are Shell Plugins?
They let 1Password authenticate other CLIs with your fingerprint.
Final Verdict
Start with op run and one env file. You will remove plain secrets from a project in minutes.
Then add a service account for CI. That covers most real workflows.
Disclosure: some links on this page are affiliate links. If you buy through them we may earn a commission, and your price stays the same.

