"
1Password CLI : Setup, Examples and op run Guide featured image

1Password CLI 2026: Setup, Examples and op run Guide

How to install the 1Password CLI, sign in with the desktop app, and use op run, op read and op inject with real examples.

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

ItemDetailsSource
Command nameopCLI reference
PlatformsMac, Windows, LinuxGet started
Install on Macbrew install 1password-cliGet started
Sign inThrough the desktop app with Touch ID, Windows Hello or system authGet started
Headless useService account token scoped to vaultsGet started
Main secret commandsop run, op read, op injectLoad secrets
Command styleNoun then verb, like op item getCLI reference
CostIncluded with 1Password plansPricing
1Password Developer docs page for getting started with 1Password CLI
Source: 1Password Developer docs.

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

1Password docs listing op run, op read, op inject and op plugin run methods
Source: 1Password Developer docs.

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.

1Password docs page on loading secrets into the environment with op run
Source: 1Password Developer docs.

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

CommandBest forSecret lifetime
op runApps that read environment variablesOnly while the process runs
op readOne value in one commandOnly for that command
op injectTools that need a config fileUntil you delete the file
op plugin runThird party CLIs via Shell PluginsHandled 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.

1Password Shell Plugins docs page for authenticating third party CLIs
Source: 1Password Developer docs.

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 run so 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

ProblemLikely fix
Command asks for a password every timeTurn on the desktop app integration
Wrong account usedRun op signin and pick the account
Reference not foundCheck vault, item and field names match exactly
Works locally, fails in CIUse a service account token
Another app keeps requesting CLI accessReview 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.

PlanPromo priceRegular 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

ProsCons
Secrets never sit in plain textNeeds the desktop app for biometric sign in
Biometric approval in the terminalService accounts add setup work
Works with any language or toolAgents with broad access are risky
Included in every planSome 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.

Roshan Jha

About the author: Roshan Jha

Roshan Jha researches password managers and credential vaults for families and small teams. On 1Pass.Coupons he documents first-year promos, plan limits and comparisons with other vaults. He helps households and small teams lock down every login without overpaying. Follow Roshan Jha on LinkedIn.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *