Sign In

memory-palace-red-queen

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

memory-palace-red-queen

Memory Palace + Red Queen Protocol - A Claude Code skill for durable knowledge through vivid encoding + adversarial testing

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
3
-50%
Maintainers
1
Weekly downloads
 
Created
Source

Memory Palace + Red Queen

A Claude Code skill for durable knowledge through vivid encoding + adversarial testing.

Memory without testing is belief without verification. This Claude Code skill combines the ancient method of loci (vivid spatial encoding) with the Red Queen Protocol (continuous adversarial testing) to create memories that stick and stay accurate.

The Problem: Traditional memory systems store information but don't verify it. Result? Confident hallucinations and rapid decay.

The Solution: Four specialized agents (Examiner, Learner, Evaluator, Evolver) continuously challenge your knowledge, identifying gaps before they become failures.

Website Paper License npm

# Install via npm (recommended)
npx memory-palace-red-queen

# Or via Skills CLI
npx skills add https://github.com/Algiras/memory-palace --skill memory-palace-red-queen

Key Results: 97% context reduction | 92% hallucination detection F1 | +23% retention with Red Queen pre-learning

Key Results

Memory Palace achieves state-of-the-art performance across multiple benchmarks:

vs. Commercial Embedding Systems (MTEB)

ModelNDCG@10ParametersContext LimitCost
Google Gecko66.3%1.2B2048$$$
Cohere embed-v465.2%~1B512$$
OpenAI text-embedding-3-large64.6%Unknown8191$$
Voyage-3-large63.8%Unknown32000$$
Memory Palace58.2%0UnlimitedFree

*BEIR Natural Questions benchmark. With SMASHIN encoding on domain corpora: 89% Recall@1

SOTA Comparison

vs. RAG Systems (BEIR Benchmark)

BEIR Comparison

MethodNQHotpotQAMS MARCOAvg NDCG@10
ColBERT52.4%59.3%40.0%50.6%
Contriever49.8%63.8%40.7%51.4%
GraphRAG55.7%64.3%41.2%53.7%
Memory Palace58.2%67.1%42.8%56.0%

Hallucination Detection

Hallucination Detection

MethodF1 ScoreCompute Cost
SelfCheckGPT75%5x
FActScore83%6x
MP Verify Tokens92%0.01x

Key Advantages for LLM Memory:

  • 97% context reduction: Hierarchical 2-hop retrieval vs flat RAG
  • 92% hallucination detection: Built-in verification tokens (F1 score)
  • Domain routing: Queries routed to relevant index partitions
  • Scalable: Handles large knowledge bases without context overflow

Red Queen Pre-Learning

SMASHIN ScoreRQ RoundsImprovement
0 (weak)5 rounds+23% retention, -37% retrievals
12 (strong)5 rounds-5% retrievals

Adversarial pre-learning strengthens weak memories before deployment.

Method Comparison

Method Comparison Radar

Retrieval Comparison

Memory Palace outperforms traditional methods across all key metrics:

  • Retrieval Accuracy: 89% Recall@1 vs 72% for flat RAG
  • Context Efficiency: 97% reduction in context window usage
  • Hallucination Detection: F1=0.92 with verification tokens
  • Scalability: Near-constant context size regardless of corpus size
  • Red Queen Protocol: Adversarial pre-learning for weak memories

Context Efficiency

Context Scaling

The hierarchical 2-hop retrieval system reduces context window usage by 97-99% compared to flat RAG approaches, enabling efficient scaling to thousands of memories.

Red Queen Pre-Learning

Red Queen Ablation

The Red Queen Protocol provides adversarial pre-learning to strengthen weak memories:

  • Weak encodings (SMASHIN=0): 37% fewer retrievals with 5 RQ rounds
  • Strong encodings (SMASHIN=12): Already resilient, marginal benefit

Red Queen Interaction

SMASHIN SCOPE Encoding

SMASHIN SCOPE Effect

The SMASHIN SCOPE mnemonic encoding system creates memorable, multi-channel representations:

  • Substitute, Movement, Absurd, Sensory, Humor, Interact, Numbers
  • Symbols, Color, Oversize, Position, Emotion

Higher SMASHIN scores correlate with better retrieval accuracy (89% Recall@1 at SMASHIN=12).

