agentsclimarketplace

Session guard

Skill Adit-Jain-srm/skill-forge/skills/session-guard

18 AI agent skills that catch what your agent misses: hidden code debt, false completions, missing error handling, context amnesia, imprecise UI edits. Self-improving with TF-IDF routing + SkillOpt loop. Cursor, Claude Code, Codex, Copilot. Install: npx skills@latest add Adit-Jain-srm/skill-forge

Install
npx -y skills add Adit-Jain-srm/skill-forge --skill session-guard

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Prevents long-session corruption AND context compaction amnesia. Monitors session health, detects instruction drift, enforces critical-rule recitation, and splits proactively before degradation hits. Use when working on complex multi-step tasks, when a session is getting long, when the agent starts ignoring rules it followed earlier, when CLAUDE.md conventions drift, when output quality seems to degrade, or after any context compaction event.

SKILL.md

5.5 KB, as published. Nobody here has run it

Session Guard

Overview

Long sessions corrupt silently. Context compaction drops your instructions without warning. This skill prevents both: monitors health, anchors critical rules through compaction, and splits before damage occurs. No packages, no SQLite, no MCP — pure behavioral enforcement that works in Cursor AND Claude Code.

Process

Monitor session health passively. At checkpoints, RECITE critical rules to self-anchor. Split BEFORE corruption appears — once it occurs, it's invisible and irreversible.

Persistence

ACTIVE every session. Monitors passively. Escalates on threshold breach. Recites critical rules at checkpoints.

The Problem (June 2026, confirmed across platforms)

Two distinct failure modes:

1. Tool Call Degradation (50+ calls):

  • Hallucinated tool results (content that doesn't match files on disk)
  • Tool results duplicated (same read echoed 2-8x)
  • False progress (agent claims "done" for incomplete work)

2. Context Compaction Amnesia:

  • CLAUDE.md instructions silently dropped after compaction
  • Naming conventions, architectural rules, file structure constraints forgotten
  • Agent operates from "degraded mental model" without knowing it
  • Compaction summary creates "narrative momentum" that overrides re-injected rules

Both are PLATFORM limitations. Smart session management mitigates both completely.

Health Signals

SignalThresholdAction
Tool call count>40YELLOW: checkpoint + recite critical rules
Tool call count>60RED: split or compact with anchor
Agent contradicts earlier decisionAnyVERIFY: re-read source of truth
Style/naming conventions driftAnyRECITE: state the active rules aloud
File read returns unexpected contentAnyRE-READ: don't trust cached state
Repeated failed tool calls3+ same errorPAUSE: diagnose before continuing
Task scope growing unboundedContinuousSPLIT: 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 CLAUDE.md / 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 you detect compaction has occurred (sudden loss of earlier context, or after /compact):

1. RE-READ the project's CLAUDE.md or rules file immediately
2. RECITE the 3-5 critical rules from it 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 (use this to your advantage):

  • Most recent user messages (high priority)
  • Currently-invoked skill body (capped at 5K tokens — put critical rules near TOP)
  • Git status and project structure
  • File contents you 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)
  • Skill descriptions you didn't invoke

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 we agreed on earlier."

Session Split Protocol

## Handoff — Session Split

**Why split:** [signal that triggered]
**Progress:** [what's done]  
**Current state:** [modified files, test status]
**Critical rules still active:** [list the 3-5 rules that must carry forward]
**Next steps:** [exact actions — numbered, specific]

Start fresh session with: "Continue from handoff: [summary]. Critical rules: [list]"

Common Mistakes

  • Trusting that "I 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: Claude ignores post-compaction injections). External memory tools require heavy setup. This skill is the lightweight behavioral countermeasure: no infra, no packages — just disciplined self-monitoring that works anywhere.

The cost of anchoring: 5 seconds to recite rules at checkpoints. The cost of NOT anchoring: hours debugging code written against forgotten constraints.

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.