Source: https://keypaste.com/developers/cli/
Last updated: 2026-12-01

# CLI commands

`keypaste` is one command with a verb for each task. `keypaste <command> --help` prints every flag of a command, and `keypaste version` prints the version. The desktop app’s Settings › keypaste in a terminal puts it on your `PATH`, or [install it alone](https://keypaste.com/developers/install/).

Terminal window

```
keypaste <command> [flags]
```

## Secrets

| Command | Does | More |
| --- | --- | --- |
| `get` | Copies a secret to the clipboard, or prints it with `--reveal`. |  |
| `show` | Shows an item’s fields and tags; values only with `--reveal`. |  |
| `set` | Creates or updates a secret, or its custom fields. |  |
| `field` | Lists, renames or removes an item’s custom fields. |  |
| `attachment` | Lists, adds, replaces, removes or saves an item’s attachments. |  |
| `rotate` | Replaces a secret with a new generated one. It changes the vault, not the credential at its provider. |  |
| `run` | Runs a command with an environment’s variables. | [keypaste run](https://keypaste.com/developers/run/) |
| `env` | Imports, exports and compares an environment’s stages: `ls`, `set`, `rm`, `pull`, `export`, `diff`, `tag` and `untag`. | [keypaste env](https://keypaste.com/developers/env/) |
| `hook` | Prints the line that loads a folder’s environment into your terminal as you enter it. | [keypaste hook](https://keypaste.com/developers/hook/) |
| `stage` | Switches the stage the hook loads in this terminal. | [keypaste hook](https://keypaste.com/developers/hook/#switch-the-stage) |

## Agents

| Command | Does | More |
| --- | --- | --- |
| `setup` | Connects this computer’s AI tools to your vault, or takes keypaste out with `--remove`. | [keypaste setup](https://keypaste.com/developers/setup/) |
| `mcp` | The bridge your AI tools start; you do not run it yourself. | [The bridge and its tools](https://keypaste.com/developers/mcp/) |
| `approve` | Holds the vault unlocked in this terminal and asks you about each agent’s request. | [keypaste approve](https://keypaste.com/developers/approve/) |
| `clients` | Lists agents, their rules and kept answers, and changes them. | [Agent settings](https://keypaste.com/developers/policy/) |
| `doctor` | Checks the vault, the AI tools and the app, and says what to fix. |  |
| `token` | Creates, lists and revokes scoped tokens that only feed `keypaste run`, and seals bundles. | [keypaste token](https://keypaste.com/developers/token/) |
| `log` | Shows the audit log; `log verify` checks its hash chain. | [The audit log](https://keypaste.com/developers/audit-log/) |

## Vault

| Command | Does | More |
| --- | --- | --- |
| `init` | Creates a new vault. | [Give an AI agent its first key](https://keypaste.com/developers/start/) |
| `use` | Chooses the vault used when no `--vault` is given, or prints it. |  |
| `import` | Copies in another KeePass file or another password manager’s export, or keeps a KeePass file where it is. | [Import](https://github.com/notinferred/keypaste/blob/main/docs/import.md) |
| `share` | Makes an encrypted link that opens a set number of times; `ls`, `revoke` and `open` manage them. | [keypaste share](https://keypaste.com/developers/share/) |
| `account` | Signs in to the free keypaste account share links need. | [keypaste share](https://keypaste.com/developers/share/) |
| `browser` | Turns keypaste on or off as each browser’s extension host. | [Browser fill](https://github.com/notinferred/keypaste/blob/main/docs/browser-fill.md) |
| `lock` | Locks the vault now and pauses every agent. | [The bridge and its tools](https://keypaste.com/developers/mcp/) |
| `add` | Adds an item. |  |
| `ls` | Lists groups and items. |  |
| `search` | Finds items by title, group, username or website. |  |
| `rm` | Removes an item. |  |
| `generate` | Prints a passphrase (`--words N`); it is not stored. |  |
| `access` | Changes the master password or key file. |  |

While the desktop app holds the vault, commands that edit it send their change to the app, which saves it once you allow it. `access`, `import`, `token` and `share` are refused instead: make the change in the app, or run `keypaste lock` first.

## Flags every command takes

| Flag | Effect |
| --- | --- |
| `--vault <path>` | Which vault to use. Or set `KEYPASTE_VAULT`; with neither, the vault chosen with `keypaste use` or in the app. |
| `--keyfile <path>` | The key file the vault needs too. Or set `KEYPASTE_KEYFILE`. |
| `--json` | Machine-readable output, from `ls`, `search`, `show`, `field ls`, `attachment ls`, `env ls`, `log`, `doctor`, `token ls`, `share ls`, `clients` and `browser`. |
| `-h`, `--help` | Help for any command. |

[Files and environment variables](https://keypaste.com/developers/files/) lists every variable keypaste reads.

## Exit codes

| Code | Meaning |
| --- | --- |
| 0 | Success |
| 1 | Usage error |
| 2 | Internal or environment error |
| 3 | Vault or item not found |
| 4 | Wrong master password |
| 5 | The audit log is not the file keypaste wrote |

Once a command `keypaste run` starts, its exit code is keypaste’s own ([keypaste run](https://keypaste.com/developers/run/#exit-codes)). Data goes to standard output and diagnostics to standard error. Passwords are never echoed, and Escape at a prompt cancels.
