Skip to main content
skill Claude Code CX Codex Cursor

session-guard — Claude Code skill: what it does, how to install

session-guard monitors long sessions and rule drift. Use it for multi-step tasks or after a context compaction event.

Install into Claude Code · Plugin marketplace All methods and platforms ↓
/plugin marketplace add wshobson/agents
/plugin install skill-forge-essentials@claude-code-workflows
Open on GitHub

What session-guard does

session-guard helps an agent keep its working rules during a long session. It watches tool-call count, contradictions with earlier decisions, style and naming drift, and unexpected file contents. After 40 tool calls it prompts a checkpoint and a repeat of critical rules. After 60, it tells the agent to stop, re-read project rules, and prepare a handoff for a new session.

The skill uses a behavioral protocol, so it needs no packages or database. After context compaction, it requires the project rules file to be read again, the next action to be checked, and the source file to be revisited when an earlier decision is uncertain. For Claude Code, install it with npx skills add wshobson/agents --skill session-guard -a claude-code; Codex and Cursor have their own install commands.

Install it when a task spans many steps and earlier conventions matter. It is unnecessary for a short session with no context compaction.

What it helps with

  • monitor a long agent session
  • catch style and naming drift
  • restore project rules after context compaction
  • split a task before session damage grows

Example prompts for the agent

  • Check the session health and recite the active rules before the next step.
  • Context compaction just occurred. Re-read the project rules and verify the plan.
  • The session passed 40 tool calls. Create a checkpoint and assess whether the task should be split.

How to install session-guard

1Plugin marketplace

/plugin marketplace add wshobson/agents
/plugin install skill-forge-essentials@claude-code-workflows

This installs the whole skill-forge-essentials plugin with all its skills

2Skills CLI (Vercel)

npx skills add wshobson/agents --skill session-guard -a claude-code

3Manually: put the files in place

~/.claude/skills/session-guard/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/session-guard/

From the same set213

The whole set →
typescript-advanced-types Seth Hobson Guides an agent through advanced TypeScript types, from generics to conditional and mapped types. Use it for typed libraries, API clients, or strict configuration objects. Claude Code CX Codex Cursor 92,169installs tailwind-design-system Seth Hobson Helps build design systems with Tailwind CSS v4, from theme tokens to component variants. Use it when a project needs shared UI patterns. Claude Code CX Codex Cursor 70,180installs brand-landingpage Travis D. Elliott This skill interviews you about the product and its visual direction, then builds a landing page through Stitch. Use it when there’s no established design yet. Claude Code CX Codex Cursor 39,476installs python-testing-patterns Seth Hobson This skill guides Python testing with pytest, fixtures and mocks. Use it when building a test suite or tracking down failing checks. Claude Code CX Codex Cursor 36,943installs python-performance-optimization Seth Hobson This skill profiles Python code to locate CPU and memory bottlenecks. Use it when an application responds slowly or consumes too many resources. Claude Code CX Codex Cursor 35,675installs nextjs-app-router-patterns Seth Hobson This skill covers Next.js App Router patterns for rendering, routing, and data fetching. Use it when starting an App Router project or moving from Pages Router. Claude Code CX Codex Cursor 32,529installs api-design-principles Seth Hobson Use this skill to plan or review REST and GraphQL APIs. It helps when writing a specification or setting API conventions for a team. Claude Code CX Codex Cursor 30,348installs code-review-excellence Seth Hobson This skill guides pull request reviews, catches logic and security issues, and helps teams give specific feedback. Use it for review standards or developer mentoring. Claude Code CX Codex Cursor 30,193installs

Similar

lsp-setup official github Installs a language server and configures LSP for Copilot CLI. Use it when you need code navigation such as go-to-definition or find-references. GitHub Copilot 1,100installs team Yeachan-Heo Coordinates several agents through a shared task list and assigns work by stage. Use it when a larger task needs parallel execution and review. Claude Code CX Codex Cursor +1 878installs project-session-manager Yeachan-Heo Automates creation of separate git worktrees for each task, PR, or feature, with optional tmux session orchestration. Work on multiple branches in parallel without conflicts. Claude Code CX Codex Cursor +1 861installs skill Yeachan-Heo Manage local skills with slash commands to list, create, search, edit, and remove them. It suits projects that keep both user and project-level skill files. Claude Code CX Codex Cursor +1 833installs handoff thedotmack Generates a structured HANDOFF.md with goals, failed attempts, and next steps. Use it when context degrades or when starting a fresh session. Claude Code CX Codex Cursor +1 344installs obsidian-canvas-creator axtonliu Turns text into a JSON Canvas file that Obsidian opens as an interactive board. Choose a radial mind map or a freeform layout with grouped zones. Claude Code CX Codex Cursor +1 2,000installs find-skills vercel-labs Discovers and installs agent skills from skills.sh directly inside your coding assistant. Handy when you need domain-specific workflows for a project. Claude Code CX Codex Cursor +1 4,000,000installs grill-me Matt Pocock grill-me interviews you about a plan or design to expose gaps and sharpen decisions. Use it before implementation starts. Claude Code 1,424,476installs

Questions about session-guard

How do I install session-guard in Claude Code?

Run npx skills add wshobson/agents --skill session-guard -a claude-code. The skill file is placed at ~/.claude/skills/session-guard/SKILL.md.

What does session-guard do?

It monitors long-session warning signs: tool-call count, contradictions with earlier decisions, convention drift, and context compaction. It prompts checkpoints, rule reviews, or a handoff to a fresh session.

Which platforms work with session-guard?

The input includes installation options for Claude Code, Codex, and Cursor. Codex uses npx skills add wshobson/agents --skill session-guard -a codex, while Cursor uses npx skills add wshobson/agents --skill session-guard -a cursor.

Source text

SKILL.md · MIT
---
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.
---

# 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)
Normal operation. No intervention needed.

### Yellow Zone (40-60 tool calls)
1. CHECKPOINT - summarize progress in one paragraph
2. RECITE - state the 3-5 most critical active rules aloud: "Active rules: [naming convention], [file structure], [error handling pattern], [testing requirement]"
3. ASSESS - almost done? Push through. Not done? Prepare split.
4. REDUCE - no exploratory reads. Only targeted operations.

### Red Zone (60+ tool calls OR drift signal)
1. STOP - do not make more tool calls
2. VERIFY - re-read project rules (don't trust memory)
3. CHECKPOINT - write state to handoff document
4. SPLIT - create handoff, suggest fresh session

## Context Anchoring (anti-compaction)

When compaction has occurred (sudden loss of earlier context, or after /compact):

1. RE-READ the project's rules file immediately
2. RECITE the 3-5 critical rules aloud in your response
3. VERIFY your planned next action matches those rules before executing
4. 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.

© Adit Jain · MIT · wshobson/agents

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor