Skip to main content
command CX Codex

context-restore — Claude Code command: restore project context

Brings back saved project context and decisions so you can resume a session without re-explaining the task.

Install into Claude Code · Plugin marketplace All methods and platforms ↓
/plugin marketplace add wshobson/agents
/plugin install code-refactoring@claude-code-workflows
Open on GitHub

What context-restore does

context-restore pulls up a previously saved project state: the overview, architectural decisions, tech stack, recent agent work and known issues. Retrieval is semantic, so you describe what you need instead of digging through files.

The command takes four arguments: context_source (where the context lives), project_identifier (the project namespace), restoration_mode (full, incremental or diff) and token_budget. The token budget defaults to 8192 and the relevance threshold to 0.75. Components load in priority order until the budget runs out, so on a large project some context will not make it into the session. Worth tuning token_budget for the task at hand.

The spec covers three-way merge for conflicting context versions and integrity checks. Two workflows ship with it: resuming a project with the context validated against the current codebase, and moving knowledge from one project to another.

What it helps with

  • resume a project after a break
  • merge two saved versions of context
  • find a context fragment by meaning
  • move knowledge from one project to another
  • fit context restoration into a token limit

Example prompts for the agent

  • /context-restore project:ai-assistant --mode full
  • /context-restore project:web-platform --mode incremental
  • /context-restore project:ml-pipeline --query "model training strategy"

How to install context-restore

1Plugin marketplace

/plugin marketplace add wshobson/agents
/plugin install code-refactoring@claude-code-workflows

2Manually: put the files in place

.claude/commands/context-restore.md

Call it with /context-restore. For all projects use ~/.claude/commands/

Questions about context-restore

How do I install context-restore in Claude?

Add the marketplace: /plugin marketplace add wshobson/agents. Then install the plugin: /plugin install code-refactoring@claude-code-workflows. The command file lands in .claude/commands/context-restore.md.

What does context-restore do?

It retrieves saved project context and decisions so a session can continue where it left off. It supports full restoration, partial updates and comparing context versions.

What do I pass when running it?

A context source, a project identifier and a restoration mode. The token budget defaults to 8192 and the semantic similarity threshold to 0.75.

Source text

context-restore.md · MIT
---
description: Restore saved project context and decisions to resume a session
---

# Context Restoration: Advanced Semantic Memory Rehydration

## Role Statement

Expert Context Restoration Specialist focused on intelligent, semantic-aware context retrieval and reconstruction across complex multi-agent AI workflows. Specializes in preserving and reconstructing project knowledge with high fidelity and minimal information loss.

## Context Overview

The Context Restoration tool is a sophisticated memory management system designed to:

- Recover and reconstruct project context across distributed AI workflows
- Enable seamless continuity in complex, long-running projects
- Provide intelligent, semantically-aware context rehydration
- Maintain historical knowledge integrity and decision traceability

## Core Requirements and Arguments

### Input Parameters

- `context_source`: Primary context storage location (vector database, file system)
- `project_identifier`: Unique project namespace
- `restoration_mode`:
  - `full`: Complete context restoration
  - `incremental`: Partial context update
  - `diff`: Compare and merge context versions
- `token_budget`: Maximum context tokens to restore (default: 8192)
- `relevance_threshold`: Semantic similarity cutoff for context components (default: 0.75)

## Advanced Context Retrieval Strategies

### 1. Semantic Vector Search

- Utilize multi-dimensional embedding models for context retrieval
- Employ cosine similarity and vector clustering techniques
- Support multi-modal embedding (text, code, architectural diagrams)

```python
def semantic_context_retrieve(project_id, query_vector, top_k=5):
    """Semantically retrieve most relevant context vectors"""
    vector_db = VectorDatabase(project_id)
    matching_contexts = vector_db.search(
        query_vector,
        similarity_threshold=0.75,
        max_results=top_k
    )
    return rank_and_filter_contexts(matching_contexts)
```

### 2. Relevance Filtering and Ranking

- Implement multi-stage relevance scoring
- Consider temporal decay, semantic similarity, and historical impact
- Dynamic weighting of context components

```python
def rank_context_components(contexts, current_state):
    """Rank context components based on multiple relevance signals"""
    ranked_contexts = []
    for context in contexts:
        relevance_score = calculate_composite_score(
            semantic_similarity=context.semantic_score,
            temporal_relevance=context.age_factor,
            historical_impact=context.decision_weight
        )
        ranked_contexts.append((context, relevance_score))

    return sorted(ranked_contexts, key=lambda x: x[1], reverse=True)
```

### 3. Context Rehydration Patterns

- Implement incremental context loading
- Support partial and full context reconstruction
- Manage token budgets dynamically

```python
def rehydrate_context(project_context, token_budget=8192):
    """Intelligent context rehydration with token budget management"""
    context_components = [
        'project_overview',
        'architectural_decisions',
        'technology_stack',
        'recent_agent_work',
        'known_issues'
    ]

    prioritized_components = prioritize_components(context_components)
    restored_context = {}

    current_tokens = 0
    for component in prioritized_components:
        component_tokens = estimate_tokens(component)
        if current_tokens + component_tokens <= token_budget:
            restored_context[component] = load_component(component)
            current_tokens += component_tokens

    return restored_context
```

### 4. Session State Reconstruction

- Reconstruct agent workflow state
- Preserve decision trails and reasoning contexts
- Support multi-agent collaboration history

### 5. Context Merging and Conflict Resolution

- Implement three-way merge strategies
- Detect and resolve semantic conflicts
- Maintain provenance and decision traceability

### 6. Incremental Context Loading

- Support lazy loading of context components
- Implement context streaming for large projects
- Enable dynamic context expansion

### 7. Context Validation and Integrity Checks

- Cryptographic context signatures
- Semantic consistency verification
- Version compatibility checks

### 8. Performance Optimization

- Implement efficient caching mechanisms
- Use probabilistic data structures for context indexing
- Optimize vector search algorithms

## Reference Workflows

### Workflow 1: Project Resumption

1. Retrieve most recent project context
2. Validate context against current codebase
3. Selectively restore relevant components
4. Generate resumption summary

### Workflow 2: Cross-Project Knowledge Transfer

1. Extract semantic vectors from source project
2. Map and transfer relevant knowledge
3. Adapt context to target project's domain
4. Validate knowledge transferability

## Usage Examples

```bash
# Full context restoration
context-restore project:ai-assistant --mode full

# Incremental context update
context-restore project:web-platform --mode incremental

# Semantic context query
context-restore project:ml-pipeline --query "model training strategy"
```

## Integration Patterns

- RAG (Retrieval Augmented Generation) pipelines
- Multi-agent workflow coordination
- Continuous learning systems
- Enterprise knowledge management

## Future Roadmap

- Enhanced multi-modal embedding support
- Quantum-inspired vector search algorithms
- Self-healing context reconstruction
- Adaptive learning context strategies

© Seth Hobson · MIT · wshobson/agents

Similar slash commands

All slash commands for Agent setup: memory, context, orchestration →

From the same set342

The whole set →
new-track A slash command from the conductor plugin: it interviews you, writes a track specification, then breaks the work into phases with tasks. CX Codex ★ 41,729repo stars conductor-validator A subagent that checks Conductor project files for completeness and consistency. Useful right after setup and before implementation. CX Codex ★ 41,729repo stars comprehensive-review-security-auditor A security-auditor subagent that checks code and infrastructure for vulnerabilities and helps with DevSecOps and GDPR, HIPAA, SOC 2 compliance. CX Codex ★ 41,729repo stars codebase-cleanup-test-automator A testing subagent that runs the TDD loop, writes tests and wires them into CI. Useful when coverage is thin or failures keep repeating. CX Codex ★ 41,729repo stars code-explain This command explains complex code, algorithms and design patterns with step-by-step breakdowns, Mermaid diagrams and examples. Handy when you inherit unfamiliar code. CX Codex ★ 41,729repo stars code-documentation-code-reviewer A code review subagent that hunts for vulnerabilities, performance bottlenecks and configuration mistakes. Useful when changes head to production and you want a second pass. CX Codex ★ 41,729repo stars cicd-automation-kubernetes-architect A Kubernetes architect subagent: cluster design, GitOps pipelines, service mesh and multi-tenancy. Useful once a project outgrows a single namespace. CX Codex ★ 41,729repo stars cicd-automation-cloud-architect A cloud architect subagent for AWS, Azure, GCP and OCI: designs infrastructure, estimates cost and writes IaC. CX Codex ★ 41,729repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor