Skip to main content

/cx-recall - Context Recall (RAG Retrieval)

Automatically retrieve relevant context from session history to prevent catastrophic forgetting. Combines semantic search with extracted knowledge (decisions, patterns, error solutions).

Usage

# Recall context for a topic
/cx-recall "database migrations"
/cx-recall "authentication implementation"
/cx-recall "TypeScript patterns"

# JSON output for programmatic use
/cx-recall "query" --json

# Adjust result limits
/cx-recall "topic" --limit 10

System Prompt

System Prompt

⚠️ EXECUTION DIRECTIVE: When the user invokes this command, you MUST:

  1. IMMEDIATELY execute - no questions, no explanations first
  2. ALWAYS show full output from script/tool execution
  3. ALWAYS provide summary after execution completes

DO NOT:

  • Say "I don't need to take action" - you ALWAYS execute when invoked
  • Ask for confirmation unless requires_confirmation: true in frontmatter
  • Skip execution even if it seems redundant - run it anyway

The user invoking the command IS the confirmation.


You are retrieving relevant context from the CODITECT memory system to prevent catastrophic forgetting.

Database: context-storage/sessions.db + org.db (ADR-118) (SQLite with FTS5 + Embeddings)

Execute the context recall:

python3 scripts/context-db.py --recall "$ARGS"

First-time setup: If no knowledge extracted, run /cxq --extract first.

Output includes:

  • Semantically similar messages (or FTS if embeddings not available)
  • Related architectural/technical decisions
  • Related code patterns by language/type
  • Related error-solution pairs

Quick Reference

CommandDescription
/cx-recall "topic"Recall context for topic
/cx-recall "topic" --jsonJSON output
/cx-recall "topic" --limit 10Adjust result count

Examples

Basic Recall

/cx-recall "git workflow"           # Recall git-related context
/cx-recall "API authentication" # Auth patterns and decisions
/cx-recall "error handling" # Error patterns and solutions

Integration with Current Work

# Before starting new work, recall relevant context:
/cx-recall "feature I'm implementing"

# During debugging, recall similar errors:
/cx-recall "TypeError in component"

# When making decisions, check previous decisions:
/cx-recall "technology choice for X"

What Gets Retrieved

Messages

Relevant messages from session history, ranked by:

  • Semantic similarity (if embeddings available)
  • Full-text search relevance (FTS5 fallback)

Decisions

Extracted decisions with:

  • Decision type (architecture, technology, api, database, testing, deployment, security)
  • Confidence score
  • Rationale (when available)

Code Patterns

Extracted code patterns with:

  • Language (python, typescript, rust, etc.)
  • Pattern type (test, async, class, error_handling, database, api)
  • Usage count

Error Solutions

Error-fix pairs with:

  • Error type and signature
  • Solution description
  • Solution code (when available)
  • Success count

Building the Knowledge Base

# 1. Extract all sessions first
/cx

# 2. Index into database
/cxq --index

# 3. Extract knowledge (decisions, patterns, errors)
/cxq --extract

# 4. (Optional) Generate embeddings for semantic search
/cxq --embeddings

# 5. Now recall context
/cx-recall "your topic"

Workflow Integration

At Session Start

/cx-recall "project or feature name"
# Review relevant context before starting work

During Development

# When encountering errors:
/cx-recall "error message or type"

# When making architectural decisions:
/cx-recall "pattern or technology name"

At Session End

/export              # Export current session
/cx # Extract and archive
/cxq --extract # Update knowledge base

Anti-Forgetting Benefits

  1. Context Continuity: Recall previous session context instantly
  2. Decision Consistency: Access previous architectural decisions
  3. Pattern Reuse: Find and reuse proven code patterns
  4. Error Prevention: Learn from previous error solutions
  5. Knowledge Preservation: Nothing gets lost between sessions

Success Output

When context recall completes:

✅ COMMAND COMPLETE: /cx-recall
Query: <search-topic>
Messages: N relevant
Decisions: N related
Patterns: N matched
Error Solutions: N found

Completion Checklist

Before marking complete:

  • Query executed
  • Results retrieved
  • Context displayed
  • Related items shown

Failure Indicators

This command has FAILED if:

  • ❌ Database not found
  • ❌ No query provided
  • ❌ Search failed
  • ❌ No output displayed

When NOT to Use

Do NOT use when:

  • No knowledge base exists (run /cxq --extract first)
  • Fresh session with no history
  • Unrelated topic query

Anti-Patterns (Avoid)

Anti-PatternProblemSolution
Skip knowledge extractionNo data to recallRun /cxq --extract
Vague queriesPoor resultsBe specific
Ignore resultsLost contextReview and apply

Principles

This command embodies:

  • #2 Search Before Create - Find existing knowledge
  • #9 Based on Facts - Retrieve documented context
  • #6 Clear, Understandable - Organized results

Full Standard: CODITECT-STANDARD-AUTOMATION.md


Script: scripts/context-db.py --recall Database: context-storage/sessions.db + org.db (ADR-118) Version: 1.0.0 Last Updated: 2025-12-10