context-degradation

Diagnose context degradation in long-running agent sessions with attention mapping and health analysis.

Updated Apr 25, 2026
One-click install
npx skills add https://github.com/nshaikhs/claude-code-for-operators --skill context-degradation-nshaikhs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: context-degradation
Source: https://github.com/nshaikhs/claude-code-for-operators/tree/main/skills/context-engineering/skills/context-degradation
Command: npx skills add https://github.com/nshaikhs/claude-code-for-operators --skill context-degradation-nshaikhs

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

Long-running agent sessions often suffer from context degradation, leading to lost memory, misaligned tool usage, and inconsistent outputs. This Skill provides patterns and tooling to diagnose and mitigate issues like lost-in-middle, context poisoning, distraction, confusion, and context clash.

Core Features & Use Cases

  • Attention distribution mapping to identify where critical information sits in the context.
  • Lost-in-middle detection and recommendations to move important content to attention-favored regions.
  • Context structure analysis to assess layout risk and degradation potential.
  • In-line detectors for poisoning and hallucination markers and a composite ContextHealthAnalyzer for holistic health checks.
  • A convenience function analyze_agent_context for quick health analysis in real sessions.

Quick Start

Run the degradation detector on your current agent context to assess health and receive actionable recommendations.

Frequently Asked Questions about context-degradation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What is long-context degradation in agent sessions?

Detect context degradation by running attention distribution mapping, degradation detection, and context-structure analysis to identify layout risks and attention imbalance in your agent sessions.

How do I detect context poisoning in long-running agent conversations?

Detect context poisoning by applying in-line detectors for poisoning and hallucination markers, then run the composite ContextHealthAnalyzer for a holistic health check of the agent session.

How do I fix the lost-in-middle problem in long-context agent outputs?

Fix the lost-in-middle problem by mapping attention distribution to locate critical information, then follow recommendations to move important content to attention-favored regions of the context.

Can I run a quick context health analysis on a live agent session?

You can run a quick context health analysis on live sessions using the analyze_agent_context convenience function, which assesses attention balance, memory integrity, and tool usage degradation.

What are the limitations of using context degradation detection for agent memory management?

Context degradation detection focuses on diagnosing attention balance and context structure risks but does not automatically rewrite or compress context; it provides recommendations to guide manual remediation.