CLI Documentation

vault-cli

Manage your code snippets from the terminal. List, search, copy, create, push, and delete snippets without leaving your editor.

Getting Started#

vault-cli is a Go binary that talks directly to your Vault instance. You need a Vault account and a CLI access token to get started.

01

Install

Download the binary via go install

02

Get a token

Generate a CLI token in settings

03

Authenticate

Run vault auth login --token

You need a Vault account to generate a CLI token. Sign up for free then go to settings → CLI access tokens.

Installation#

Install via go install — requires Go 1.21 or later.

terminal
go install github.com/yuricommits/vault-cli@latest

The binary is installed to $GOPATH/bin. Make sure this is in your $PATH.

Build from source

terminal
git clone https://github.com/yuricommits/vault-cli
cd vault-cli
go build -o vault .
sudo mv vault /usr/local/bin/

Verify installation

terminal
vault --help

Supported platforms: Linux, macOS, Windows. Clipboard support requires xclip on Linux.

Authentication#

vault-cli uses token-based authentication. Tokens are generated from your Vault settings page and stored locally in ~/.config/vault/config.json.

Generate a token

  1. 1.Go to vault settings
  2. 2.Scroll to CLI Access Tokens
  3. 3.Enter a name (e.g. macbook, work-pc)
  4. 4.Click create — copy the token immediately, it won't be shown again

Login

terminal
vault auth login --token vlt_yourtoken

Login with custom URL (self-hosted)

terminal
vault auth login --token vlt_yourtoken --url https://your-vault.com

Check status

terminal
vault auth status

Logout

terminal
vault auth logout

Commands Reference#

All commands require authentication. Run vault auth login first.

List snippets

vault list

List all your snippets showing ID, language, and title.

Search snippets

vault search <query>

Search snippets by title, description, language, or code content.

terminal
vault search "debounce"

Copy to clipboard

vault copy <id>

Copy a snippet's code directly to your system clipboard. Falls back to printing to stdout if clipboard is unavailable.

terminal
vault copy a1b2c3d4-...

Create a snippet

vault new

Interactively create a new snippet from the terminal. Prompts for title, language, description, and code. Type END on a new line to finish entering code.

Push a file

vault push <file>

Push a local file as a snippet. Language is auto-detected from the file extension.

--titleSnippet titlefilename
--languageLanguage overrideauto-detect
--descriptionSnippet description
terminal
vault push ./hooks/useDebounce.ts
vault push ./hooks/useDebounce.ts --title "useDebounce" --description "Debounce hook for React"

Delete a snippet

vault delete <id>

Delete a snippet. Prompts for confirmation unless --force is passed.

--forceSkip confirmation promptfalse
terminal
vault delete a1b2c3d4-...
vault delete a1b2c3d4-... --force

Configuration#

Config is stored at ~/.config/vault/config.json. You can edit it directly or use the CLI commands.

~/.config/vault/config.json
tokenstringCLI access token
base_urlstringBase URL of your Vault instancevault-two-lovat.vercel.app

Example config

{
  "token": "vlt_abc123...",
  "base_url": "https://vault-two-lovat.vercel.app"
}

Examples#

Push all TypeScript files in a folder

terminal
for f in ./utils/*.ts; do
  vault push "$f"
done

Search and copy in one step

terminal
# Find the snippet ID
vault search "debounce"

# Copy it
vault copy <id>

Quickly save a script you just wrote

terminal
vault push ./cleanup.sh --title "DB cleanup script" --description "Removes stale sessions"

Delete multiple snippets

terminal
vault delete <id1> --force
vault delete <id2> --force

Troubleshooting#

command not found: vault

Make sure $GOPATH/bin is in your $PATH. Add export PATH=$PATH:$(go env GOPATH)/bin to your shell profile.

not authenticated

Run vault auth login --token <token>. Generate a token from vault settings → CLI access tokens.

request failed: 401

Your token may be revoked or expired. Generate a new one from settings and run vault auth login again.

clipboard not working on Linux

Install xclip: sudo apt install xclip. The copy command falls back to printing to stdout if xclip is unavailable.

vault: command not found after go install

Run go env GOPATH to find your Go binary path, then add it to PATH.

GitHub#

vault-cli is open source. Contributions, bug reports, and feature requests are welcome.

yuricommits/vault-cli
view on github