# Diagnose and Repair Context Degradation

Long contexts can hide critical instructions, preserve bad claims, and mix conflicting tasks. This skill diagnoses the failure pattern and recommends placement, filtering, compression, isolation, or recovery strategies.

## Install

```bash
npx skillstore add muratcankoylan/context-degradation
```

## Metadata

- Status: approved
- Slug: muratcankoylan-context-degradation
- Skillstore revision: r2
- Version status: missing
- Tree hash: 8fd3d62a266184c4c7d70ec3297eacd24ee3333185d5c9f6bc7ab6554cdd9b81
- Author: muratcankoylan
- GitHub username: muratcankoylan
- License: MIT
- Repository: https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering/tree/main/skills/context-degradation
- Ref: 02be9409c79ca1183f7844009c14d9df684d0cf9
- Supported tools: Claude, Codex, Claude Code
- Audit status: complete
- Agent install advisory: allowed
- Manual install advisory: allowed
- Artifact signature: available
- Audit attestation: unavailable
- Human verification: not\_verified
- Risk factors: external\_commands
- Quality score: 80
- Quality tier: silver
- Public page: https://skillstore.pages.dev/skills/muratcankoylan-context-degradation
- Manifest: https://skillstore.pages.dev/api/skills/muratcankoylan-context-degradation/manifest

## Capabilities

- Classifies failures as lost-in-middle, poisoning, distraction, confusion, or clash.
- Estimates attention distribution across context positions with a demonstrative U-shaped model.
- Flags critical items placed in attention-degraded regions.
- Detects heuristic poisoning indicators, contradictions, and uncertain claim markers.
- Produces a composite context health score with mitigation recommendations.

## Use Cases

- Debug a Long Agent Session: Identify why instructions or facts stop influencing responses as conversation history grows.
- Review Retrieved Context: Find irrelevant, outdated, contradictory, or unverified material before it enters a model prompt.
- Design Reliability Tests: Define workload-specific baselines, degradation thresholds, monitoring signals, and recovery checks.

## Prompt Templates

### Quick Context Diagnosis

```
Review this conversation for context degradation. Identify the likely pattern, cite symptoms, and recommend three immediate fixes.
```

### Lost-in-Middle Review

```
Analyze the supplied prompt layout for lost-in-middle risk. Mark critical content, assess placement, and propose a safer ordering.
```

### Retrieval Quality Audit

```
Compare these documents for poisoning, distraction, and clash. Explain source conflicts, relevance gaps, and content that should be removed.
```

### Production Health Plan

```
Design a context health plan for this agent. Define metrics, baselines, alert thresholds, compaction triggers, recovery steps, and validation tests.
```

## Limitations

- Attention values are simulated and do not inspect model internals.
- Token counts use whitespace splitting instead of model-specific tokenizers.
- Poisoning detection relies on simple patterns and can produce false positives.
- Published degradation thresholds require validation against each model and workload.

## Best Practices

- Establish a low-context performance baseline before diagnosing degradation.
- Keep source provenance and version labels beside every retrieved claim.
- Trigger compaction or isolation before measured performance reaches its decline threshold.

## Anti Patterns

- Do not treat one weak response as proof of context degradation.
- Do not add corrections while leaving known poisoned claims in context.
- Do not assume advertised context capacity guarantees workload quality.

## Security Audit

- Audited at: 2026-08-09T09:34:17.378\+00:00
- Summary: All 22 static findings are false positives caused by Python documentation markup, Markdown formatting, ordinary text literals, and a benign dictionary-key print. No command execution, credential handling, system reconnaissance, prompt injection, or other malicious intent was found.

## Stats

- Views: 219
- Downloads: 21
- Favorites: 0
- Popularity score: 0
