Context Degradation skill
Diagnose long-context failures and plan recovery using verified facts and workload-specific comparisons.
Community · Muratcan Koylan| Author | Muratcan Koylan |
|---|---|
| Licence | MIT |
| Source | muratcankoylan/Agent-Skills-for-Context-Engineering · SKILL.md on GitHub |
| Works in | Claude Code · Codex, Gemini CLI, Cursor, Copilot |
| Read from the source on |
The context-degradation skill diagnoses failures caused by crowded, misleading or conflicting agent context.
It separates lost-in-middle behavior, poisoning, distraction, confusion and clashes. Recovery starts with the symptom and verified evidence rather than a universal token cutoff.
From the skill's SKILL.md: ## Gotchas
What it does
- Classify the observed failure and inspect its context.
- Compare repeated runs against a smaller-context baseline.
- Propose selective retrieval, compression, isolation or a verified restart.
What you get
- A context-failure diagnosis and a recovery experiment plan.
When to use it
- An agent misses requirements or repeats earlier mistakes in a long session.
When not to use it
- Implementing a persistent memory system or assuming every mistake is a context-window failure.
What it needs
- A file-capable agent with representative prompts, traces and expected outcomes.
- The optional Python example uses simulated attention and heuristic checks; it is not model telemetry or a calibrated detector.
Files in the skill
| File or folder | What it is for |
|---|---|
SKILL.md | Failure patterns, diagnostic comparisons and recovery guidance. |
references/patterns.md | A Python example detector and a reference guide to degradation patterns. |
scripts/degradation_detector.py | A Python example detector and a reference guide to degradation patterns. |
Licence as found in the repository on 2026-11-20: MIT.
Example prompts
Type one of these after installing; naming the skill makes sure it is used.
- Diagnose why this long session keeps overlooking the acceptance criteria.
- Compare short and long context runs before recommending compression.
- Plan a restart using only verified facts and their sources.
How to install context-degradation
Copy the complete skill folder
Keep references and scripts beside SKILL.md so relative links resolve. The marketplace plugin bundles the wider context-engineering collection.
No paid service is required to read the guidance. Real experiments need your agent and workload; model usage may cost money. Hosted upload and API execution are not verified here.
A skill is a folder with a SKILL.md file. You install it once; the agent reads its short description at the start of each session and loads the full instructions only when a request matches. Pick the place you use:
Claude Code: from the plugin marketplace
- Start Claude Code in a terminal with
claude. - Add the marketplace (once per computer):
/plugin marketplace add muratcankoylan/Agent-Skills-for-Context-Engineering - Install the plugin. Claude Code opens its details first: check what it will add (skills, hooks, MCP servers), then choose whether it is for you, for everyone on this repository, or for you in this repository only.
/plugin install context-engineering@context-engineering-marketplace - Type / and look for
/context-engineering:context-degradation, or simply ask for the task.
From your shell instead of a session:
claude plugin marketplace add muratcankoylan/Agent-Skills-for-Context-Engineering
claude plugin install context-engineering@context-engineering-marketplaceThe plugin installs as a whole, so other skills come with it, including context-fundamentals, context-compression, context-optimization, self-managed-context, multi-agent-patterns, long-horizon-prompting, memory-systems, tool-design, filesystem-context, hosted-agents, evaluation, advanced-evaluation, harness-engineering, project-development, bdi-mental-states, latent-briefing, self-improvement-loops.
Claude Code: copy the folder into your skills folder
Put the skill's folder in ~/.claude/skills/ to use it in every project on this computer, or in .claude/skills/ inside a repository to share it with everyone who works there (commit it).
git clone --depth 1 https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering.git
mkdir -p ~/.claude/skills
cp -R Agent-Skills-for-Context-Engineering/skills/context-degradation ~/.claude/skills/Claude Code notices new or changed skills in these folders during the session. If the skills folder did not exist when the session started, run /reload-skills once. Then type /context-degradation or just describe the task.
On Windows, run the commands in Git Bash or WSL, or copy the folder into the same place with File Explorer.
Codex, Gemini CLI, Cursor and GitHub Copilot
These agents read the same SKILL.md folders. The one folder all four accept inside a project is .agents/skills/, so this copies the skill there:
git clone --depth 1 https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering.git
mkdir -p .agents/skills
cp -R Agent-Skills-for-Context-Engineering/skills/context-degradation .agents/skills/| Agent | Project folder | Your user folder | Notes |
|---|---|---|---|
| OpenAI Codex | .agents/skills/ | ~/.agents/skills/ | Type $ or run /skills to pick a skill; Codex also chooses one when your task matches. |
| Gemini CLI | .agents/skills/.gemini/skills/ | ~/.agents/skills/~/.gemini/skills/ | Or install from Git with gemini skills install <git URL> --path <folder> --consent. Google replaced Gemini CLI with Antigravity CLI for free-tier and Google One users on 18 June 2026; Antigravity uses .agents/skills/ in a project and ~/.gemini/config/skills/ for you. |
| Cursor | .agents/skills/.cursor/skills/ | ~/.agents/skills/~/.cursor/skills/ | Type / in Agent chat to pick a skill. Cursor also reads Claude Code's .claude/skills/ folders. |
| GitHub Copilot | .github/skills/.agents/skills/.claude/skills/ | ~/.copilot/skills/~/.agents/skills/ | Works in Copilot CLI, the cloud agent, and agent mode in VS Code, Visual Studio and JetBrains (IDE support depends on the version). Or run gh skill install OWNER/REPOSITORY SKILL (public preview, GitHub CLI 2.90.0 or later). |
Sources for these steps
Checked against each vendor's documentation on 2026-11-14:
Diagnose before changing the harness
First test whether the prompt works with a smaller, relevant context. Repeat runs and compare outcomes so ordinary variability is not mistaken for degradation.
Put source provenance and precedence next to important facts. A shorter summary that preserves an error can still poison the next session.
Example detector limitations
The script illustrates risks using simulated curves and text patterns. Its output cannot establish whether a model attended to a passage or whether a claim is true.
Use real task outcomes to validate recovery. Record the model, prompt, context composition and experiment conditions so comparisons remain meaningful.
Questions about context-degradation
Does the example measure actual model attention?
No. It simulates attention curves and uses approximate token counts and pattern checks.
Is there one safe context length?
No. Establish a baseline for the model, task and harness instead of treating example thresholds as universal limits.
Should all earlier answers survive a restart?
No. Preserve verified facts with sources; carrying unsupported answers forward can repeat the failure.
Does this replace context compression?
No. It diagnoses the problem and selects a recovery approach; compression and durable memory need their own implementation.
More AI skills
Related skills
Agent Evaluation skill
Community · Muratcan KoylanPlan agent regression suites with deterministic checks, separate quality dimensions and versioned baselines.Advanced Evaluation skill
Community · Muratcan KoylanDesign LLM judges with evidence-based rubrics, swapped pairwise comparisons and human calibration.Dev-Browser skill
Community · Sawyer HoodAutomate Chrome with persistent named pages, Puppeteer scripts and a local command-line service.Tool Design skill
Community · Muratcan KoylanDesign agent-facing tool contracts with clear inputs, outputs, selection guidance and recoverable errors.Brainstorming skill
Community · Jesse Vincent / Prime RadiantTurn an undeveloped idea into an agreed design before writing implementation code.Writing Plans skill
Community · Jesse Vincent / Prime RadiantConvert an approved design into reviewable engineering tasks with interfaces and verification.