JavaScript is disabled. Some features may not work.
context-degradation — ★ 16.7K GitHub Stars — Install Guide | SkillsNav
🇺🇸 English🇨🇳 中文
SkillsNav
Home

context-degradation

★ 16K repomlN/AIntermediateClaude
🤖 AI Summary

This skill detects and mitigates five specific patterns of context degradation (lost-in-middle, poisoning, distraction, confusion, clash) by applying measurable thresholds and targeted recovery strategies, treating context failures as predictable engineering problems rather than random errors.

How to Install

Claude Code:
git clone --depth 1 https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering.git && cp Agent-Skills-for-Context-Engineering/skills/context-degradation ~/.claude/skills/context-degradation -r
# 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. Treat context poisoning as a circuit breaker problem. Once a hallucination, tool error, or incorrect retrieved fact enters context, it compounds through repeated self-reference. A poisoned goals section causes every downstream decision to reinforce incorrect assumptions. Detection requires tracking claim provenance; recovery requires truncating to before the poisoning point or restarting with verified-only context. Filter aggressively before loading context — even a single irrelevant document measurably degrades performance on relevant tasks. Models cannot "skip" irrelevant context; they must attend to everything provided, creating attention competition between relevant and irrelevant content. Move information that might be needed but is not immediately relevant behind tool calls instead of pre-loading it. Isolate task contexts to prevent confusion. When context contains multiple task types or switches between objectives, models incorporate constraints from the wrong task, call tools appropriate for a different context, or blend requirements from multiple sources. Explicit task segmentation with separate context windows eliminates cross-contamination. Resolve context clash throug

Details

Category AI/ML → ml
Sourcemuratcankoylan/Agent-Skills-for-Context-Engineering
SKILL.mdView on GitHub →
Repo Stars★ 16.7K
Est. per SkillN/A (shared across 17 skills from this repo)
DifficultyIntermediate
Risk LevelN/A

Related Skills

Works Well With

Skills from the same repository — often designed to work together