Auto-Memory
Persistent project memory system with automatic extraction, keyword-ranked context retrieval, and dream consolidation. Manage via xc memory commands.
XibeCode's auto-memory system gives the agent persistent, project-specific memory across sessions. It automatically extracts useful information from conversations, retrieves relevant memories when starting a new session, and periodically consolidates stale entries.
How It Works
- Automatic Extraction: After each conversation turn, the agent extracts notable facts, patterns, and decisions into memory files
- Context Retrieval: When a session starts, memories relevant to the user's prompt are loaded and injected into the agent's context
- Dream Consolidation: Periodically, older and overlapping memories are merged and pruned to keep the memory store lean and accurate
Memory Storage
Memories are stored as Markdown files with YAML frontmatter:
~/.xibecode/projects/<sanitized-cwd>/memory/
├── 2026-05-03-api-patterns.md
├── 2026-05-03-auth-flow.md
└── 2026-05-02-testing-approach.mdAdditionally, project-local memories are stored in:
<project-root>/.xibecode/memory.mdBoth locations are scanned and merged when listing or searching memories.
Memory File Format
Each memory file uses frontmatter for metadata:
---
type: pattern
tags: [api, rest, express]
created: 2026-05-03T10:00:00Z
updated: 2026-05-03T10:00:00Z
relevance: 0.8
---
## API Pattern
All REST endpoints follow the controller-service-repository pattern.
Error handling uses a centralized middleware in src/middleware/errorHandler.ts.Memory Types
| Type | Description |
|---|---|
fact | A factual observation about the codebase |
pattern | A recurring pattern or convention |
decision | An architectural or design decision |
correction | A user correction that should be remembered |
preference | A user preference for how code should be written |
CLI Commands
List all memories
xc memory listShows all memories for the current project, grouped by type.
Search memories
xc memory search "authentication flow"
xc memory search "API patterns"Returns memories ranked by relevance to the query. Ranking is based on:
- Tag overlap between query and memory tags
- Keyword frequency matching
- Recency (newer memories rank slightly higher)
Run dream consolidation
xc memory dreamTriggers consolidation, which:
- Scans all memory files for overlapping content
- Merges similar memories into unified entries
- Removes stale or redundant entries
- Updates relevance scores
Dream consolidation also runs automatically when the memory store grows large.
Show memory directory path
xc memory pathDisplays the filesystem path where memories are stored for the current project.
Chat Commands
Inside an interactive chat session:
/memory list Show all project memories
/memory search Search memories by keywordConfiguration
Memory behavior can be configured in settings:
{
"memory": {
"enabled": true,
"maxMemories": 100,
"relevanceThreshold": 0.3,
"dreamConsolidationInterval": 3600
}
}| Setting | Description | Default |
|---|---|---|
memory.enabled | Enable or disable auto-memory | true |
memory.maxMemories | Maximum number of memory files before consolidation triggers | 100 |
memory.relevanceThreshold | Minimum relevance score for context injection | 0.3 |
memory.dreamConsolidationInterval | Seconds between automatic dream consolidations | 3600 |
How Context Injection Works
When you start a new session, the agent:
- Takes your initial prompt
- Searches memory files for relevant entries using keyword and tag matching
- Selects memories above the relevance threshold
- Injects them into the system prompt as a "Relevant Project Memories" section
This means the agent remembers your project conventions, past decisions, and user corrections without you having to repeat them every session.
Manual Memory
You can also create memories directly by writing to .xibecode/memory.md in your project root:
# Project Memory
## Conventions
- Always use pnpm for package management
- Follow conventional commits for commit messages
- Use TypeScript strict mode
## Architecture
- Monorepo with packages/core and packages/cli
- Core is published as xibecode-core on npmThis file is automatically included in memory scans alongside the auto-extracted memories.
Example Session
$ xc chat
> Add a new API endpoint for user preferences
[Agent loads relevant memories about API patterns and project structure]
[Agent follows the stored conventions for endpoint creation]
> /memory list
5 memories found for this project:
- API Pattern (pattern) - REST endpoint conventions
- Auth Flow (pattern) - Authentication middleware
- Testing Approach (pattern) - Test file structure
- User Preference (preference) - Always use pnpm
- Error Handling (decision) - Centralized error middlewareNext Steps
- Settings — Configure memory behavior
- Lifecycle Hooks — Run logic at session events
- Permissions — Control tool execution
Lifecycle Hooks
Register custom commands, prompts, and HTTP calls at agent lifecycle events. Run scripts before/after tool use, at session start/end, and on compaction.
Permission Rules
Fine-grained allow, deny, and ask rules for controlling tool execution in XibeCode. Configure per-tool patterns via settings.