Mandatory persistent memory integration for project development. Use when working on any codebase that uses opencode-mem for context persistence. Always searches memory before planning, coding, refactoring, or debugging. Suggests adding new facts after completing significant tasks. Works with any programming language, framework, or architecture style.
Before responding to any architecture, refactoring, feature implementation, debugging, or project-related query, execute one or more semantic searches in persistent memory using the memory tool.
Craft specific, descriptive queries based on the user's task and the project context:
// Architecture & design patterns
memory({ mode: "search", query: "architecture pattern layers components structure" })
// Technology stack & frameworks
memory({ mode: "search", query: "framework library dependencies tech stack" })
// Error handling & logging
memory({ mode: "search", query: "error handling logging monitoring patterns" })
// Testing strategy
memory({ mode: "search", query: "testing unit integration e2e test patterns" })
// Specific features or modules
memory({ mode: "search", query: "authentication user management JWT session" })
memory({ mode: "search", query: "database schema models relationships ORM" })
memory({ mode: "search", query: "API endpoints routes controllers handlers" })
Key principles for effective searches:
After completing important tasks (refactors, new features, architectural decisions, significant fixes), identify valuable new knowledge and suggest adding it to memory:
memory({ mode: "add", content: "[concise, precise description of new decision/implementation]" })
What makes good memory content:
Examples across different project types:
// Frontend project
memory({ mode: "add", content: "Use React.memo() for all list item components to prevent unnecessary re-renders; measured 40% performance improvement" })
// Backend API
memory({ mode: "add", content: "All API endpoints use middleware chain: auth → rate-limit → validation → controller; defined in src/middleware/index.js" })
// Database
memory({ mode: "add", content: "User sessions table uses UUID v4 for session_id with 24-hour TTL; cleanup cron runs daily at 3 AM UTC" })
// DevOps
memory({ mode: "add", content: "Deploy staging with 'npm run deploy:staging'; auto-runs migrations and health checks before traffic switch" })
// Architecture decision
memory({ mode: "add", content: "Switched from REST to GraphQL for mobile API to reduce over-fetching; web still uses REST for caching benefits" })
These guidelines apply regardless of project type, but always defer to project-specific patterns stored in memory:
Correct Response Flow:
Correct Response Flow:
Correct Response Flow:
When to Search Memory:
When to Add to Memory:
Default Response Flow:
1. memory search (1+ queries based on task)
↓
2. analyze retrieved facts and patterns
↓
3. generate solution consistent with project
↓
4. suggest memory add for new knowledge (if applicable)
Search Query Formula:
[feature/module name] + [technical aspect] + [related patterns]
Examples:
- "user profile component React state management"
- "payment processing error handling retry logic"
- "database migration rollback strategy"