> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hydradb.com/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenCode

> Give OpenCode long-term memory with the native HydraDB plugin.

The [OpenCode](https://opencode.ai) plugin provides a `hydradb_recall` tool for
the agent to call, syncs workspace docs when files change, and captures turns
when the session becomes idle.

| OpenCode surface | Engine action |
| - | - |
| `hydradb_recall` tool (agent-invocable) | recall memory/knowledge for a query |
| `event`: `file.edited` | incremental workspace sync |
| `event`: `session.idle` | capture the completed turn |

**1. Install & set credentials**

Add the plugin to your `opencode.json`; OpenCode installs [hydradb-opencode-plugin](https://www.npmjs.com/package/hydradb-opencode-plugin) from npm:

```json theme={"dark"}
{ "plugin": ["hydradb-opencode-plugin"] }
```

```bash theme={"dark"}
export HYDRADB_API_KEY="your-api-key"
export HYDRADB_DATABASE="your-database"
```

Requires [Bun](https://bun.sh) (OpenCode's runtime) and Node.js 18+.

**2. Run with tool approval**

Tool calls need approval. Run with `--auto` or approve `hydradb_recall`
interactively:

```bash theme={"dark"}
opencode run --auto "What did we decide? Use hydradb_recall."
```

It runs on the same engine as the [Claude Code plugin](/plugins/claude-code.md), so the [modes](/plugins/claude-code.md#modes) and [config variables](/plugins/claude-code.md#config-variables) there apply here too.

## Feedback and contributions

This plugin is open source. Feel free to [raise an issue](https://github.com/hydra-db/hydradb-opencode-plugin/issues) or [contribute on GitHub](https://github.com/hydra-db/hydradb-opencode-plugin).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.