Quick Start

# Create a palace
/memory-palace create "TypeScript Mastery" "Ancient Library"

# Store information
/memory-palace store "generics"

# Recall with semantic search
/memory-palace recall

# Run adversarial testing
/memory-palace red-queen weak-spots

Architecture

System Architecture

~/memory/
├── config.json              # System configuration
├── global/                  # Cross-project knowledge
│   ├── palace-registry.json
│   ├── meta-index.md
│   └── *.json               # Palaces
└── project/{id}/            # Project-specific knowledge

Red Queen Protocol

"It takes all the running you can do, to keep in the same place." — The Red Queen, Through the Looking-Glass (Lewis Carroll)

Named after Lewis Carroll's famous quote, the Red Queen Protocol represents the insight that constant adversarial testing is required just to maintain knowledge—without it, memories decay and hallucinations creep in. Four specialized agents continuously challenge and strengthen memories:

                    PRE-LEARNING PHASE
                    ┌─────────────────┐
                    │  Red Queen      │
                    │  Rounds (0-5)   │
                    │  ↓              │
                    │  Test → Boost   │
                    │  weak memories  │
                    └────────┬────────┘
                             │
                    RUNTIME PHASE
┌─────────────┐     ┌─────────────┐     ┌─────────────┐
│  EXAMINER   │────►│   LEARNER   │────►│  EVALUATOR  │
│  (haiku)    │     │   (haiku)   │     │   (haiku)   │
│ Generate Qs │     │ Blind recall│     │ Score gaps  │
└─────────────┘     └─────────────┘     └──────┬──────┘
                                               │
                                               ▼
                                        ┌─────────────┐
                                        │   EVOLVER   │
                                        │   (opus)    │
                                        │ Strengthen  │
                                        └─────────────┘

Pre-learning: Run --red-queen-rounds 5 to strengthen weak memories before deployment.

Commands

CommandDescription
/memory-palace create <name>Create a new memory palace
/memory-palace store <topic>Store a memory in current palace
/memory-palace recall [topic]Walk through with semantic search
/memory-palace define <concept>Instant one-sentence lookup
/memory-palace navigateCross-palace exploration with heat maps
/memory-palace red-queenRun adversarial recall testing
/memory-palace interviewTimed rapid-fire Q&A mode
/memory-palace statusShow memory statistics

Installation

The skill starts completely empty - you build your own palaces from scratch.

Quick Install (Skills CLI)

The easiest way to install Memory Palace is using the Skills CLI:

# Install the skill directly from GitHub
npx skills add https://github.com/Algiras/memory-palace --skill memory-palace-red-queen

# Verify installation
/memory-palace status

Finding Other Skills

Use the Skills CLI to discover and install other agent skills:

# Search for skills by keyword
npx skills find react performance
npx skills find testing

# Install a specific skill
npx skills add <owner>/<repo>@<skill-name> -g -y

# Check for updates
npx skills check

# Update all installed skills
npx skills update

Browse available skills at: skills.sh

Prerequisites (Manual Install)

  • Claude Code installed and configured
  • Git for cloning the repository
  • Node.js (optional, for development)
# 1. Clone the repository
git clone https://github.com/Algiras/memory-palace.git
cd memory-palace

