memories.sh logomemories.sh
Integrations

OpenCode

Integrate memories.sh with OpenCode CLI.

OpenCode is an open-source AI coding assistant that runs in your terminal. It works well with the canonical .agents/ harness and supports MCP servers via opencode.json.

Quick Setup

cd your-project
memories init

This automatically:

  1. Sets up your local memory store
  2. Configures MCP for supported tools
  3. Generates instruction files with your existing memories

Manual Setup

Option 1: Generated File

memories generate agents

This creates the canonical .agents/ directory used across agent tools. If you want a dedicated OpenCode instructions file too:

memories generate claude -o .opencode/instructions.md

Option 2: MCP Server

Add memories.sh to OpenCode's MCP configuration. Create or edit opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "memories": {
      "type": "local",
      "command": ["npx", "-y", "@memories.sh/cli", "serve"]
    }
  }
}

Or for global configuration, add to ~/.config/opencode/opencode.json.

Using both methods together gives the best experience:

  1. Generated file — Provides a static baseline always available to OpenCode
  2. MCP server — Gives OpenCode live access to search and add memories

Syncing OpenCode Config

To sync your OpenCode configuration across machines:

# On your main machine
memories files ingest

# On a new machine  
memories files apply --global --force

This syncs:

  • opencode.json — Project OpenCode MCP configuration
  • .agents/**/* — Canonical shared harness files
  • .opencode/instructions.md — Your instruction files
  • .opencode/skills/**/* — Any skills you've created

To also sync the global OpenCode config (~/.config/opencode/opencode.json):

memories files ingest --global --include-config
memories files apply --global --include-config --force

OpenCode-Specific Features

Custom Instructions

OpenCode can read .opencode/instructions.md at the project level. Generate this file with:

memories generate claude -o .opencode/instructions.md

Skills

If you've created OpenCode skills, they're synced with memories files:

# Import your skills
memories files ingest

# Apply on another machine
memories files apply --global

On this page