# Context Degradation

Should be used for diagnosing and mitigating context degradation: lost-in-middle...

- Repository: https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering (18272 stars)
- Category: AI and agents
- License: MIT
- Last updated: 2026-10-12
- Runs scripts: yes, review before use

## Install

Claude Code: `npx skills add muratcankoylan/Agent-Skills-for-Context-Engineering --skill context-degradation -g -a claude-code -y`
Codex: `npx skills add muratcankoylan/Agent-Skills-for-Context-Engineering --skill context-degradation -g -a codex -y`
Cursor: `npx skills add muratcankoylan/Agent-Skills-for-Context-Engineering --skill context-degradation -g -a cursor -y`
Gemini CLI: `npx skills add muratcankoylan/Agent-Skills-for-Context-Engineering --skill context-degradation -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add muratcankoylan/Agent-Skills-for-Context-Engineering`

## Description

This skill should be used for diagnosing and mitigating context degradation: lost-in-middle failures, context poisoning, context clash, context confusion, attention-pattern issues, and agent performance degradation caused by accumulated or conflicting context.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Context Degradation Patterns

Diagnose and fix context failures before they cascade. Context degradation is not binary, it is a continuum that manifests through five distinct, predictable patterns: lost-in-middle, poisoning, distraction, confusion, and clash. Each pattern has specific detection signals and mitigation strategies. Treat degradation as an engineering problem with measurable thresholds, not an unpredictable failure mode.

## When to Activate

Activate this skill when:
- Agent performance degrades unexpectedly during long conversations
- Debugging cases where agents produce incorrect or irrelevant outputs
- Designing systems that must handle large contexts reliably
- Evaluating context engineering choices for production systems
- Investigating "lost in middle" phenomena in agent outputs
- Analyzing context-related failures in agent behavior

Do not activate this skill for adjacent work owned by other skills:
- Explaining foundational context mechanics without an active failure: `context-fundamentals`.
- Applying token-efficiency tactics after the failure pattern is known: `context-optimization`.
- Designing a compression or handoff summary strategy: `context-compression`.
- Persisting large outputs, logs, or scratch state outside the prompt: `filesystem-context`.

## Core Concepts

Structure context placement around the attention U-curve: beginning and end positions receive reliable attention, while middle positions suffer materially reduced recall accuracy in long-context experiments (claim-context-degradation-lost-middle-ruler). This is not a model bug but a consequence of attention mechanics, the first token (often BOS) acts as an "attention sink" that absorbs disproportionate attention budget, leaving middle tokens under-attended as context grows.

The rest: https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering/blob/HEAD/skills/context-degradation/SKILL.md
