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 initThis automatically:
- Sets up your local memory store
- Configures MCP for supported tools
- Generates instruction files with your existing memories
Manual Setup
Option 1: Generated File
memories generate agentsThis creates the canonical .agents/ directory used across agent tools. If you want a dedicated OpenCode instructions file too:
memories generate claude -o .opencode/instructions.mdOption 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.
Recommended: Use Both
Using both methods together gives the best experience:
- Generated file — Provides a static baseline always available to OpenCode
- 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 --forceThis 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 --forceOpenCode-Specific Features
Custom Instructions
OpenCode can read .opencode/instructions.md at the project level. Generate this file with:
memories generate claude -o .opencode/instructions.mdSkills
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