Session Guard
Unverified●30/40Claude Code◐PartialHas SKILL.md but declares no allowed-tools — Claude Code will ask for permission each time
Cursor◐PartialPlain prose you can paste in — but no Cursor rules file
Codex◐PartialPlain prose you can paste in — but no AGENTS.md
Gemini CLI◐PartialPlain prose you can paste in
Copilot◐PartialPlain prose you can paste in — but no Copilot instructions file
npx agentalley add session-guardWho is stuck, and on what
>- 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.
The whole source
Frontmatter — 2 properties
| name | session-guard |
|---|---|
| description | >- 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. |
| 1 | --- |
| 2 | name: session-guard |
| 3 | description: >- |
| 4 | Use when working on complex multi-step tasks, when a session is getting long |
| 5 | (40+ tool calls), when the agent starts ignoring rules it followed earlier, |
| 6 | when conventions drift, when output quality seems to degrade, or after any |
| 7 | context compaction event. Prevents long-session corruption AND context |
| 8 | compaction amnesia through behavioral self-enforcement. |
| 9 | ---A5 — No allowed-tools declared — no way to tell what this skill may touch |
| 10 | |
| 11 | # Session Guard |
| 12 | |
| 13 | ## Overview |
| 14 | |
| 15 | 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. |
| 16 | |
| 17 | ## When to Use |
| 18 | |
| 19 | - Session exceeds 40 tool calls |
| 20 | - Agent contradicts earlier decisions |
| 21 | - Style/naming conventions start drifting |
| 22 | - After any context compaction event |
| 23 | - Task scope growing unbounded |
| 24 | |
| 25 | ## Health Signals |
| 26 | |
| 27 | | Signal | Threshold | Action | |
| 28 | |--------|-----------|--------| |
| 29 | | Tool call count | >40 | YELLOW: checkpoint + recite critical rules | |
| 30 | | Tool call count | >60 | RED: split or compact with anchor | |
| 31 | | Agent contradicts earlier decision | Any | VERIFY: re-read source of truth | |
| 32 | | Style/naming drift | Any | RECITE: state the active rules aloud | |
| 33 | | File read returns unexpected content | Any | RE-READ: don't trust cached state | |
| 34 | | Task scope growing unbounded | Continuous | SPLIT: one task per session | |
| 35 | |
| 36 | ## Protocol |
| 37 | |
| 38 | ### Green Zone (0-40 tool calls) |
| 39 | Normal operation. No intervention needed. |
| 40 | |
| 41 | ### Yellow Zone (40-60 tool calls) |
| 42 | 1. CHECKPOINT - summarize progress in one paragraph |
| 43 | 2. RECITE - state the 3-5 most critical active rules aloud: "Active rules: [naming convention], [file structure], [error handling pattern], [testing requirement]" |
| 44 | 3. ASSESS - almost done? Push through. Not done? Prepare split. |
| 45 | 4. REDUCE - no exploratory reads. Only targeted operations. |
| 46 | |
| 47 | ### Red Zone (60+ tool calls OR drift signal) |
| 48 | 1. STOP - do not make more tool calls |
| 49 | 2. VERIFY - re-read project rules (don't trust memory) |
| 50 | 3. CHECKPOINT - write state to handoff document |
| 51 | 4. SPLIT - create handoff, suggest fresh session |
| 52 | |
| 53 | ## Context Anchoring (anti-compaction) |
| 54 | |
| 55 | When compaction has occurred (sudden loss of earlier context, or after /compact): |
| 56 | |
| 57 | 1. RE-READ the project's rules file immediately |
| 58 | 2. RECITE the 3-5 critical rules aloud in your response |
| 59 | 3. VERIFY your planned next action matches those rules before executing |
| 60 | 4. If uncertain about ANY prior decision, RE-READ the source file - don't guess |
| 61 | |
| 62 | ### What survives compaction: |
| 63 | - Most recent user messages (high priority) |
| 64 | - Currently-invoked skill body (capped at 5K tokens, oldest dropped first) |
| 65 | - Git status and project structure |
| 66 | - File contents read AFTER compaction |
| 67 | |
| 68 | ### What gets LOST in compaction: |
| 69 | - Decisions made early in conversation |
| 70 | - Architectural rules stated only verbally (not in files) |
| 71 | - Context from tool outputs (file reads, command outputs) |
| 72 | |
| 73 | ### Compaction-Safe Pattern |
| 74 | Keep critical instructions in FILES (CLAUDE.md, CONTEXT.md), NOT in conversation. If a rule matters, it must live in a file the agent can re-read - not in something agreed on earlier. |
| 75 | |
| 76 | ## Common Mistakes |
| 77 | |
| 78 | - Trusting that you remember the rules after 50+ tool calls (you don't - re-read) |
| 79 | - Re-reading EVERYTHING to be safe (wastes tool calls - be targeted) |
| 80 | - Feeling fine therefore assuming context is fine (compaction is SILENT) |
| 81 | - Splitting AFTER noticing problems (split BEFORE - prevention, not recovery) |
| 82 | |
| 83 | ## Why This Matters |
| 84 | |
| 85 | Context compaction is the #1 unsolved platform problem in 2026. Hooks don't fix it (confirmed: the agent ignores post-compaction injections because the compaction summary creates narrative momentum). This skill is the lightweight behavioral countermeasure: no infrastructure, no packages - disciplined self-monitoring that works in every harness. |
| 86 |
Reviews
Installed this one?Write the first review and take the Trailblazer badge.
Alternatives
Task Coordination StrategiesDecompose complex tasks, design dependency graphs, and coordinate multi-agent work with proper task descriptions and workload balancing. Use this skill when breaking down work for agent teams, managing task dependencies, or monitoring team progress.◐◐◐◐◐●35/40Ebay Seller Tools·····●34/40Tough Decision Advisor: Every Angle ConsideredHand in a decision you're stuck on. Get back a clear breakdown of every angle — the trade-offs, the risks, the blind spot, and a recommended path.●····●32/40DHDNA Profiler — Cognitive Pattern ExtractionPaste any email, proposal, or note someone wrote, and get back a plain-language read on how they think, what drives their decisions, and how they communicate.●····●32/40