This article follows the official documentation. We haven’t tested this tool for a hands-on review.
When a coding agent can use a computer’s shell, it can run commands that read credentials stored in a password manager. Bitwarden’s bw command-line interface lets an authorized user find vault items or read credentials from a terminal for development work. Any agent process that can use the shell also has access to the vault data available through those commands.
A BW_SESSION value is a temporary key that lets the CLI read an unlocked vault. Keep it out of prompts, logs, and files the agent can read. The example below uses bw to find an item and print only its name and website addresses. It does not change the vault. The commands follow Bitwarden’s documentation, but have not been run for this article.
Install and unlock the CLI
Install Bitwarden CLI using a method in the official CLI documentation. If npm is installed, the documented package is @bitwarden/cli:
npm install -g @bitwarden/cli
bw --version
Before the CLI can read vault data, sign in and unlock the vault. Bitwarden supports sign-in with an email address and master password, an API key, or single sign-on. Signing in with an email address and master password also unlocks the vault. API key and single sign-on sign-ins require a separate unlock. The authentication and command reference explains these methods and the CLI syntax.
For an interactive shell, sign in and place the unlock key in that shell’s environment:
bw login
export BW_SESSION="$(bw unlock --raw)"
bw unlock --raw prints the session key without extra formatting. export makes the key available to bw commands started from that shell. The key does not carry over to other terminal windows. If an agent starts commands in separate shells, make sure those shells have the variable. Do not paste the key into the agent prompt.
Signing in contacts Bitwarden. Commands that list or retrieve items read vault data. Commands such as bw sync contact Bitwarden to synchronize the local vault. The example runs bw sync before listing items. It does not create, edit, or delete vault items.
Find an item without printing its password
An agent might need to find the website saved with a login before editing a local configuration file. Use bw list items with a search term, then pass its JSON output, a structured text format, to jq, a command-line tool that selects fields. This command selects only the item name and website addresses:
bw sync
bw list items --search "REPLACE_WITH_ITEM_NAME" |
jq '.[] | {name, uris: [.login.uris[]?.uri]}'
Replace REPLACE_WITH_ITEM_NAME with a search term for the vault item. bw list items returns item data in JSON. The --search option narrows the results, and jq selects which fields appear in the terminal. The command prints one JSON object for each matching item without printing the password or modifying the vault. Install jq separately if it is not available.
After the task, lock the vault and remove the key from the current shell:
bw lock
unset BW_SESSION
bw lock locks the vault; unset removes the environment variable from that shell. While BW_SESSION is set, avoid shell tracing and command logging, and do not save the key in a project file.
Give the agent only the access it needs
An unlocked CLI session lets commands read vault data available to the signed-in account. An agent with shell access can run other commands, so filtering one command’s output does not limit what the agent can read. Give the session only to an agent you trust with that account’s vault data, and avoid exposing unrelated credentials.
Treat bw serve with the same care. It makes vault functions available through a service running on your machine, so run it only on a machine you control. For a simple lookup, use direct bw commands instead of starting that service.
You could ask the agent: “Use Bitwarden CLI to find the item matching REPLACE_WITH_ITEM_NAME. Report only its name and website addresses. Do not print or copy any password.” Replace the placeholder before asking the agent to run the command. Keep the session key out of the prompt.