> ## Documentation Index
> Fetch the complete documentation index at: https://cortex-e852fafe-t3code-rewrite-docs-declutter.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenCode

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

Native plugin for [OpenCode](https://opencode.ai) that hooks the session
lifecycle to recall context at prompt time, sync workspace docs, and capture
turns.

| 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 |

<Steps>
  <Step title="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+.
  </Step>

  <Step title="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."
    ```
  </Step>
</Steps>

It runs on the same engine as the [Claude Code plugin](/plugins/claude-code), so the [modes](/plugins/claude-code#modes) and [config variables](/plugins/claude-code#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.