Share memories between OpenCode and Claude Code.
Using claude-brain and Memvid.
You: "Remember that auth bug we fixed?"
OpenCode: "I don't have memory of previous conversations."
You: "We spent 3 hours on it yesterday"
OpenCode: "I'd be happy to help debug from scratch!"
Large context window. Zero memory between sessions.
You: "What did we decide about auth?"
OpenCode: "We chose JWT over sessions for your microservices.
The refresh token issue - here's exactly what we fixed..."
One file. OpenCode remembers everything.
- Node.js 18.0.0 or higher
- OpenCode 0.1.0 or higher
npm install opencode-brainAdd to your opencode.json:
{
"plugin": ["opencode-brain"]
}Restart OpenCode. Done.
After install, OpenCode's memory lives in one file:
your-project/
└── .claude/
└── mind.mv2 # OpenCode's brain. That's it.
No database. No cloud. No API keys.
What gets captured:
- Tool outputs (files read, commands run, searches)
- Session context, decisions, bugs, solutions
- Auto-injected at session start
- Searchable anytime
Why one file?
git commit→ version control OpenCode's brainscp→ transfer anywhere- Send to teammate → instant onboarding
- Compatible with claude-brain → Use both tools on the same project
In OpenCode:
/mind:stats # memory statistics
/mind:search "authentication" # find past context
/mind:ask "why did we choose X?" # ask your memory
/mind:recent # what happened latelyOr just ask naturally: "mind stats", "search my memory for auth bugs", etc.
| Tool | Description |
|---|---|
mind_search |
Search memories by query with relevance scoring |
mind_ask |
Ask questions about past work using context |
mind_stats |
View memory statistics and health |
mind_timeline |
View recent observations chronologically |
/mind:search "database connection error"Output:
1. [problem] Database connection timeout
Score: 0.85 | 2h ago | via opencode
Failed to connect to PostgreSQL: connection timeout after 30s
File: src/db/connection.ts
2. [solution] Fixed connection pool configuration
Score: 0.72 | 2h ago | via opencode
Increased pool size to 20, added retry logic with exponential backoff
File: src/db/connection.ts
/mind:ask "Why did we switch from REST to GraphQL?"Output:
Based on recent observations:
We switched to GraphQL to solve the over-fetching problem in the mobile app.
The REST endpoints were returning entire user objects when the app only needed
names and avatars, causing slow load times. GraphQL allows the mobile team to
request exactly what they need.
Decision made 3 days ago during API redesign discussion.
/mind:recent 5Output:
📅 Recent Observations (last 5):
1. 5 minutes ago | [feature] Added user authentication endpoints
Implemented JWT-based auth with refresh tokens
2. 15 minutes ago | [discovery] Found existing auth middleware
Located reusable auth middleware in src/middleware/
3. 1 hour ago | [problem] TypeScript errors in auth service
Missing types for User interface
4. 1 hour ago | [solution] Fixed TypeScript errors
Added proper type definitions
5. 2 hours ago | [decision] Chose PostgreSQL for user data
Better suited for relational user data than MongoDB
opencode-brain and claude-brain share the same .claude/mind.mv2 file.
- Both plugins read/write the same memory file
- Source attribution shows which tool created each memory
- File locking prevents corruption from concurrent access
- Completely transparent - just works
Scenario 1: Research + Implementation
- Use Claude Code to research an architecture decision → Stored in
.claude/mind.mv2 - Use OpenCode to implement it → Reads the same file, sees the decision
- Both tools maintain a shared memory
Scenario 2: Team Collaboration
- Developer A uses Claude Code to debug an issue
- Developer A commits
.claude/mind.mv2to git - Developer B pulls the repo and uses OpenCode
- Developer B sees all of Developer A's debugging context
Scenario 3: Multi-Tool Workflow
- Use Claude Code for complex reasoning tasks
- Use OpenCode for rapid coding
- Both see the same project context
- No context loss when switching tools
Observations are automatically classified as:
- discovery - New information found (files, patterns, APIs)
- decision - Choices made (architecture, libraries, approaches)
- problem - Errors encountered (bugs, failures, issues)
- solution - Fixes implemented (bug fixes, workarounds)
- pattern - Patterns recognized (code smells, best practices)
- warning - Concerns noted (tech debt, security issues)
- success - Successful outcomes (passing tests, deployments)
- refactor - Code refactoring (improvements, cleanups)
- bugfix - Bugs fixed (specific issues resolved)
- feature - Features added (new functionality)
How big is the file?
Empty: ~70KB. Grows ~1KB per memory. A year of use stays under 5MB.
Large outputs are automatically compressed to ~500 tokens using ENDLESS MODE compression.
Is it private?
100% local. Nothing leaves your machine. Ever.
The .mv2 file is stored in your project directory with full control.
How fast?
Sub-millisecond. Native Rust core via memvid. Searches 10K+ memories in <1ms.
Does it work with claude-brain?
Yes! 100% compatible. Both use .claude/mind.mv2 and can be used interchangeably on the same project.
File locking ensures safe concurrent access.
What gets compressed?
Tool outputs over 3000 characters are automatically compressed using tool-specific strategies:
- File reads: Extract structure, imports, exports, functions, classes
- Bash commands: Focus on errors, success indicators, key output
- Grep results: Summarize matches and files
- Glob results: Group by directory, show samples
- Edits/Writes: Capture summary and confirmation
Compression reduces to ~500 tokens while preserving key information.
Can I disable compression?
Compression is automatic for large outputs. The autoCompress config option exists but compression is recommended to avoid context limits.
Reset memory?
rm .claude/mind.mv2The file will be recreated automatically on next use.
Can I commit the .mv2 file to git?
Yes! It's designed for version control. Your team can share the same project context.
Just add it to git:
git add .claude/mind.mv2
git commit -m "Share project context"What if the file gets corrupted?
opencode-brain automatically detects corruption and creates a backup before starting fresh.
Backups are stored as .claude/mind.mv2.backup-{timestamp} (keeps 3 most recent).
If you see deserialization errors, opencode-brain automatically:
- Creates a backup:
.claude/mind.mv2.backup-{timestamp} - Starts a fresh memory file
- Keeps the 3 most recent backups
Check backup files if you need to recover data.
Files over 100MB are automatically detected and archived. Consider:
- Deleting old
.mv2files periodically - Starting fresh for new projects
- Checking for runaway observation creation
export OPENCODE_BRAIN_DEBUG=1This shows detailed logging of:
- Observations being captured
- Compression operations
- File locking activity
- SDK operations
- Check
opencode.jsonhas correct plugin name:"opencode-brain" - Verify Node.js version:
node --version(needs 18+) - Rebuild:
npm run buildin plugin directory - Check OpenCode logs for errors
- Enable debug logging (see above)
- Check if tools are being used (Read, Bash, Grep, etc.)
- Verify
.claude/directory is writable - Check for file locking issues (shouldn't happen with proper-lockfile)
Search memories by query using fast lexical search.
Parameters:
query(string, required) - Search terms or questionlimit(number, optional) - Max results, default 10
Returns: Array of search results with observation, score, and snippet
Ask questions about past work using memory context.
Parameters:
question(string, required) - Natural language question
Returns: String answer based on relevant memories
View memory statistics.
Parameters: None
Returns: Statistics object with:
totalObservations- Total memory counttotalSessions- Session countoldestMemory- Timestamp of oldest memorynewestMemory- Timestamp of newest memoryfileSize- Size in bytestopTypes- Observation type counts
View recent observations chronologically.
Parameters:
limit(number, optional) - Max results, default 20
Returns: Array of observations in chronological order
Contributions welcome! See CONTRIBUTING.md for guidelines.
git clone https://github.com/deiviuds/opencode-brain.git
cd opencode-brain
npm install
npm run build
npm testMIT - see LICENSE
If this saved you time, ⭐ star the repo
Built with ❤️ for the OpenCode community
Related: claude-brain - The original for Claude Code
