By jlceaser
Defense in depth for Claude Code context. State preservation across compaction + security layer against prompt injection, context leakage, and unauthorized manipulation. Pure bash, zero dependencies.
Append a persistent dated note to a project-scoped topic file that survives context compaction and session restarts. Trigger: "/cg-annotate", "annotate", "save note", "save annotation"
Context budget zones and degradation detection for Context Guard. Trigger: "budget zone", "context budget", "am I degrading", "check context health", "zone status", "/cg-budget"
Show Context Guard health dashboard — snapshots, recovery state, and system status. Trigger: "context status", "guard status", "snapshot status", "context health", "check context guard", "/cg-context-status"
Retrieve annotations for a topic and load them into working context. Lists available topics when called without arguments. Trigger: "/cg-recall", "recall annotations", "load annotations", "show annotations"
Manually restore context from the latest Context Guard snapshot. Trigger: "restore context", "recover state", "what were we doing", "resume work", "load snapshot", "/cg-restore"
Uses power tools
Uses Bash, Write, or Edit tools
Own this plugin?
Verify ownership to unlock analytics, metadata editing, and a verified badge. GitHub access is read-only (username + org membership).
Sign in to claimOwn this plugin?
Verify ownership to unlock analytics, metadata editing, and a verified badge. GitHub access is read-only (username + org membership).
Sign in to claimBased on adoption, maintenance, documentation, and repository signals. Not a security audit or endorsement.
Defense in depth for Claude Code context.
State preservation + security layer against prompt injection, leakage, and manipulation.
When Claude Code hits ~95% context usage, it auto-compacts your conversation. You lose:
Context Guard captures your entire work environment — git state, actual code diffs, build health, worktrees, environment variables, and Claude's own memory — and automatically restores it after compaction.
Before: "Fix the auth bug in user-service.ts"
*edits 3 files, runs tests, debugging failing case*
--- COMPACTION ---
"I see we're working on a project. How can I help?"
After: --- COMPACTION ---
"Resuming: auth bug in user-service.ts, branch feat/auth-fix.
3 files modified (core:2, ui:1), tests failing on line 42.
Diff shows we added token validation but missed expiry check.
Continuing with the expiry logic..."
/plugin marketplace add jlceaser/context-guard
/plugin install context-guard@jlceaser
Restart Claude Code. That's it — hooks, skills, and agent are all active.
git clone https://github.com/jlceaser/context-guard.git
cd context-guard
bash install.sh # auto-configures settings.json via jq
bash test.sh # verify (31 tests)
bash <(curl -sL https://raw.githubusercontent.com/jlceaser/context-guard/main/install.sh)
Context at 80%
│
┌──────────▼──────────┐
│ PreCompact Hook │
│ ┌────────────────┐ │
│ │ Git state │ │
│ │ Code diffs │ │ ┌─────────────────┐
│ │ Build health │ │────▶│ Snapshot .md │
│ │ Worktrees │ │ │ + systemMessage │
│ │ Environment │ │ └────────┬────────┘
│ │ Claude memory │ │ │
│ └────────────────┘ │ │
└─────────────────────┘ │
▼
┌─────────────────────┐ ┌────────────────┐
│ --- COMPACTION --- │───▶│ systemMessage │
└─────────────────────┘ │ injected into │
│ compacted state │
┌─────────────────────┐ └────────┬───────┘
│ SessionStart Hook │◀────────────┘
│ Detects snapshot │
│ Injects recovery │──▶ Claude reads snapshot
└─────────────────────┘ and resumes work
Two-phase defense:
systemMessage — critical metadata (project, branch, dirty files) is injected directly into the compaction summary. This survives compaction and is immediately available.
Snapshot file — full state with code diffs is saved to disk. Claude reads this on the next turn to restore complete context.
Annotation Layer (v4.0.0):
/cg-annotate <topic> "note", retrieve with /cg-recall <topic>. Stored in ~/.claude/annotations/<project>/<topic>.md. Inspired by context-hub.New in v0.5.0 — Context Guard now includes a security layer that protects against prompt injection, credential leakage, and context manipulation.
npx claudepluginhub jlceaser/context-guard --plugin context-guardv9.44.1 — Patch release for Gemini environment/version detection and qwen auth gating. Run /octo:setup.
Harness-native ECC operator layer - 67 agents, 271 skills, 92 legacy command shims, reusable hooks, rules, selective install profiles, and production-ready workflows for Claude Code, Codex, OpenCode, Cursor, and related agent harnesses
Comprehensive skill pack with 66 specialized skills for full-stack developers: 12 language experts (Python, TypeScript, Go, Rust, C++, Swift, Kotlin, C#, PHP, Java, SQL, JavaScript), 10 backend frameworks, 6 frontend/mobile, plus infrastructure, DevOps, security, and testing. Features progressive disclosure architecture for 50% faster loading.
Binary reverse engineering, malware analysis, firmware security, and software protection research for authorized security research, CTF competitions, and defensive security
Upstash Context7 MCP server for up-to-date documentation lookup. Pull version-specific documentation and code examples directly from source repositories into your LLM context.
Comprehensive startup business analysis with market sizing (TAM/SAM/SOM), financial modeling, team planning, and strategic research