XibeCode

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

  1. Automatic Extraction: After each conversation turn, the agent extracts notable facts, patterns, and decisions into memory files
  2. Context Retrieval: When a session starts, memories relevant to the user's prompt are loaded and injected into the agent's context
  3. 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.md

Additionally, project-local memories are stored in:

<project-root>/.xibecode/memory.md

Both 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

TypeDescription
factA factual observation about the codebase
patternA recurring pattern or convention
decisionAn architectural or design decision
correctionA user correction that should be remembered
preferenceA user preference for how code should be written

CLI Commands

List all memories

xc memory list

Shows 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 dream

Triggers consolidation, which:

  1. Scans all memory files for overlapping content
  2. Merges similar memories into unified entries
  3. Removes stale or redundant entries
  4. Updates relevance scores

Dream consolidation also runs automatically when the memory store grows large.

Show memory directory path

xc memory path

Displays 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 keyword

Configuration

Memory behavior can be configured in settings:

{
  "memory": {
    "enabled": true,
    "maxMemories": 100,
    "relevanceThreshold": 0.3,
    "dreamConsolidationInterval": 3600
  }
}
SettingDescriptionDefault
memory.enabledEnable or disable auto-memorytrue
memory.maxMemoriesMaximum number of memory files before consolidation triggers100
memory.relevanceThresholdMinimum relevance score for context injection0.3
memory.dreamConsolidationIntervalSeconds between automatic dream consolidations3600

How Context Injection Works

When you start a new session, the agent:

  1. Takes your initial prompt
  2. Searches memory files for relevant entries using keyword and tag matching
  3. Selects memories above the relevance threshold
  4. 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 npm

This 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 middleware

Next Steps

Ctrl+I
Assistant

How can I help?

Ask me about configuration, installation, or specific features.