Memory

The rulebook memory system provides persistent context across AI sessions using hybrid search (BM25 keyword + HNSW vector) with zero native dependenci

11 stars

Best use case

Memory is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

The rulebook memory system provides persistent context across AI sessions using hybrid search (BM25 keyword + HNSW vector) with zero native dependenci

Teams using Memory should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/memory/SKILL.md --create-dirs "https://raw.githubusercontent.com/hivellm/rulebook/main/templates/skills/modules/memory/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/memory/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How Memory Compares

Feature / AgentMemoryStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

The rulebook memory system provides persistent context across AI sessions using hybrid search (BM25 keyword + HNSW vector) with zero native dependenci

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

<!-- MEMORY:START -->
## Persistent Memory System

The rulebook memory system provides persistent context across AI sessions using hybrid search (BM25 keyword + HNSW vector) with zero native dependencies.

### 3-Layer Search Pattern (Token-Efficient)

**Layer 1 — Compact Search**: Get brief results to scan relevance.
```
rulebook_memory_search({ query: "authentication bug", mode: "hybrid", limit: 10 })
→ Returns: { id, title, type, score, matchType, createdAt } per result (~50 tokens each)
```

**Layer 2 — Timeline**: Get chronological context around a memory.
```
rulebook_memory_timeline({ memoryId: "abc-123", window: 5 })
→ Returns: 5 memories before + anchor + 5 memories after (~200 tokens each)
```

**Layer 3 — Full Details**: Get complete content only for selected memories.
```
rulebook_memory_get({ ids: ["abc-123", "def-456"] })
→ Returns: Full memory objects with content (~500-1000 tokens each)
```

### Memory Types

- **bugfix**: Bug fixes, error resolutions
- **feature**: New features, additions
- **refactor**: Code restructuring
- **decision**: Architectural decisions (protected from eviction)
- **discovery**: Insights and learnings
- **change**: Updates and modifications
- **observation**: General observations

### CLI Commands

```bash
rulebook memory search "authentication bug"     # Hybrid search
rulebook memory save "Decided to use sql.js" --type decision --title "DB Choice"
rulebook memory list --limit 10                  # Recent memories
rulebook memory stats                            # Database statistics
rulebook memory cleanup --force                  # Force eviction
rulebook memory export --format json             # Export all memories
```

### Configuration (.rulebook)

```json
{
  "memory": {
    "enabled": true,
    "dbPath": ".rulebook-memory/memory.db",
    "maxSizeBytes": 524288000,
    "vectorDimensions": 256
  }
}
```

### Privacy

Content between `<private>` and `</private>` tags is automatically stripped before storage.
<!-- MEMORY:END -->