Session Guard
SkillProductivitySession Guard is a skill for AI agents that keeps long, multi-step work sessions reliable. It makes the agent watch its own behavior for signs of trouble, such as passing 40 tool calls, contradicting earlier decisions, or drifting from conventions, and then checkpoint progress, restate critical rules, and re-read source files instead of trusting memory. It also handles context compaction by re-reading rules files and keeping important instructions in files rather than in the conversation.
Then ask your AI: use the Session Guard skill
Details
Instructions available. Your AI can read the instructions. Execution depends on the setup they require.
Account requirements not reviewed. Check the skill instructions before use; Ahel provides instructions and does not run this skill.
No other account needed.
Have a project rules file that states your conventions and critical instructions.
What your AI can do with it
- Tracks tool call count and flags a yellow zone after 40 calls
- Flags a red zone after 60 calls or any drift signal
- Checkpoints progress in a paragraph or handoff document
- Recites the 3 to 5 most critical active rules aloud
- Re-reads project rules and source files after compaction
- Splits work into a fresh session when scope grows unbounded
Getting started
- Have a project rules file that states your conventions and critical instructions.
- Add the session-guard skill to your agent's available skills.
- Configure the agent to invoke the skill for complex multi-step tasks or long sessions.
- Keep critical instructions in files rather than only in the conversation.
- When the agent reports a yellow or red zone, follow its checkpoint and split guidance.
What this skill tells your AI
The instructions your AI receives, as published by wshobson/agents in plugins/skill-forge-essentials/skills/session-guard/SKILL.md and read by Ahel’s review.
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)
Normal operation. No intervention needed.
Yellow Zone (40-60 tool calls)
- CHECKPOINT - summarize progress in one paragraph
- RECITE - state the 3-5 most critical active rules aloud: "Active rules: [naming convention], [file structure], [error handling pattern], [testing requirement]"
- ASSESS - almost done? Push through. Not done? Prepare split.
- REDUCE - no exploratory reads. Only targeted operations.
Red Zone (60+ tool calls OR drift signal)
- STOP - do not make more tool calls
- VERIFY - re-read project rules (don't trust memory)
- CHECKPOINT - write state to handoff document
- SPLIT - create handoff, suggest fresh session
Context Anchoring (anti-compaction)
When compaction has occurred (sudden loss of earlier context, or after /compact):
- RE-READ the project's rules file immediately
- RECITE the 3-5 critical rules aloud in your response
- VERIFY your planned next action matches those rules before executing
- If uncertain about ANY prior decision, RE-READ the source file - don't guess
What survives compaction:
- Most recent user messages (high priority)
- Currently-invoked skill body (capped at 5K tokens, oldest dropped first)
- Git status and project structure
- File contents read AFTER compaction
What gets LOST in compaction:
- Decisions made early in conversation
- Architectural rules stated only verbally (not in files)
- Context from tool outputs (file reads, command outputs)
Compaction-Safe Pattern
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.
Common Mistakes
- Trusting that you remember the rules after 50+ tool calls (you don't - re-read)
- Re-reading EVERYTHING to be safe (wastes tool calls - be targeted)
- Feeling fine therefore assuming context is fine (compaction is SILENT)
- Splitting AFTER noticing problems (split BEFORE - prevention, not recovery)
Why This Matters
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.
Signals
- GitHub stars
- 40k
- Forks
- 4k
- Last commit
- Oct 2026
Questions
- Does it work with hooks?
- It does not rely on hooks. The skill states that hooks do not fix long-session corruption or compaction amnesia, and it uses behavioral self-enforcement instead, so it works in every harness.
- What happens after context compaction?
- The agent re-reads the project rules file, recites the 3 to 5 critical rules aloud, verifies its next action against them, and re-reads source files when uncertain about any prior decision.
Advanced
- Item type
- skill
- Key
session-guard- Source
- github.com/wshobson/agents
Related picks
Skill · jabrena
The pick for GitHub Issuesgithub-issues
Skill · graniet
The pick for GitHub Issuessocial
Skill · coreyhaines31
More in Productivityfrontend-ui-engineering
Skill · addyosmani
More in Productivitycontent-strategy
Skill · coreyhaines31
More in Productivityagent-self-evaluation
Skill · affaan-m
More in Productivity