session-guard
Use when working on complex multi-step tasks, when a session is getting long (40+ tool calls), when the agent starts ignoring rules it followed earlier, when conventions drift, when output quality seems to degrade, or after any context compaction event. Prevents long-session corruption AND context compaction amnesia through behavioral self-enforcement.
npx skills add wshobson/agents --skill session-guard --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# Session Guard ## Overview Long sessions corrupt silently. Context compaction drops instructions unannounced. Hooks don't fix it (confirmed by multiple developers on GitHub issues #19471, #9796, #64171). This skill prevents both through behavioral self-enforcement: monitor health, anchor critical rules through compaction, split before damage occurs. No packages, no databases - pure behavioral enforcement that works in every harness. ## When to Use - Session exceeds 40 tool calls - Agent contradicts earlier decisions - Style/naming conventions start drifting - After any context compaction event - Task scope growing unbounded ## Health Signals | Signal | Threshold | Action | |--------|-----------|--------| | Tool call count | >40 | YELLOW: checkpoint + recite critical rules | | Tool call count | >60 | RED: split or compact with anchor | | Agent contradicts earlier decision | Any | VERIFY: re-read source of truth | | Style/naming drift | Any | RECITE: state the active rules aloud | | File read returns unexpected content | Any | RE-READ: don't trust cached state | | Task scope growing unbounded | Continuous | SPLIT: one task per session | ## Protocol ### Green Zone (0-40 tool calls) N
- Overview
- When to Use
- Health Signals
- Protocol
- Green Zone (0-40 tool calls)
- Yellow Zone (40-60 tool calls)
- Red Zone (60+ tool calls OR drift signal)
- Context Anchoring (anti-compaction)
- What survives compaction:
- What gets LOST in compaction:
- Compaction-Safe Pattern
- Common Mistakes
- Why This Matters
What does the session-guard skill do?
Use when working on complex multi-step tasks, when a session is getting long (40+ tool calls), when the agent starts ignoring rules it followed earlier, when conventions drift, when output quality seems to degrade, or after any context compaction event. Prevents long-session corruption AND context compaction amnesia through behavioral self-enforcement.
How do I install it?
Run `npx skills add wshobson/agents --skill session-guard --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From wshobson/agents, a repository with 38,479 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.