# CLI reference

Look up commands to save or rotate a credential, run a process with named secrets, or check a request.

```sh
npm i -g @asecret/cli
```

It needs Node.js 24 or later, and installs two commands: `asecret`, and `asecret-mcp` for [MCP](https://asecret.sh/docs/mcp).

## Secrets

| Command | What it does |
| --- | --- |
| `save <name>` | Save a secret from standard input. `secret` does the same |
| `list [name]` | List this agent's secrets by name, never their values; with a name, that secret's kept versions. `secrets` does the same |
| `get <name>` | Print a secret's value, with a warning. `--version <n>` prints an earlier one |
| `delete <name>` | Delete a secret and its earlier versions |
| `run --secret <name> -- <cmd>` | Run a command with secrets in its environment. A detail your user shared sets each of its parts too |

## Your user

| Command | What it does |
| --- | --- |
| `link` | Link this agent to your user, so they can see it and answer its asks. `--name` sets how it appears to them |
| `unlink` | End the link to your user |
| `ask <detail>` | Ask your user to save a detail they keep, or `ask setup` to set up several |
| `ask <detail> --use` | Ask your user to share a detail for a task. `--for "why"` says why, `--as NAME` names the secret it's kept as |
| `asks` | List this agent's asks and where each stands |
| `check <ask>` | Read one ask, or wait for the decision with `--wait` |
| `cancel <ask>` | Cancel an ask that is still waiting |
| `recipients` | List the merchants your user's own aSecret server delivers to (`--server` only) |

These work with asecret.sh. Payment methods and deliveries to merchants need your user's own aSecret server: point the commands at it with `--server <origin>`. [Asking your user](https://asecret.sh/docs/person)

## Use a detail

```sh
asecret ask postal_address --use --for "fill in the checkout at shop.example"
asecret run --secret POSTAL_ADDRESS -- sh checkout.sh
```

Your user chooses which address to share, in their browser, and it arrives encrypted for this agent alone. It's kept as one of the agent's secrets, `POSTAL_ADDRESS` unless `--as` names it, and `run` sets the whole detail and each part: `POSTAL_ADDRESS_STREET`, `POSTAL_ADDRESS_CITY`, `POSTAL_ADDRESS_REGION`, `POSTAL_ADDRESS_POSTAL_CODE` and `POSTAL_ADDRESS_COUNTRY`. The address is in that command's environment alone, so a script like this `checkout.sh` fills in a form without it entering the chat:

```sh
curl https://shop.example/api/checkout \
  --data-urlencode "street=$POSTAL_ADDRESS_STREET" \
  --data-urlencode "city=$POSTAL_ADDRESS_CITY" \
  --data-urlencode "postcode=$POSTAL_ADDRESS_POSTAL_CODE" \
  --data-urlencode "country=$POSTAL_ADDRESS_COUNTRY"
```

If the agent isn't linked yet, `--use` links it first: your user approves it, and the ask opens on the same page. [Use a detail](https://asecret.sh/docs/person#use)

## This agent

| Command | What it does |
| --- | --- |
| `connect` | Connect this agent to aSecret and create its key. `--name` sets how it appears to your user |
| `me` | Show this agent, its secrets and whether a person is linked |
| `key` | Show this agent's key fingerprint, or export the key with `--export` |
| `token --rotate` | Replace this agent's token, for example if it leaked |
| `erase` | Delete this agent at aSecret, with every secret, and forget it here |
| `logout` | Forget the token and key on this machine |
| `add` | Install the aSecret skill in supported runtimes |
| `remove` | Remove the aSecret skill from installed runtimes |
| `mcp` | Run aSecret as a local MCP server, or print its settings with `--print` |
| `instructions` | Print text your user can paste into any chat |

## Options for every command

| Option | What it does |
| --- | --- |
| `--json` | Print the API's JSON, for scripts and agents |
| `-y`, `--yes` | Answer yes to every prompt |
| `--api <url>` | Use another aSecret API (`https://api.asecret.sh` unless you say otherwise) |
| `-h`, `--help` | Show help |
| `-v`, `--version` | Show the version |

## Environment

| Variable | What it does |
| --- | --- |
| `ASECRET_TOKEN` | Use an existing token |
| `ASECRET_CONFIG_DIR` | Keep a separate agent on the same machine |
| `ASECRET_API_URL` | Use another aSecret API than api.asecret.sh |

The token and key live in `~/.config/asecret/credentials.json`, readable only by you. `asecret logout` forgets them on this machine, and doesn't delete anything at aSecret. `asecret erase` deletes the agent at aSecret too.

If the token leaks, run `asecret token --rotate`. The new token is saved here and the old one stops working; the key stays the same, so every secret stays readable. Export the key again afterwards, since earlier exports hold the old token.

## Exit codes

`0` means it worked, `1` means the request failed, and `2` means the command itself was wrong, such as an unknown command or a missing argument. With `run`, the exit code is the command's own.
