Skill

Preserve Critical Context Before Compression

Context Guardian preserves critical session data before Claude Code's automatic context compaction, using priority-classified extraction and redundant


91
Spark score
out of 100
Updated 29 days ago
Version 14.1.0
Models
claude

Add to Favorites

Why it matters

Safeguard vital project information from automatic context compression in large technical projects. This skill ensures no critical details are lost during Claude Code's summarization process, preventing regressions and rework.

Outcomes

What it gets done

01

Detect and extract critical data (decisions, fixes, code changes, errors) before context window limits are reached.

02

Perform integrity checks to ensure no vital information is omitted during extraction.

03

Persist extracted information redundantly across multiple layers (snapshot file, MEMORY.md, context-agent).

04

Generate a transition briefing to summarize session state for continuity after compression.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/ag-context-guardian | bash

Overview

Context Guardian

Context Guardian detects approaching Claude Code context compaction and runs a four-phase protocol (extraction, verification, redundant persistence, transition briefing) to preserve critical technical decisions, fixes, and task state before automatic summarization loses detail. Use it when context usage nears 60-70% of the window, during heavy multi-file technical sessions, or before a task expected to generate extensive output - complementary to context-agent's post-session persistence, not a replacement for it.

What it does

Context Guardian is a context-integrity system that protects complex technical projects from information loss during Claude Code's automatic context compaction. It complements a related context-agent skill: while context-agent acts after sessions (save/load), context-guardian acts during the session, detecting when compaction is approaching and executing preservation protocols with redundant verification before the automatic, heuristic summarization destroys detail. This matters for heavy technical projects (ecosystems with 21+ skills, security audits, architecture refactors) where losing a single detail can cause regressions, rework, or serious inconsistencies.

It runs a four-phase protocol: structured extraction - scanning the conversation and classifying critical information by priority: P0/fatal-loss items preserved with triple redundancy (technical decisions with their rationale, task state - done/remaining/dependencies, applied bug fixes with root cause and affected files, exact code changes with file paths and line numbers, encountered errors with exact messages and resolutions, and commands that worked); P1/serious-loss items preserved with verification (discovered patterns/conventions, cross-component dependencies, user preferences, project context, open questions); and P2/tolerable-loss items as compact summaries (attempt history, progress metrics, exploratory discussion). Integrity verification, redundant persistence, and transition briefing generation follow, producing a structured handoff document covering current state, what was done this session, what remains, critical decisions (not to be changed without reason), applied fixes (not to be reverted), important file paths, alerts, and where to recover more information - plus a fast-path protocol for when time is short and a post-compaction completeness check.

Location: skills/context-guardian/
├── SKILL.md
├── references/extraction-protocol.md
├── references/verification-checklist.md
└── scripts/context_snapshot.py

When to use - and when NOT to

Activates automatically when context usage reaches roughly 60-70% of the window (compaction warnings, messages starting to be summarized), during heavy sessions with many edited files or complex cross-component dependencies, or before a task expected to generate extensive output. It can also be triggered manually with phrases like "save state before compacting," "make a checkpoint," or "snapshot the context." It is specifically for preserving critical technical detail before Claude Code's automatic compaction - not a general session-summary tool, and not a substitute for context-agent's after-session persistence.

Inputs and outputs

Input is the ongoing conversation/session content approaching a context-compaction threshold. Output is a verified, redundantly-stored snapshot plus a transition briefing document covering current state, completed/remaining work, critical decisions and applied fixes not to be reverted, important file paths, alerts, and pointers to where more detail can be recovered.

Integrations

Works alongside a companion context-agent skill (post-session persistence, MEMORY.md sync, FTS5 search indexing) and uses a context_snapshot.py script plus reference protocol documents for extraction and verification.

Who it's for

Developers running long, technically complex Claude Code sessions (multi-skill ecosystems, security audits, architecture refactors) who need to prevent critical detail loss when the context window approaches its automatic compaction limit.

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.