context-guardian

Prevents Claude Code context exhaustion and generates session recovery files from git state.

Updated Apr 5, 2026
One-click install
npx skills add https://github.com/Simon-YHKim/eject-button --skill context-guardian-simon-yhkim
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: context-guardian
Source: https://github.com/Simon-YHKim/eject-button/tree/main/.claude/skills/context-guardian
Command: npx skills add https://github.com/Simon-YHKim/eject-button --skill context-guardian-simon-yhkim

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve? Claude Code sessions slow down or disconnect when the context window fills up, losing in-progress work. This Skill prevents context exhaustion with project rules, monitors measured token limits, and captures recovery state so a new session can resume seamlessly. ## Core Features & Use Cases - Prevention mode: Installs a CLAUDE.md rule block (file-read limits, scope caps, 80/90% warning rules) and a .claudeignore file blocking node_modules, dist, .git, and other heavy paths. Idempotent via a marker comment. - Monitoring mode: Tracks measured context limits in context_limit_log.json with a configurable safety margin, and warns at 80% and 90% of the effective limit. Never hardcodes limits so model upgrades stay accurate. - Recovery mode: Generates SESSION_RECOVERY.md from git status, diff stats, branch, and .env.example variable names (values excluded), with an automatic secret-pattern scan that aborts on detected API keys or tokens. - Use Case: Mid-refactor your session hits 85% context. Run the recovery script, start a fresh session, paste the generated resume prompt, and continue from the first unfinished task without losing state. ## Quick Start Ask the agent to install context-guardian prevention rules into this project and create a session recovery file before the context limit is reached.

Frequently Asked Questions about context-guardian

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent Claude Code sessions from hitting the context limit?

Run the install-rules.sh script to append a Context Guardian rule block to CLAUDE.md and create a .claudeignore file. The rules cap edits at five files per session, block reads of node_modules and build directories, and trigger warnings at 80% and 90% of the measured limit.

How do I recover work after a Claude Code session disconnects?

Run create-recovery.sh before or after a disconnect to generate SESSION_RECOVERY.md with your branch, last commit, git status, and diff stats. Start a new session and paste the included resume prompt so the agent reads the file and continues from the first unfinished task.

What is the difference between context-guardian and the /checkpoint command?

The /checkpoint command unconditionally snapshots general work state, while context-guardian focuses on preventing context exhaustion and recovering after disconnects. They are complementary: use /checkpoint for mid-work saves and context-guardian for limit prevention and session continuity.

Does the recovery file store environment variable values or secrets?

No. The script extracts only variable names from .env.example, never values. It also scans the generated SESSION_RECOVERY.md for secret patterns like sk-, AKIA, ghp_, and xox tokens, and aborts with a warning if any are detected.

Why does the context limit log use measured values instead of hardcoded limits?

Model updates change the real context window size, so hardcoded limits go stale immediately. The update-context-log.sh script records measured limits per model in a history array and computes an effective limit using a 0.8 safety margin.

Is it safe to run the install script multiple times?

Yes. install-rules.sh is idempotent: it checks for the context-guardian-rules:v1 marker in CLAUDE.md and skips insertion if present, and it never overwrites an existing .claudeignore file.