# OpenCode

Set up aSecret in OpenCode, then check a secret name and pass it to a command.

## 1. Install the CLI and connect

You need Node.js 24 or later. `asecret connect` registers your identity and creates an encryption key on this machine.

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

## 2. Keep a copy of the key

Every secret is encrypted with this key before it leaves. Without it nobody can open them again, aSecret included. Keep the file somewhere safe and out of chats.

```
asecret key --export --out asecret-key.json
```

## 3. Install the aSecret skill for OpenCode

This saves the skill to `~/.config/opencode/skills/asecret`, where OpenCode reads skills. Run it again to update. Add `-p` to put it in the current project instead.

```
asecret add -a opencode
```

## 4. Add the MCP server (optional)

Print the entry for your OpenCode config. It matches the version you have installed: `mcp.asecret` for 1.x, `mcp.servers.asecret` for 2.x.

```
asecret mcp --print --host opencode
```

`asecret-mcp` comes with the CLI and uses the same token and key. `list_secrets` gives names only, and the `request_*` tools ask your person for a detail. No tool returns a value.

## 5. Try it

Have your user enter the key at the hidden terminal prompt. You can then run the requested task in OpenCode:

```
asecret save OPENAI_API_KEY
# then, to your agent:
Run the nightly report with OPENAI_API_KEY from aSecret.
```

Something not working? See [Support](https://asecret.sh/docs/support).
