# context-window-management

A skill for handling LLM context windows: summarization, trimming, routing and fighting context rot. Useful when a long dialogue runs into the token limit.

- skill · `type=skill` · Claude Code · 309 installs
- Author: davila7
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/davila7/claude-code-templates/tree/HEAD/cli-tool/components/skills/ai-research/context-window-management
- Updated: 2026-10-24
- HTML: https://affpapa.org/en/nevibecode/skills/context-window-management

## What it does

The skill turns the agent into a context engineering specialist. It works from the idea that context is a finite resource, and it lays out what to do once tokens pile up: how to summarize, what to trim, where to route a request.

Inside are patterns and anti-patterns. Tiered Context Strategy picks an approach based on context size, Serial Position Optimization puts important content at the start and the end, Intelligent Summarization compresses by importance rather than recency. The anti-pattern list names naive truncation, ignoring token costs and applying one approach to every case.

The skill is meant to sit alongside `rag-implementation`, `conversation-memory`, `prompt-caching` and `llm-npc-dialogue`. In Claude it installs with `npx claude-code-templates@latest --skill ai-research/context-window-management` or `npx skills add davila7/claude-code-templates --skill context-window-management -a claude-code`, landing at `~/.claude/skills/context-window-management/SKILL.md`.

## Install

### Claude Code (native platform)

1. **claude-code-templates**
```bash
npx claude-code-templates@latest --skill ai-research/context-window-management
```

2. **Skills CLI (Vercel)**
```bash
npx skills add davila7/claude-code-templates --skill context-window-management -a claude-code
```

3. **Manually: put the files in place**
- File: `~/.claude/skills/context-window-management/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/context-window-management/

### Codex

**Manually: put the files in place**
- File: `.agents/skills/context-window-management/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

**Manually: put the files in place**
- File: `.cursor/skills/context-window-management/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install davila7/claude-code-templates context-window-management
```

2. **Manually: put the files in place**
- File: `.github/skills/context-window-management/SKILL.md`

### Gemini CLI

**Platform CLI**
```bash
gemini skills install https://github.com/davila7/claude-code-templates --path cli-tool/components/skills/ai-research/context-window-management
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/context-window-management/SKILL.md` — The legacy .windsurf/skills/ path still works

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/davila7/claude-code-templates/tree/HEAD/cli-tool/components/skills/ai-research/context-window-management

## When to use it
- decide what to summarize and what to keep in context
- place key facts at the edges so the middle does not swallow them
- pick a context strategy for a given size instead of one for all
- estimate token cost before hitting the limit
- tie context handling to RAG and prompt caching

## Example prompts
- Help me sort out the context window: what should be summarized in this long dialogue?
- Move the key facts to the edges of the context so the middle does not lose them
- Pick a context strategy for this size — trimming or summarization?

## Similar
- [context-compression](https://affpapa.org/en/nevibecode/skills/muratcankoylan-context-compression.md) — skill · 459 installs
- [context-budget](https://affpapa.org/en/nevibecode/skills/context-budget.md) — skill · 5000 installs
- [c-ai](https://affpapa.org/en/nevibecode/skills/c-ai.md) — skill · ★ 173
- [window-management](https://affpapa.org/en/nevibecode/skills/window-management.md) — skill · 58 installs
- [llm-context](https://affpapa.org/en/nevibecode/skills/llm-context.md) — skill · 1300 installs
- [context-engineering](https://affpapa.org/en/nevibecode/skills/mrgoonie-context-engineering.md) — skill · 496 installs

## Other versions with the same name
- [context-window-management · sickn33](https://affpapa.org/en/nevibecode/skills/sickn33-context-window-management.md) — 1600 installs

From the same set: [davila7/claude-code-templates](https://affpapa.org/en/nevibecode/by/davila7/claude-code-templates.md) — 495 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
