> ## Documentation Index
> Fetch the complete documentation index at: https://supermemory-capy-add-llmstxt-summary-and.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenCode

> Supermemory plugin for OpenCode. Keeps memory across coding sessions.

[OpenCode-Supermemory](https://github.com/supermemoryai/opencode-supermemory) is an OpenCode plugin that gives your AI persistent memory across sessions. Your agent remembers what you worked on — across sessions, across projects.

<Tip>
  **Prefer to keep everything on your machine?** This plugin works with [self-hosted Supermemory](/self-hosting/overview) — run `npx supermemory local`, then set `apiKey` / base URL in `~/.config/opencode/supermemory.jsonc` and use the API key printed on first boot.
</Tip>

## Install the plugin

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
bunx opencode-supermemory@latest install
```

For LLM agents (non-interactive):

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
bunx opencode-supermemory@latest install --no-tui
```

## Authenticate

Browser login (recommended):

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
bunx opencode-supermemory@latest login
```

Check the connection any time:

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
bunx opencode-supermemory@latest status
```

Or set an API key manually from the [API Keys](https://console.supermemory.ai/keys) page in the console:

<Tabs>
  <Tab title="macOS / Linux (zsh)">
    ```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
    echo 'export SUPERMEMORY_API_KEY="sm_..."' >> ~/.zshrc
    source ~/.zshrc
    ```
  </Tab>

  <Tab title="macOS / Linux (bash)">
    ```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
    echo 'export SUPERMEMORY_API_KEY="sm_..."' >> ~/.bashrc
    source ~/.bashrc
    ```
  </Tab>

  <Tab title="Windows (PowerShell)">
    ```powershell theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
    [System.Environment]::SetEnvironmentVariable("SUPERMEMORY_API_KEY", "sm_...", "User")
    ```

    Restart your terminal after running this.
  </Tab>
</Tabs>

Ensure your `~/.config/opencode/opencode.jsonc` contains:

```json theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
{
  "plugin": ["opencode-supermemory"]
}
```

## How it works

Once installed, the plugin runs automatically:

* **Context Injection** — On session start, relevant memories are fetched and injected into the agent's context (user profile, project knowledge, semantic matches).
* **Keyword Detection** — Phrases like "remember" or "save this" trigger automatic storage.
* **Smart Compaction** — At 80% context capacity, sessions are summarized and saved as memories.
* **Privacy Protection** — Content within `<private>` tags never persists.

### Memory scopes

| Scope | Description |
| - | - |
| `user` | Memories that persist across all projects |
| `project` | Memories isolated to the current project (default) |

### Memory types

| Type | Description |
| - | - |
| `project-config` | Project configuration and setup details |
| `architecture` | Codebase structure and design patterns |
| `error-solution` | Problems encountered and their fixes |
| `preference` | User preferences and coding style |
| `learned-pattern` | Patterns discovered during sessions |
| `conversation` | Important conversation context |

## Commands

### /supermemory-init

Explore and index your codebase structure into memory:

```
/supermemory-init
```

## Tools

The agent has access to a `supermemory` tool with these modes:

| Mode | Parameters | Function |
| - | - | - |
| `add` | content, type?, scope? | Store information |
| `search` | query, scope? | Find relevant memories |
| `profile` | query? | View user preferences |
| `list` | scope?, limit? | Display stored items |
| `forget` | memoryId, scope? | Remove memory |

## Configuration

Create `~/.config/opencode/supermemory.jsonc`:

```jsonc theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
{
  "apiKey": "sm_...",              // Or use SUPERMEMORY_API_KEY / browser login
  "similarityThreshold": 0.6,      // Minimum match score (0-1)
  "maxMemories": 5,                // Memories per injection
  "maxProjectMemories": 10,        // Project memory listings
  "maxProfileItems": 5,            // Profile facts injected
  "injectProfile": true,           // Include user preferences in context
  "containerTagPrefix": "opencode", // Tag prefix for scoping
  "userContainerTag": "my-user-tag",       // Optional override
  "projectContainerTag": "my-project-tag", // Optional override
  "keywordPatterns": ["log\\s+this"],      // Extra auto-save triggers
  "compactionThreshold": 0.80      // Context usage ratio for summarization
}
```

## Logging

View plugin activity:

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
tail -f ~/.opencode-supermemory.log
```

## Next steps

<CardGroup cols={2}>
  <Card title="GitHub repository" icon="https://mintcdn.com/supermemory-capy-add-llmstxt-summary-and/RZUchfWXNk8FOiN_/images/github-icon.svg?fit=max&auto=format&n=RZUchfWXNk8FOiN_&q=85&s=997e915bbbc7ec5808a4cced93759dbc" href="https://github.com/supermemoryai/opencode-supermemory" width="16" height="16" data-path="images/github-icon.svg">
    Source code, issues, and detailed README.
  </Card>

  <Card title="Claude Code plugin" icon="https://mintcdn.com/supermemory-capy-add-llmstxt-summary-and/LIMkcglt81IfjBVR/icons/hugeicons/source-code.svg?fit=max&auto=format&n=LIMkcglt81IfjBVR&q=85&s=52683783392468c7c21576fea4b14c15" href="/integrations/claude-code" width="24" height="24" data-path="icons/hugeicons/source-code.svg">
    Memory plugin for Claude Code.
  </Card>
</CardGroup>


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