From context-guard
Context budget zones and degradation detection for Context Guard. Trigger: "budget zone", "context budget", "am I degrading", "check context health", "zone status", "/cg-budget"
How this skill is triggered — by the user, by Claude, or both
Slash command
/context-guard:cg-budgetThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Adapt behavior based on estimated context consumption.
Adapt behavior based on estimated context consumption.
source "$HOME/.claude/hooks/compact-guard-lib.sh" 2>/dev/null
ZONE=$(cg_estimate_zone)
SESSION=$(cg_session_number)
SNAP_COUNT=$(cg_snapshot_count)
echo "Zone: $ZONE | Session: #$SESSION | Snapshots: $SNAP_COUNT"
| Zone | Context | Behavior |
|---|---|---|
| GREEN | < 60% | Full exploration. Read files, broad searches, no constraints. |
| YELLOW | 60-75% | Be selective. Prefer Grep over Read. Batch operations. Avoid re-reading files. |
| ORANGE | 75-85% | Conserve. Line ranges only. Delegate to subagents. Consider /cg-snapshot. |
| RED | > 85% | Wrap up. Complete only active task. Run /cg-snapshot. Suggest new session. |
GREEN: Work freely. Front-load research and exploration.
YELLOW:
ORANGE:
/cg-snapshot to save state preemptivelyRED:
/cg-snapshot to capture full stateWhen suspecting context degradation, run this mental checklist:
| Check | Question | If NO → |
|---|---|---|
| 1 | Projenin ana hedefini hatırlıyor muyum? | Stage 1+ |
| 2 | Bu oturumda hangi dosyaları değiştirdim? | Stage 2+ |
| 3 | Şu an düzenlediğim fonksiyonu tekrar okumadan tarif edebilir miyim? | Stage 2+ |
| 4 | Daha önce denediğim bir adımı tekrarlıyor muyum? | Stage 3 |
| 5 | Referans verdiğim API'ler/fonksiyonlar gerçekten var mı? | Stage 3 |
Stage 1 (Mild, ~60%): Detayları unutma, tekrar sorma. → Kritik dosyayı tekrar oku, plan özetle.
Stage 2 (Moderate, ~75%): Kararlarla çelişme, import eksikleri. → Durum özeti yaz, sadece aktif dosyaları oku, araştırmayı subagent'a delege et.
Stage 3 (Severe, ~85%): API hallucination, aynı fix'i tekrarlama.
→ Kodlamayı durdur. /cg-snapshot çalıştır. Kullanıcıya bildir.
Stage 4 (Critical, ~90%+): Tutarsız reasoning, anlamsız kod. → Hiçbir kod değişikliği yapma. State kaydet, oturumu kapat.
/cg-snapshot alnpx claudepluginhub jlceaser/context-guard --plugin context-guardAudits session context weight in Claude Code — estimates tokens from CLAUDE.md, agents, MCP descriptions, rules, skills, and conversation history, reports headroom, and alerts on overflow.
Preserves critical context data before Claude Code's automatic compaction using snapshots, integrity verification, and zero-loss extraction protocols for complex projects.
Monitors Claude Code context token usage and auto-triggers compaction at 65% via Bash hooks: snapshots transcripts, summarizes, restores state to prevent overload.