# 2. Copy skill files to Claude Code skills directory
mkdir -p ~/.claude/skills/memory-palace-red-queen
cp -r skills/memory-palace-red-queen/* ~/.claude/skills/memory-palace-red-queen/

# 3. Create storage directories
mkdir -p ~/memory/global ~/memory/project

# 4. Verify installation
ls ~/.claude/skills/memory-palace-red-queen/
# Should show: README.md, SKILL.md, commands/, subagents/, etc.
# Clone the repository
git clone https://github.com/Algiras/memory-palace.git
cd memory-palace

# Create symlink for easy updates
ln -s $(pwd)/skills/memory-palace-red-queen ~/.claude/skills/memory-palace-red-queen

# Create storage directories
mkdir -p ~/memory/global ~/memory/project

Method 3: Manual Installation

  • Download the repository: git clone https://github.com/Algiras/memory-palace.git
  • Copy the skills/memory-palace-red-queen/ folder contents
  • Paste into ~/.claude/skills/memory-palace-red-queen/ (create if doesn't exist)
  • Create ~/memory/global and ~/memory/project directories

Verify Installation

Open Claude Code and run:

/memory-palace status

You should see a message like:

🏛️ Memory Palace Status
📊 0 memories | 0 palaces | Storage: ~/memory/
✅ Skill active and ready

Create Your First Palace

# Create a palace
/memory-palace create "My First Palace" "Ancient Library"

# Store your first memory
/memory-palace store "important concept"
# Follow the prompts to create a vivid mental image

# Recall your memories
/memory-palace recall

# Run adversarial testing
/memory-palace red-queen weak-spots

Uninstallation

# Remove the skill
rm -rf ~/.claude/skills/memory-palace-red-queen

# Optional: Remove stored memories (backup first!)
rm -rf ~/memory/

Benchmarks

Run LLM retrieval benchmarks with Gemini or Ollama models on standard QA datasets:

cd paper/code
python -m venv .venv
source .venv/bin/activate
pip install numpy pandas plotly kaleido datasets google-generativeai

# Standard QA benchmark on SQuAD (local Ollama)
python standard_benchmark.py --backend ollama --dataset squad --samples 100

# Standard QA benchmark on SQuAD (Gemini API)
# Add GEMINI_API_KEY to .env
python standard_benchmark.py --backend gemini --dataset squad --samples 100

# TriviaQA benchmark
python standard_benchmark.py --backend ollama --dataset triviaqa --samples 100

# Memory Palace retrieval benchmark
python ollama_benchmark.py

# Gemini API benchmark
python gemini_benchmark.py

# Generate visualizations (including Red Queen charts)
python visualize_plotly.py

Datasets Used

DatasetTypeSizeReference
SQuAD 2.0Reading Comprehension100k+ QA pairsStanford
TriviaQAOpen-domain QA95k QA pairsUniversity of Washington
Natural QuestionsSearch QA300k+ queriesGoogle

Models Supported

BackendEmbedding ModelLLMLocal/Cloud
Ollamanomic-embed-textministral-3:8bLocal
Geminiembedding-001gemini-proCloud (API)

Red Queen Pre-Learning

# Run benchmarks with Red Queen pre-learning rounds
cd paper/code
source .venv/bin/activate
python legacy/run_benchmarks.py --red-queen-rounds 5

Documentation

Evolution History

Scientific testing of 11 hypotheses using the Red Queen adversarial protocol:

EvolutionStatusKey Result
001: SQLite Backend✅ Accepted10-100x speedup, ACID transactions
002: Semantic Search✅ Accepted85% top-5 precision with 1536d embeddings
003: Hook System❌ Rejected8% gain not worth 7.35/10 annoyance
004: Spaced Repetition✅ AcceptedFibonacci intervals: 86% vs 19% retention (+66%)
005: Palace Architecture✅ AcceptedHierarchical chunking: 100+ loci, 100% navigation
006: Export/Import✅ AcceptedMulti-format: Anki, Markdown, JSON, Gists
007: Subagents✅ Accepted4 specialized agents, +25% code clarity
008: Gamification◐ HybridAdaptive: beginners get gamification, experts get utility
009: Red Queen Pre-Learning✅ Accepted-37% retrievals, +23% retention for weak memories
010: Hierarchical LLM Retrieval✅ Accepted97% context reduction, 89% Recall@1
011: Verification Tokens✅ AcceptedF1=0.92 hallucination detection, 600× cheaper

Skill Fitness: 99% (11/11 evolutions tested, 10 core tests passing)

See evolutions/ or online evolution history for full details.

Research

This project explores the intersection of:

  • Hierarchical Retrieval: 2-hop routing reduces context by 97% vs flat RAG
  • Verification Tokens: Embedded anti-hallucination markers (F1=0.92)
  • SMASHIN SCOPE Encoding: 12-factor framework for memorable knowledge representations
  • Red Queen Protocol: Adversarial pre-learning strengthens weak memories by 37%
  • Method of Loci: Ancient mnemonic principles applied to LLM memory architecture

License

MIT License - See LICENSE for details.

Keywords

claude

FAQs

Package last updated on 01 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts