code-refactoring-context-restore
Use when working with code refactoring context restore
About this skill
The `code-refactoring-context-restore` skill, part of the `antigravity-awesome-skills` collection, is designed to empower AI agents with robust capabilities for managing and re-establishing context during intricate code refactoring operations. It focuses on 'Advanced Semantic Memory Rehydration,' meaning it helps the agent intelligently recall and synthesize previously established code understanding, architectural context, and refactoring goals, even after interruptions or across multi-turn interactions. This skill provides an AI agent with the framework, best practices, and actionable guidance to maintain a consistent and accurate understanding of a codebase, preventing context loss that can lead to errors or inefficiencies in complex development workflows. It is particularly valuable for agents working on large-scale refactorings where maintaining a long-term, deep understanding is crucial.
Best use case
Ensuring an AI agent accurately maintains and restores relevant context during complex code refactoring operations, particularly when dealing with long or fragmented sessions, to prevent loss of understanding and improve refactoring quality.
Use when working with code refactoring context restore
Improved accuracy and consistency in code refactoring outputs, better continuity and coherence in multi-turn agent interactions, reduced errors stemming from lost context, more contextually aware and relevant refactoring suggestions, and adherence to best practices for managing an AI agent's understanding of a complex codebase during development.
Practical example
Example input
I've been working on refactoring the `OrderProcessingService` to make it more modular, specifically separating out the payment gateway integration. I had to stop midway yesterday. Can you use the `code-refactoring-context-restore` skill to help me re-establish the full context of this ongoing refactoring? I need to remember the current state, the original structure, the refactoring goals, and the next logical steps for implementing the `Stripe` payment gateway.
Example output
Certainly! Using the `code-refactoring-context-restore` skill, I will guide you through re-establishing the full context for your `OrderProcessingService` refactoring: 1. **Summarize Current Refactoring State**: I will review our previous interactions, any generated diffs, and your version control history to outline the exact changes made to `OrderProcessingService` so far, specifically regarding modularity and payment gateway preparation. 2. **Identify Original & Target Structure**: I will present a side-by-side view (or description) of the original `OrderProcessingService` structure and the envisioned modular structure, highlighting the separation of payment concerns. 3. **Reiterate Refactoring Goals**: I will confirm the primary goals for the refactoring: improved modularity, better separation of concerns, and readiness for `Stripe` integration, ensuring scalability and maintainability. 4. **Contextual Checklist**: I will provide a checklist to validate the restored context, including: verifying relevant file changes, understanding the API interactions with `Stripe`, and reviewing any pending unit tests. 5. **Proposed Next Actionable Steps**: Based on the re-established context, I recommend focusing on creating a new `StripePaymentGateway` class, defining its interface, and integrating it into the `OrderProcessingService` via dependency injection. We can start by outlining the `Stripe` API calls required. Are you ready to proceed with these steps, or would you like to refine the current understanding further?
When to use this skill
- When an AI agent needs to resume a code refactoring task after a significant pause or interruption.
- During multi-turn or iterative code refactoring sessions where the agent must maintain a deep understanding of the evolving codebase.
- When integrating new code or features into an existing refactored section, requiring a fresh re-establishment of the current context.
- When the agent requires guidance, best practices, or a checklist for effectively managing its semantic memory during code transformation tasks.
When not to use this skill
- When the task is a simple, single-turn code generation or analysis operation that does not require long-term context retention.
- When the primary goal is not related to code refactoring or context management within a coding task.
- When an external tool or domain-specific functionality (e.g., a specific linter or build system) is needed, rather than an internal context-management strategy.
- For tasks completely unrelated to code development or semantic memory rehydration.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/code-refactoring-context-restore/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How code-refactoring-context-restore Compares
| Feature / Agent | code-refactoring-context-restore | Standard Approach |
|---|---|---|
| Platform Support | Claude | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | medium | N/A |
Frequently Asked Questions
What does this skill do?
Use when working with code refactoring context restore
Which AI agents support this skill?
This skill is designed for Claude.
How difficult is it to install?
The installation complexity is rated as medium. You can find the installation instructions above.
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.
Related Guides
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
ChatGPT vs Claude for Agent Skills
Compare ChatGPT and Claude for AI agent skills across coding, writing, research, and reusable workflow execution.
SKILL.md Source
# Context Restoration: Advanced Semantic Memory Rehydration
## Use this skill when
- Working on context restoration: advanced semantic memory rehydration tasks or workflows
- Needing guidance, best practices, or checklists for context restoration: advanced semantic memory rehydration
## Do not use this skill when
- The task is unrelated to context restoration: advanced semantic memory rehydration
- You need a different domain or tool outside this scope
## Instructions
- Clarify goals, constraints, and required inputs.
- Apply relevant best practices and validate outcomes.
- Provide actionable steps and verification.
- If detailed examples are required, open `resources/implementation-playbook.md`.
## 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 strategiesRelated Skills
data-structure-protocol
Give agents persistent structural memory of a codebase — navigate dependencies, track public APIs, and understand why connections exist without re-reading the whole repo.
codex-review
Professional code review with auto CHANGELOG generation, integrated with Codex AI. Use when you want professional code review before commits, you need automatic CHANGELOG generation, or reviewing large-scale refactoring.
code-review-checklist
Comprehensive checklist for conducting thorough code reviews covering functionality, security, performance, and maintainability
code-documentation-code-explain
You are a code education expert specializing in explaining complex code through clear narratives, visual diagrams, and step-by-step breakdowns. Transform difficult concepts into understandable explanations for developers at all levels.
c4-architecture-c4-architecture
Generate comprehensive C4 architecture documentation for an existing repository/codebase using a bottom-up analysis approach.
hig-project-context
Create or update a shared Apple design context document that other HIG skills use to tailor guidance.
filesystem-context
Use for file-based context management, dynamic context discovery, and reducing context window bloat. Offload context to files for just-in-time loading.
ddd-context-mapping
Map relationships between bounded contexts and define integration contracts using DDD context mapping patterns.
context7-auto-research
Automatically fetch latest library/framework documentation for Claude Code via Context7 API. Use when you need up-to-date documentation for libraries and frameworks or asking about React, Next.js, Prisma, or any other popular library.
context-optimization
Context optimization extends the effective capacity of limited context windows through strategic compression, masking, caching, and partitioning. The goal is not to magically increase context windows but to make better use of available capacity.
context-management-context-save
Use when working with context management context save
context-management-context-restore
Use when working with context management context restore