/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:
- IMMEDIATELY execute - no questions, no explanations first
- ALWAYS show full output from script/tool execution
- 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: truein 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
| Command | Description |
|---|---|
/cx-recall "topic" | Recall context for topic |
/cx-recall "topic" --json | JSON output |
/cx-recall "topic" --limit 10 | Adjust 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
- Context Continuity: Recall previous session context instantly
- Decision Consistency: Access previous architectural decisions
- Pattern Reuse: Find and reuse proven code patterns
- Error Prevention: Learn from previous error solutions
- 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-Pattern | Problem | Solution |
|---|---|---|
| Skip knowledge extraction | No data to recall | Run /cxq --extract |
| Vague queries | Poor results | Be specific |
| Ignore results | Lost context | Review 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